1+ import pytest
12from satosa .internal import AuthenticationInformation
23from satosa .internal import InternalData
34from satosa .micro_services .attribute_authorization import AttributeAuthorization
@@ -25,7 +26,7 @@ def test_authz_allow_success(self):
2526 ctx = Context ()
2627 ctx .state = dict ()
2728 authz_service .process (ctx , resp )
28- except SATOSAAuthenticationError as ex :
29+ except SATOSAAuthenticationError :
2930 assert False
3031
3132 def test_authz_allow_fail (self ):
@@ -38,13 +39,10 @@ def test_authz_allow_fail(self):
3839 resp .attributes = {
3940 "a0" : ["bar" ],
4041 }
41- try :
42+ with pytest . raises ( SATOSAAuthenticationError ) :
4243 ctx = Context ()
4344 ctx .state = dict ()
4445 authz_service .process (ctx , resp )
45- assert False
46- except SATOSAAuthenticationError as ex :
47- assert True
4846
4947 def test_authz_allow_second (self ):
5048 attribute_allow = {
@@ -60,7 +58,7 @@ def test_authz_allow_second(self):
6058 ctx = Context ()
6159 ctx .state = dict ()
6260 authz_service .process (ctx , resp )
63- except SATOSAAuthenticationError as ex :
61+ except SATOSAAuthenticationError :
6462 assert False
6563
6664 def test_authz_deny_success (self ):
@@ -73,13 +71,10 @@ def test_authz_deny_success(self):
7371 resp .attributes = {
7472 "a0" : ["foo2" ],
7573 }
76- try :
74+ with pytest . raises ( SATOSAAuthenticationError ) :
7775 ctx = Context ()
7876 ctx .state = dict ()
7977 authz_service .process (ctx , resp )
80- assert False
81- except SATOSAAuthenticationError as ex :
82- assert True
8378
8479 def test_authz_deny_fail (self ):
8580 attribute_deny = {
@@ -95,5 +90,5 @@ def test_authz_deny_fail(self):
9590 ctx = Context ()
9691 ctx .state = dict ()
9792 authz_service .process (ctx , resp )
98- except SATOSAAuthenticationError as ex :
93+ except SATOSAAuthenticationError :
9994 assert False
0 commit comments