@@ -50,20 +50,21 @@ def test_register_endpoints(self, sp_conf):
5050 """
5151 Tests the method register_endpoints
5252 """
53+ def get_path_from_url (url ):
54+ return urlparse (url ).path .lstrip ("/" )
55+ metadata_url = "http://example.com/SAML2IDP/metadata"
5356 samlbackend = SamlBackend (None , INTERNAL_ATTRIBUTES , {"config" : sp_conf ,
5457 "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 })
5660
5761 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 )
6768
6869 def test_start_auth_no_request_info (self , sp_conf ):
6970 """
0 commit comments