@@ -84,7 +84,7 @@ class TestSAMLBackend:
84
84
@pytest .fixture (autouse = True )
85
85
def create_backend (self , sp_conf , idp_conf ):
86
86
setup_test_config (sp_conf , idp_conf )
87
- self .samlbackend = SAMLBackend (Mock (), INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf ,
87
+ self .samlbackend = SAMLBackend (Mock (), Mock (), INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf ,
88
88
"disco_srv" : DISCOSRV_URL },
89
89
"base_url" ,
90
90
"samlbackend" )
@@ -168,7 +168,7 @@ def test_start_auth_redirects_directly_to_mirrored_idp(
168
168
def test_redirect_to_idp_if_only_one_idp_in_metadata (self , context , sp_conf , idp_conf ):
169
169
sp_conf ["metadata" ]["inline" ] = [create_metadata_from_config_dict (idp_conf )]
170
170
# instantiate new backend, without any discovery service configured
171
- samlbackend = SAMLBackend (None , INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf }, "base_url" , "saml_backend" )
171
+ samlbackend = SAMLBackend (None , 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 )
@@ -241,6 +241,7 @@ def test_authn_response_with_encrypted_assertion(self, sp_conf, context):
241
241
242
242
sp_conf ["entityid" ] = "https://federation-dev-1.scienceforum.sc/Saml2/proxy_saml2_backend.xml"
243
243
samlbackend = SAMLBackend (
244
+ Mock (),
244
245
Mock (),
245
246
INTERNAL_ATTRIBUTES ,
246
247
{"sp_config" : sp_conf , "disco_srv" : DISCOSRV_URL },
@@ -279,15 +280,15 @@ def test_authn_response_with_encrypted_assertion(self, sp_conf, context):
279
280
280
281
def test_backend_reads_encryption_key_from_key_file (self , sp_conf ):
281
282
sp_conf ["key_file" ] = os .path .join (TEST_RESOURCE_BASE_PATH , "encryption_key.pem" )
282
- samlbackend = SAMLBackend (Mock (), INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf ,
283
+ samlbackend = SAMLBackend (Mock (), Mock (), INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf ,
283
284
"disco_srv" : DISCOSRV_URL },
284
285
"base_url" , "samlbackend" )
285
286
assert samlbackend .encryption_keys
286
287
287
288
def test_backend_reads_encryption_key_from_encryption_keypair (self , sp_conf ):
288
289
del sp_conf ["key_file" ]
289
290
sp_conf ["encryption_keypairs" ] = [{"key_file" : os .path .join (TEST_RESOURCE_BASE_PATH , "encryption_key.pem" )}]
290
- samlbackend = SAMLBackend (Mock (), INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf ,
291
+ samlbackend = SAMLBackend (Mock (), Mock (), INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf ,
291
292
"disco_srv" : DISCOSRV_URL },
292
293
"base_url" , "samlbackend" )
293
294
assert samlbackend .encryption_keys
@@ -301,7 +302,7 @@ def test_metadata_endpoint(self, context, sp_conf):
301
302
def test_get_metadata_desc (self , sp_conf , idp_conf ):
302
303
sp_conf ["metadata" ]["inline" ] = [create_metadata_from_config_dict (idp_conf )]
303
304
# instantiate new backend, with a single backing IdP
304
- samlbackend = SAMLBackend (None , INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf }, "base_url" , "saml_backend" )
305
+ samlbackend = SAMLBackend (None , None , INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf }, "base_url" , "saml_backend" )
305
306
entity_descriptions = samlbackend .get_metadata_desc ()
306
307
307
308
assert len (entity_descriptions ) == 1
@@ -328,7 +329,7 @@ def test_get_metadata_desc_with_logo_without_lang(self, sp_conf, idp_conf):
328
329
329
330
sp_conf ["metadata" ]["inline" ] = [create_metadata_from_config_dict (idp_conf )]
330
331
# instantiate new backend, with a single backing IdP
331
- samlbackend = SAMLBackend (None , INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf }, "base_url" , "saml_backend" )
332
+ samlbackend = SAMLBackend (None , None , INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf }, "base_url" , "saml_backend" )
332
333
entity_descriptions = samlbackend .get_metadata_desc ()
333
334
334
335
assert len (entity_descriptions ) == 1
@@ -356,7 +357,7 @@ def test_default_redirect_to_discovery_service_if_using_mdq(
356
357
# one IdP in the metadata, but MDQ also configured so should always redirect to the discovery service
357
358
sp_conf ["metadata" ]["inline" ] = [create_metadata_from_config_dict (idp_conf )]
358
359
sp_conf ["metadata" ]["mdq" ] = ["https://mdq.example.com" ]
359
- samlbackend = SAMLBackend (None , INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf , "disco_srv" : DISCOSRV_URL ,},
360
+ samlbackend = SAMLBackend (None , None , INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf , "disco_srv" : DISCOSRV_URL ,},
360
361
"base_url" , "saml_backend" )
361
362
resp = samlbackend .start_auth (context , InternalData ())
362
363
assert_redirect_to_discovery_server (resp , sp_conf , DISCOSRV_URL )
@@ -373,21 +374,21 @@ def test_use_of_disco_or_redirect_to_idp_when_using_mdq_and_forceauthn_is_not_se
373
374
SAMLBackend .KEY_MEMORIZE_IDP : True ,
374
375
}
375
376
samlbackend = SAMLBackend (
376
- None , INTERNAL_ATTRIBUTES , backend_conf , "base_url" , "saml_backend"
377
+ None , None , INTERNAL_ATTRIBUTES , backend_conf , "base_url" , "saml_backend"
377
378
)
378
379
resp = samlbackend .start_auth (context , InternalData ())
379
380
assert_redirect_to_discovery_server (resp , sp_conf , DISCOSRV_URL )
380
381
381
382
context .state [Context .KEY_MEMORIZED_IDP ] = idp_conf ["entityid" ]
382
383
samlbackend = SAMLBackend (
383
- None , INTERNAL_ATTRIBUTES , backend_conf , "base_url" , "saml_backend"
384
+ None , None , INTERNAL_ATTRIBUTES , backend_conf , "base_url" , "saml_backend"
384
385
)
385
386
resp = samlbackend .start_auth (context , InternalData ())
386
387
assert_redirect_to_idp (resp , idp_conf )
387
388
388
389
backend_conf [SAMLBackend .KEY_MEMORIZE_IDP ] = False
389
390
samlbackend = SAMLBackend (
390
- None , INTERNAL_ATTRIBUTES , backend_conf , "base_url" , "saml_backend"
391
+ None , None , INTERNAL_ATTRIBUTES , backend_conf , "base_url" , "saml_backend"
391
392
)
392
393
resp = samlbackend .start_auth (context , InternalData ())
393
394
assert_redirect_to_discovery_server (resp , sp_conf , DISCOSRV_URL )
@@ -396,7 +397,7 @@ def test_use_of_disco_or_redirect_to_idp_when_using_mdq_and_forceauthn_is_not_se
396
397
context .state [Context .KEY_MEMORIZED_IDP ] = idp_conf ["entityid" ]
397
398
backend_conf [SAMLBackend .KEY_USE_MEMORIZED_IDP_WHEN_FORCE_AUTHN ] = True
398
399
samlbackend = SAMLBackend (
399
- None , INTERNAL_ATTRIBUTES , backend_conf , "base_url" , "saml_backend"
400
+ None , None , INTERNAL_ATTRIBUTES , backend_conf , "base_url" , "saml_backend"
400
401
)
401
402
resp = samlbackend .start_auth (context , InternalData ())
402
403
assert_redirect_to_discovery_server (resp , sp_conf , DISCOSRV_URL )
@@ -417,14 +418,14 @@ def test_use_of_disco_or_redirect_to_idp_when_using_mdq_and_forceauthn_is_set_tr
417
418
SAMLBackend .KEY_MIRROR_FORCE_AUTHN : True ,
418
419
}
419
420
samlbackend = SAMLBackend (
420
- None , INTERNAL_ATTRIBUTES , backend_conf , "base_url" , "saml_backend"
421
+ None , None , INTERNAL_ATTRIBUTES , backend_conf , "base_url" , "saml_backend"
421
422
)
422
423
resp = samlbackend .start_auth (context , InternalData ())
423
424
assert_redirect_to_discovery_server (resp , sp_conf , DISCOSRV_URL )
424
425
425
426
backend_conf [SAMLBackend .KEY_USE_MEMORIZED_IDP_WHEN_FORCE_AUTHN ] = True
426
427
samlbackend = SAMLBackend (
427
- None , INTERNAL_ATTRIBUTES , backend_conf , "base_url" , "saml_backend"
428
+ None , None , INTERNAL_ATTRIBUTES , backend_conf , "base_url" , "saml_backend"
428
429
)
429
430
resp = samlbackend .start_auth (context , InternalData ())
430
431
assert_redirect_to_idp (resp , idp_conf )
@@ -445,14 +446,14 @@ def test_use_of_disco_or_redirect_to_idp_when_using_mdq_and_forceauthn_is_set_1(
445
446
SAMLBackend .KEY_MIRROR_FORCE_AUTHN : True ,
446
447
}
447
448
samlbackend = SAMLBackend (
448
- None , INTERNAL_ATTRIBUTES , backend_conf , "base_url" , "saml_backend"
449
+ None , None , INTERNAL_ATTRIBUTES , backend_conf , "base_url" , "saml_backend"
449
450
)
450
451
resp = samlbackend .start_auth (context , InternalData ())
451
452
assert_redirect_to_discovery_server (resp , sp_conf , DISCOSRV_URL )
452
453
453
454
backend_conf [SAMLBackend .KEY_USE_MEMORIZED_IDP_WHEN_FORCE_AUTHN ] = True
454
455
samlbackend = SAMLBackend (
455
- None , INTERNAL_ATTRIBUTES , backend_conf , "base_url" , "saml_backend"
456
+ None , None , INTERNAL_ATTRIBUTES , backend_conf , "base_url" , "saml_backend"
456
457
)
457
458
resp = samlbackend .start_auth (context , InternalData ())
458
459
assert_redirect_to_idp (resp , idp_conf )
0 commit comments