@@ -103,19 +103,19 @@ def get_path_from_url(url):
103
103
for endp in all_sp_endpoints :
104
104
assert any (p .match (endp ) for p in compiled_regex )
105
105
106
- def test_start_auth_defaults_to_redirecting_to_discovery_server (self , context , sp_conf ):
106
+ def test_start_auth_defaults_to_redirecting_to_discovery_server (self , context , sp_conf , ** kwargs ):
107
107
resp = self .samlbackend .start_auth (context , InternalData ())
108
108
assert_redirect_to_discovery_server (resp , sp_conf , DISCOSRV_URL )
109
109
110
- def test_discovery_server_set_in_context (self , context , sp_conf ):
110
+ def test_discovery_server_set_in_context (self , context , sp_conf , ** kwargs ):
111
111
discosrv_url = 'https://my.org/saml_discovery_service'
112
112
context .decorate (
113
113
SAMLBackend .KEY_SAML_DISCOVERY_SERVICE_URL , discosrv_url
114
114
)
115
115
resp = self .samlbackend .start_auth (context , InternalData ())
116
116
assert_redirect_to_discovery_server (resp , sp_conf , discosrv_url )
117
117
118
- def test_full_flow (self , context , idp_conf , sp_conf ):
118
+ def test_full_flow (self , context , idp_conf , sp_conf , ** kwargs ):
119
119
test_state_key = "test_state_key_456afgrh"
120
120
response_binding = BINDING_HTTP_REDIRECT
121
121
fakeidp = FakeIdP (USERS , config = IdPConfig ().load (idp_conf , metadata_construction = False ))
@@ -165,21 +165,21 @@ def test_start_auth_redirects_directly_to_mirrored_idp(
165
165
resp = self .samlbackend .start_auth (context , InternalData ())
166
166
assert_redirect_to_idp (resp , idp_conf )
167
167
168
- def test_redirect_to_idp_if_only_one_idp_in_metadata (self , context , sp_conf , idp_conf ):
168
+ def test_redirect_to_idp_if_only_one_idp_in_metadata (self , context , sp_conf , idp_conf , ** kwargs ):
169
169
sp_conf ["metadata" ]["inline" ] = [create_metadata_from_config_dict (idp_conf )]
170
170
# instantiate new backend, without any discovery service configured
171
171
samlbackend = SAMLBackend (None , INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf }, "base_url" , "saml_backend" )
172
172
173
173
resp = samlbackend .start_auth (context , InternalData ())
174
174
assert_redirect_to_idp (resp , idp_conf )
175
175
176
- def test_authn_request (self , context , idp_conf ):
176
+ def test_authn_request (self , context , idp_conf , ** kwargs ):
177
177
resp = self .samlbackend .authn_request (context , idp_conf ["entityid" ])
178
178
assert_redirect_to_idp (resp , idp_conf )
179
179
req_params = dict (parse_qsl (urlparse (resp .message ).query ))
180
180
assert context .state [self .samlbackend .name ]["relay_state" ] == req_params ["RelayState" ]
181
181
182
- def test_authn_response (self , context , idp_conf , sp_conf ):
182
+ def test_authn_response (self , context , idp_conf , sp_conf , ** kwargs ):
183
183
response_binding = BINDING_HTTP_REDIRECT
184
184
fakesp = FakeSP (SPConfig ().load (sp_conf , metadata_construction = False ))
185
185
fakeidp = FakeIdP (USERS , config = IdPConfig ().load (idp_conf , metadata_construction = False ))
@@ -199,7 +199,7 @@ def test_authn_response(self, context, idp_conf, sp_conf):
199
199
@pytest .mark .skipif (
200
200
saml2 .__version__ < '4.6.1' ,
201
201
reason = "Optional NameID needs pysaml2 v4.6.1 or higher" )
202
- def test_authn_response_no_name_id (self , context , idp_conf , sp_conf ):
202
+ def test_authn_response_no_name_id (self , context , idp_conf , sp_conf , ** kwargs ):
203
203
response_binding = BINDING_HTTP_REDIRECT
204
204
205
205
fakesp_conf = SPConfig ().load (sp_conf , metadata_construction = False )
@@ -232,7 +232,7 @@ def test_authn_response_no_name_id(self, context, idp_conf, sp_conf):
232
232
assert_authn_response (internal_resp )
233
233
assert backend .name not in context .state
234
234
235
- def test_authn_response_with_encrypted_assertion (self , sp_conf , context ):
235
+ def test_authn_response_with_encrypted_assertion (self , sp_conf , context , ** kwargs ):
236
236
with open (os .path .join (
237
237
TEST_RESOURCE_BASE_PATH ,
238
238
"idp_metadata_for_encrypted_signed_auth_response.xml"
@@ -277,28 +277,28 @@ def test_authn_response_with_encrypted_assertion(self, sp_conf, context):
277
277
context , internal_resp = samlbackend .auth_callback_func .call_args [0 ]
278
278
assert Counter (internal_resp .attributes .keys ()) == Counter ({"mail" , "givenname" , "displayname" , "surname" })
279
279
280
- def test_backend_reads_encryption_key_from_key_file (self , sp_conf ):
280
+ def test_backend_reads_encryption_key_from_key_file (self , sp_conf , ** kwargs ):
281
281
sp_conf ["key_file" ] = os .path .join (TEST_RESOURCE_BASE_PATH , "encryption_key.pem" )
282
282
samlbackend = SAMLBackend (Mock (), INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf ,
283
283
"disco_srv" : DISCOSRV_URL },
284
284
"base_url" , "samlbackend" )
285
285
assert samlbackend .encryption_keys
286
286
287
- def test_backend_reads_encryption_key_from_encryption_keypair (self , sp_conf ):
287
+ def test_backend_reads_encryption_key_from_encryption_keypair (self , sp_conf , ** kwargs ):
288
288
del sp_conf ["key_file" ]
289
289
sp_conf ["encryption_keypairs" ] = [{"key_file" : os .path .join (TEST_RESOURCE_BASE_PATH , "encryption_key.pem" )}]
290
290
samlbackend = SAMLBackend (Mock (), INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf ,
291
291
"disco_srv" : DISCOSRV_URL },
292
292
"base_url" , "samlbackend" )
293
293
assert samlbackend .encryption_keys
294
294
295
- def test_metadata_endpoint (self , context , sp_conf ):
295
+ def test_metadata_endpoint (self , context , sp_conf , ** kwargs ):
296
296
resp = self .samlbackend ._metadata_endpoint (context )
297
297
headers = dict (resp .headers )
298
298
assert headers ["Content-Type" ] == "text/xml"
299
299
assert sp_conf ["entityid" ] in resp .message
300
300
301
- def test_get_metadata_desc (self , sp_conf , idp_conf ):
301
+ def test_get_metadata_desc (self , sp_conf , idp_conf , ** kwargs ):
302
302
sp_conf ["metadata" ]["inline" ] = [create_metadata_from_config_dict (idp_conf )]
303
303
# instantiate new backend, with a single backing IdP
304
304
samlbackend = SAMLBackend (None , INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf }, "base_url" , "saml_backend" )
@@ -321,7 +321,7 @@ def test_get_metadata_desc(self, sp_conf, idp_conf):
321
321
assert ui_info ["description" ] == expected_ui_info ["description" ]
322
322
assert ui_info ["logo" ] == expected_ui_info ["logo" ]
323
323
324
- def test_get_metadata_desc_with_logo_without_lang (self , sp_conf , idp_conf ):
324
+ def test_get_metadata_desc_with_logo_without_lang (self , sp_conf , idp_conf , ** kwargs ):
325
325
# add logo without 'lang'
326
326
idp_conf ["service" ]["idp" ]["ui_info" ]["logo" ] = [{"text" : "https://idp.example.com/static/logo.png" ,
327
327
"width" : "120" , "height" : "60" }]
@@ -351,8 +351,7 @@ def test_get_metadata_desc_with_logo_without_lang(self, sp_conf, idp_conf):
351
351
352
352
class TestSAMLBackendRedirects :
353
353
def test_default_redirect_to_discovery_service_if_using_mdq (
354
- self , context , sp_conf , idp_conf
355
- ):
354
+ self , context , sp_conf , idp_conf , ** kwargs ):
356
355
# one IdP in the metadata, but MDQ also configured so should always redirect to the discovery service
357
356
sp_conf ["metadata" ]["inline" ] = [create_metadata_from_config_dict (idp_conf )]
358
357
sp_conf ["metadata" ]["mdq" ] = ["https://mdq.example.com" ]
@@ -362,8 +361,7 @@ def test_default_redirect_to_discovery_service_if_using_mdq(
362
361
assert_redirect_to_discovery_server (resp , sp_conf , DISCOSRV_URL )
363
362
364
363
def test_use_of_disco_or_redirect_to_idp_when_using_mdq_and_forceauthn_is_not_set (
365
- self , context , sp_conf , idp_conf
366
- ):
364
+ self , context , sp_conf , idp_conf , ** kwargs ):
367
365
sp_conf ["metadata" ]["inline" ] = [create_metadata_from_config_dict (idp_conf )]
368
366
sp_conf ["metadata" ]["mdq" ] = ["https://mdq.example.com" ]
369
367
@@ -402,8 +400,7 @@ def test_use_of_disco_or_redirect_to_idp_when_using_mdq_and_forceauthn_is_not_se
402
400
assert_redirect_to_discovery_server (resp , sp_conf , DISCOSRV_URL )
403
401
404
402
def test_use_of_disco_or_redirect_to_idp_when_using_mdq_and_forceauthn_is_set_true (
405
- self , context , sp_conf , idp_conf
406
- ):
403
+ self , context , sp_conf , idp_conf , ** kwargs ):
407
404
sp_conf ["metadata" ]["inline" ] = [create_metadata_from_config_dict (idp_conf )]
408
405
sp_conf ["metadata" ]["mdq" ] = ["https://mdq.example.com" ]
409
406
@@ -430,8 +427,7 @@ def test_use_of_disco_or_redirect_to_idp_when_using_mdq_and_forceauthn_is_set_tr
430
427
assert_redirect_to_idp (resp , idp_conf )
431
428
432
429
def test_use_of_disco_or_redirect_to_idp_when_using_mdq_and_forceauthn_is_set_1 (
433
- self , context , sp_conf , idp_conf
434
- ):
430
+ self , context , sp_conf , idp_conf , ** kwargs ):
435
431
sp_conf ["metadata" ]["inline" ] = [create_metadata_from_config_dict (idp_conf )]
436
432
sp_conf ["metadata" ]["mdq" ] = ["https://mdq.example.com" ]
437
433
0 commit comments