File: 05whoami.t

package info (click to toggle)
librdf-acl-perl 0.104-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 212 kB
  • sloc: perl: 359; makefile: 2
file content (60 lines) | stat: -rw-r--r-- 1,187 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use Test::More tests => 6;
use RDF::ACL;
use Error qw(:try);

my $acl = RDF::ACL->new;

my $id = $acl->allow(
	'webid'     => ['http://example.com/joe#me'],
	'item'      => 'http://example.com/private/document',
	'level'     => ['read']
	);

$acl->i_am('http://example.com/joe#me');

is($acl->who_am_i, 'http://example.com/joe#me',
	"who_am_i works");

try
{
	$acl->allow(
		'webid'     => ['http://example.com/joe#me'],
		'item'      => 'http://example.com/private/document',
		'level'     => ['write']
		);
}
catch Error::Simple with
{
	my $e = shift;
	ok($e, "This is supposed to fail:- $e");
};

try
{
	$acl->deny($id);
}
catch Error::Simple with
{
	my $e = shift;
	ok($e, "This is also supposed to fail:- $e");
};

$acl->i_am(undef);

ok($acl->allow(
		'webid'     => ['http://example.com/joe#me'],
		'item'      => 'http://example.com/private/document',
		'level'     => ['control']
		),
	"Assigning control access to joe.");

$acl->i_am('http://example.com/joe#me');

ok($acl->allow(
		'webid'     => ['http://example.com/joe#me'],
		'item'      => 'http://example.com/private/document',
		'level'     => ['write']
		),
	"Now it works!");

ok($acl->deny($id), "This works too!");