def test_load_remote_encoding(): crypto = sigver._get_xmlsec_cryptobackend() sc = sigver.SecurityContext(crypto, key_type="", cert_type="") httpc = HTTPBase() mds = MetaDataExtern(ATTRCONV, 'http://metadata.aai.switch.ch/metadata.aaitest.xml', sc, full_path('SWITCHaaiRootCA.crt.pem'), httpc) mds.load()
def test_load_remote_encoding(mock_request): filepath = os.path.join(TESTS_DIR, "remote_data/metadata.aaitest.xml") with open(filepath) as fd: data = fd.read() mock_request.return_value.ok = True mock_request.return_value.status_code = 200 mock_request.return_value.content = data crypto = sigver._get_xmlsec_cryptobackend() sc = sigver.SecurityContext(crypto, key_type="", cert_type="") httpc = HTTPBase() mds = MetaDataExtern(ATTRCONV, 'http://metadata.aai.switch.ch/metadata.aaitest.xml', sc, full_path('SWITCHaaiRootCA.crt.pem'), httpc) mds.load()
def validate_metadata_url(url: str) -> bool: """Validates metadata URL Args: url (str): Metadata URL Returns: bool: Wether the metadata URL is valid or not """ try: http_client = HTTPBase() metadata = MetaDataExtern(None, url=url, http=http_client) metadata.load() except: return False return True