# Copyright (c) 2005-2006 bivio Software, Inc. All rights reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: Request.bunit,v 1.6 2011/11/05 23:43:38 nagler Exp $ Request(); req()->initialize_fully; my($resource) = class('Bivio::Agent::t::Mock::Resource')->new; [ sub {req()} => [ { method => 'unsafe_get_txn_resource', compute_params => sub { my(undef, $params) = @_; req()->push_txn_resource($params->[0]) if @$params; return [ref($resource)]; }, } => [ [] => [undef], [$resource] => [$resource], ], format_uri => [ LOGOUT => '/pub/logout', [{task_id => 'LOGOUT'}] => '/pub/logout', [{ task_id => 'LOGOUT', facade_uri => 'other', }] => qr{^http://other.*/pub/logout$}, sub { shift->get('object')->put(req()->REQUIRE_ABSOLUTE_GLOBAL => 1); return ['LOGOUT']; } => sub { shift->get('object')->delete(req()->REQUIRE_ABSOLUTE_GLOBAL); return qr{^http:/.*/pub/logout$}; }, LOGOUT => '/pub/logout', ], format_http_prefix => [ [] => qr{^http://(?!other)}, [1] => qr{^https://(?!other)}, [undef, 'other'] => qr{^\Qhttp://other.}, [1, 'other'] => qr{^\Qhttps://other.}, [undef, 'bad.facade.name'] => qr{^http://(?!other)}, ], set_task_and_uri => [ [{task_id => 'SITE_WIKI_VIEW', path_info => 'hello'}] => sub { assert_equals('SITE_WIKI_VIEW', req('task_id')); assert_equals('hello', req('path_info')); assert_equals('/bp/hello', req('initial_uri')); assert_equals('/bp/hello', req('uri')); return 1; }, [{}] => qr{task_id.*require}i, ], ], ];