1
1
# -*- coding: utf-8 -*-
2
2
3
-
4
- try :
5
- from urllib .error import URLError
6
- except ImportError :
7
- from urllib2 import URLError
8
-
9
3
from copy import deepcopy
10
4
import json
11
5
from os .path import dirname , join , exists
12
6
from lxml .etree import XMLSyntaxError
7
+ from requests import RequestException
13
8
import unittest
14
9
15
10
from onelogin .saml2 .idp_metadata_parser import OneLogin_Saml2_IdPMetadataParser
@@ -51,7 +46,7 @@ def testGetMetadata(self):
51
46
try :
52
47
data = OneLogin_Saml2_IdPMetadataParser .get_metadata ("https://raw.githubusercontent.com/SAML-Toolkits/python3-saml/master/tests/data/metadata/testshib-providers.xml" , validate_cert = False )
53
48
self .assertTrue (data is not None and data is not {})
54
- except URLError :
49
+ except RequestException :
55
50
pass
56
51
57
52
def testGetMetadataWithHeaders (self ):
@@ -70,7 +65,7 @@ def testParseRemote(self):
70
65
71
66
try :
72
67
data = OneLogin_Saml2_IdPMetadataParser .parse_remote ("https://raw.githubusercontent.com/SAML-Toolkits/python3-saml/master/tests/data/metadata/testshib-providers.xml" , validate_cert = False )
73
- except URLError :
68
+ except RequestException :
74
69
xml = self .file_contents (join (self .data_path , "metadata" , "testshib-providers.xml" ))
75
70
data = OneLogin_Saml2_IdPMetadataParser .parse (xml )
76
71
@@ -162,7 +157,7 @@ def test_parse_testshib_required_binding_sso_redirect(self):
162
157
"""
163
158
try :
164
159
xmldoc = OneLogin_Saml2_IdPMetadataParser .get_metadata ("https://idp.testshib.org/idp/shibboleth" )
165
- except URLError :
160
+ except RequestException :
166
161
xmldoc = self .file_contents (join (self .data_path , "metadata" , "testshib-providers.xml" ))
167
162
168
163
# Parse, require SSO REDIRECT binding, implicitly.
@@ -196,7 +191,7 @@ def test_parse_testshib_required_binding_sso_post(self):
196
191
"""
197
192
try :
198
193
xmldoc = OneLogin_Saml2_IdPMetadataParser .get_metadata ("https://idp.testshib.org/idp/shibboleth" )
199
- except URLError :
194
+ except RequestException :
200
195
xmldoc = self .file_contents (join (self .data_path , "metadata" , "testshib-providers.xml" ))
201
196
202
197
# Parse, require POST binding.
0 commit comments