# Copyright (c) 2007 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: RealmUser.bunit,v 1.4 2009/02/26 23:47:50 nagler Exp $ PropertyModel(); [ { method => 'is_sole_admin', compute_params => sub { my($case, $params) = @_; my($realm, $user, $role) = @$params; $role ||= 'ADMINISTRATOR'; req()->set_realm_and_user($realm, $user); $case->get('object')->load({ user_id => req('auth_user_id'), role => class('Auth.Role')->$role, }); return []; }, } => [ [qw(demo guest GUEST)] => 0, [qw(demo demo)] => 1, [qw(fourem-sub2 btest_admin)] => 0, ], unauth_delete_user => [ sub { my($case) = @_; my($uid) = create_user('realm_user_bunit')->get('realm_id'); foreach my $r (map(class('Auth.Role')->$_(), qw(MEMBER GUEST))) { model('RealmUser')->create({ realm_id => realm_id('demo'), user_id => $uid, role => $r, }); } $case->put(object => req('Model.RealmUser')); return []; } => not_die(), ], inline_case(sub { assert_equals( 0, unauth_model('RealmOwner')->unauth_load({name => 'realm_user_bunit'}), ); return; }), { method => 'get_any_online_admin', compute_params => sub { my(undef, $params) = @_; req()->set_realm($params->[0]); return []; }, compute_return => sub { my(undef, $actual) = @_; return [$actual->[0]->get('name')]; }, } => [ general => 'root', fourem => 'root', demo => 'demo', user => DIE(), club => DIE(), ], ];