-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for global per resource rules
These rules apply to all the entities. They follow the same convention as the rules for all the resources('' is "all") and have lower priority than the specific rules.
- Loading branch information
Showing
3 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::More tests => 6; | ||
use Authorize::Rule; | ||
|
||
my $auth = Authorize::Rule->new( | ||
default => 0, | ||
rules => { | ||
'Person' => { | ||
'place' => [ [ 1 ] ] | ||
}, | ||
'' => { | ||
'public' => [ [ 1 ] ], | ||
'' => [ [ 1 ] ], # ignored | ||
} | ||
}, | ||
); | ||
|
||
isa_ok( $auth, 'Authorize::Rule' ); | ||
|
||
ok( | ||
$auth->is_allowed( 'Person', 'place' ), | ||
'Person allowed to enter Place', | ||
); | ||
|
||
ok( | ||
! $auth->is_allowed( 'Foo', 'place' ), | ||
'Foo is not allowed in Place', | ||
); | ||
|
||
ok( | ||
$auth->is_allowed( 'Person', 'public' ), | ||
'Person is allowed in the public place' | ||
); | ||
|
||
ok( | ||
$auth->is_allowed( 'Foo', 'public' ), | ||
'Foo is allowed in the public place', | ||
); | ||
|
||
ok( | ||
! $auth->is_allowed( 'Person', 'not_public'), | ||
'Person not allowed in the not_public place(default rule)', | ||
); | ||
|