77from unittest .mock import Mock
88from unittest .mock import patch
99
10+ from pytest import raises
11+
1012import responses
1113
1214from six .moves .urllib import parse
1921from saml2 .mdstore import name
2022from saml2 import sigver
2123from saml2 .httpbase import HTTPBase
24+ from saml2 import SAMLError
2225from saml2 import BINDING_SOAP
2326from saml2 import BINDING_HTTP_REDIRECT
2427from saml2 import BINDING_HTTP_POST
156159 "class" : "saml2.mdstore.MetaDataFile" ,
157160 "metadata" : [(full_path ("swamid-2.0.xml" ),)],
158161 }],
162+ "14" : [{
163+ "class" : "saml2.mdstore.MetaDataFile" ,
164+ "metadata" : [(full_path ("invalid_metadata_file.xml" ),)],
165+ }],
159166}
160167
161168
@@ -170,6 +177,12 @@ def _fix_valid_until(xmlstring):
170177 xmlstring )
171178
172179
180+ def test_invalid_metadata ():
181+ mds = MetadataStore (ATTRCONV , sec_config , disable_ssl_certificate_validation = True )
182+ with raises (SAMLError ):
183+ mds .imp (METADATACONF ["14" ])
184+
185+
173186def test_swami_1 ():
174187 UMU_IDP = 'https://idp.umu.se/saml2/idp/metadata.php'
175188 mds = MetadataStore (ATTRCONV , sec_config ,
0 commit comments