1
+ import pytest
1
2
from satosa .internal import AuthenticationInformation
2
3
from satosa .internal import InternalData
3
4
from satosa .micro_services .attribute_authorization import AttributeAuthorization
@@ -25,7 +26,7 @@ def test_authz_allow_success(self):
25
26
ctx = Context ()
26
27
ctx .state = dict ()
27
28
authz_service .process (ctx , resp )
28
- except SATOSAAuthenticationError as ex :
29
+ except SATOSAAuthenticationError :
29
30
assert False
30
31
31
32
def test_authz_allow_fail (self ):
@@ -38,13 +39,10 @@ def test_authz_allow_fail(self):
38
39
resp .attributes = {
39
40
"a0" : ["bar" ],
40
41
}
41
- try :
42
+ with pytest . raises ( SATOSAAuthenticationError ) :
42
43
ctx = Context ()
43
44
ctx .state = dict ()
44
45
authz_service .process (ctx , resp )
45
- assert False
46
- except SATOSAAuthenticationError as ex :
47
- assert True
48
46
49
47
def test_authz_allow_second (self ):
50
48
attribute_allow = {
@@ -60,7 +58,7 @@ def test_authz_allow_second(self):
60
58
ctx = Context ()
61
59
ctx .state = dict ()
62
60
authz_service .process (ctx , resp )
63
- except SATOSAAuthenticationError as ex :
61
+ except SATOSAAuthenticationError :
64
62
assert False
65
63
66
64
def test_authz_deny_success (self ):
@@ -73,13 +71,10 @@ def test_authz_deny_success(self):
73
71
resp .attributes = {
74
72
"a0" : ["foo2" ],
75
73
}
76
- try :
74
+ with pytest . raises ( SATOSAAuthenticationError ) :
77
75
ctx = Context ()
78
76
ctx .state = dict ()
79
77
authz_service .process (ctx , resp )
80
- assert False
81
- except SATOSAAuthenticationError as ex :
82
- assert True
83
78
84
79
def test_authz_deny_fail (self ):
85
80
attribute_deny = {
@@ -95,5 +90,5 @@ def test_authz_deny_fail(self):
95
90
ctx = Context ()
96
91
ctx .state = dict ()
97
92
authz_service .process (ctx , resp )
98
- except SATOSAAuthenticationError as ex :
93
+ except SATOSAAuthenticationError :
99
94
assert False
0 commit comments