# Copyright (c) 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: Request2.bunit,v 1.13 2010/04/06 01:35:23 nagler Exp $ Request(); [ sub {req()} => [ { method => 'set_realm', compute_return => sub { return [$_[1]->[0]->get('type')->get_name]; }, } => [ [undef] => 'GENERAL', demo => 'USER', fourem => 'FORUM', 1 => 'GENERAL', 2 => 'USER', ], with_realm => [ [undef, sub {req('auth_realm')->is_general}] => 1, [fourem => sub {req(qw(auth_realm owner_name))}] => 'fourem', [fourem => sub {die('here we go')}] => qr{DIE:.*here we go}, [undef, sub {(1, 2)}] => [1, 2], ], { method => 'with_realm', want_scalar => 1, } => [ [undef, sub {()}] => [undef], [undef, sub {1}] => 1, [undef, sub {(1, 2)}] => DIE(), ], with_user => [ [undef, sub {req('auth_user')}] => [undef], [root => sub {req(qw(auth_user name))}] => 'root', [demo => sub {die('here we go')}] => qr{DIE:.*here we go}, ], map_user_realms => [ [sub {$_->{'RealmOwner.name'}}] => [[]], ], { method => 'map_user_realms', compute_params => sub { my(undef, $params) = @_; req()->set_user(shift(@$params)); return [sub {$_->{'RealmOwner.name'}}, @$params]; }, } => [ btest_read => [[qw(btest_read fourem fourem-sub1 fourem-sub1-1 fourem-sub2 site-admin)]], [btest_read => { 'RealmOwner.realm_type' => Bivio::Auth::RealmType->USER, }] => [[qw(btest_read)]], [root => { 'RealmOwner.realm_type' => Bivio::Auth::RealmType->USER, 'RealmUser.role' => Bivio::Auth::Role->ADMINISTRATOR, }] => [[qw(root)]], ], put => [ [query => 'a=3'] => sub { assert_equals({a => 3}, req('query')); return 1; }, ], ], ];