@@ -50,20 +50,21 @@ def test_register_endpoints(self, sp_conf):
50
50
"""
51
51
Tests the method register_endpoints
52
52
"""
53
+ def get_path_from_url (url ):
54
+ return urlparse (url ).path .lstrip ("/" )
55
+ metadata_url = "http://example.com/SAML2IDP/metadata"
53
56
samlbackend = SamlBackend (None , INTERNAL_ATTRIBUTES , {"config" : sp_conf ,
54
57
"disco_srv" : "https://my.dicso.com/role/idp.ds" ,
55
- "state_id" : "saml_backend_test_id" })
58
+ "state_id" : "saml_backend_test_id" ,
59
+ "publish_metadata" : metadata_url })
56
60
57
61
url_map = samlbackend .register_endpoints ()
58
- for k , v in sp_conf ["service" ]["sp" ]["endpoints" ].items ():
59
- for endp in v :
60
- match = False
61
- for regex in url_map :
62
- p = re .compile (regex [0 ])
63
- if p .match (urlparse (endp [0 ]).path .lstrip ("/" )):
64
- match = True
65
- break
66
- assert match , "Not correct regular expression for endpoint: %s" % endp [0 ]
62
+ all_sp_endpoints = [get_path_from_url (v [0 ][0 ])for v in sp_conf ["service" ]["sp" ]["endpoints" ].values ()]
63
+ compiled_regex = [re .compile (regex ) for regex , _ in url_map ]
64
+ for endp in all_sp_endpoints :
65
+ assert any (p .match (endp ) for p in compiled_regex )
66
+
67
+ assert any (p .match (get_path_from_url (metadata_url )) for p in compiled_regex )
67
68
68
69
def test_start_auth_no_request_info (self , sp_conf ):
69
70
"""
0 commit comments