@@ -10,9 +10,9 @@ def create_authz_service(self, attribute_allow, attribute_deny):
10
10
authz_service .next = lambda ctx , data : data
11
11
return authz_service
12
12
13
- def test_authz_allow (self ):
13
+ def test_authz_allow_success (self ):
14
14
attribute_allow = {
15
- "" : { "default" : {"a0" : '.+@.+' } }
15
+ "" : { "default" : {"a0" : [ '.+@.+' ] } }
16
16
}
17
17
attribute_deny = {}
18
18
authz_service = self .create_authz_service (attribute_allow , attribute_deny )
@@ -27,9 +27,9 @@ def test_authz_allow(self):
27
27
except SATOSAAuthenticationError as ex :
28
28
assert False
29
29
30
- def test_authz_not_allow (self ):
30
+ def test_authz_allow_fail (self ):
31
31
attribute_allow = {
32
- "" : { "default" : {"a0" : 'foo' } }
32
+ "" : { "default" : {"a0" : [ 'foo1' , 'foo2' ] } }
33
33
}
34
34
attribute_deny = {}
35
35
authz_service = self .create_authz_service (attribute_allow , attribute_deny )
@@ -41,5 +41,58 @@ def test_authz_not_allow(self):
41
41
ctx = Context ()
42
42
ctx .state = dict ()
43
43
authz_service .process (ctx , resp )
44
+ assert False
45
+ except SATOSAAuthenticationError as ex :
46
+ assert True
47
+
48
+ def test_authz_allow_second (self ):
49
+ attribute_allow = {
50
+ "" : { "default" : {"a0" : ['foo1' ,'foo2' ]} }
51
+ }
52
+ attribute_deny = {}
53
+ authz_service = self .create_authz_service (attribute_allow , attribute_deny )
54
+ resp = InternalResponse (AuthenticationInformation (None , None , None ))
55
+ resp .attributes = {
56
+ "a0" : ["foo2" ,"kaka" ],
57
+ }
58
+ try :
59
+ ctx = Context ()
60
+ ctx .state = dict ()
61
+ authz_service .process (ctx , resp )
62
+ except SATOSAAuthenticationError as ex :
63
+ assert False
64
+
65
+ def test_authz_deny_success (self ):
66
+ attribute_deny = {
67
+ "" : { "default" : {"a0" : ['foo1' ,'foo2' ]} }
68
+ }
69
+ attribute_allow = {}
70
+ authz_service = self .create_authz_service (attribute_allow , attribute_deny )
71
+ resp = InternalResponse (AuthenticationInformation (None , None , None ))
72
+ resp .attributes = {
73
+ "a0" : ["foo2" ],
74
+ }
75
+ try :
76
+ ctx = Context ()
77
+ ctx .state = dict ()
78
+ authz_service .process (ctx , resp )
79
+ assert False
44
80
except SATOSAAuthenticationError as ex :
45
81
assert True
82
+
83
+ def test_authz_deny_fail (self ):
84
+ attribute_deny = {
85
+ "" : { "default" : {"a0" : ['foo1' ,'foo2' ]} }
86
+ }
87
+ attribute_allow = {}
88
+ authz_service = self .create_authz_service (attribute_allow , attribute_deny )
89
+ resp = InternalResponse (AuthenticationInformation (None , None , None ))
90
+ resp .attributes = {
91
+ "a0" : ["foo3" ],
92
+ }
93
+ try :
94
+ ctx = Context ()
95
+ ctx .state = dict ()
96
+ authz_service .process (ctx , resp )
97
+ except SATOSAAuthenticationError as ex :
98
+ assert False
0 commit comments