diff --git a/tests/saml/metadata/federations/test_loader.py b/tests/saml/metadata/federations/test_loader.py index c4b794c92..05502cf1a 100644 --- a/tests/saml/metadata/federations/test_loader.py +++ b/tests/saml/metadata/federations/test_loader.py @@ -1,4 +1,5 @@ import pytest +import requests_mock from mock import MagicMock, create_autospec, patch from api.saml.metadata.federations import incommon @@ -28,13 +29,15 @@ def test_load_idp_metadata_raises_error_when_xml_is_incorrect(self, urlopen_mock metadata_loader.load_idp_metadata(url) @patch("urllib.request.urlopen") - def test_load_idp_metadata_correctly_loads_one_descriptor(self, urlopen_mock): + @patch("urllib.request.Request") + def test_load_idp_metadata_correctly_loads_one_descriptor(self, request_mock, urlopen_mock): # Arrange url = "http://md.incommon.org/InCommon/metadata.xml" incorrect_xml = fixtures.CORRECT_XML_WITH_IDP_1 urlopen_response_mock = MagicMock() urlopen_response_mock.read = MagicMock(return_value=incorrect_xml) urlopen_mock.return_value = urlopen_response_mock + request_mock.return_value = url metadata_loader = SAMLMetadataLoader() # Act @@ -45,13 +48,15 @@ def test_load_idp_metadata_correctly_loads_one_descriptor(self, urlopen_mock): assert fixtures.CORRECT_XML_WITH_IDP_1 == xml_metadata @patch("urllib.request.urlopen") - def test_load_idp_metadata_correctly_loads_multiple_descriptors(self, urlopen_mock): + @patch("urllib.request.Request") + def test_load_idp_metadata_correctly_loads_multiple_descriptors(self, request_mock, urlopen_mock): # Arrange url = "http://md.incommon.org/InCommon/metadata.xml" incorrect_xml = fixtures.CORRECT_XML_WITH_MULTIPLE_IDPS urlopen_response_mock = MagicMock() urlopen_response_mock.read = MagicMock(return_value=incorrect_xml) urlopen_mock.return_value = urlopen_response_mock + request_mock.return_value = url metadata_loader = SAMLMetadataLoader() # Act diff --git a/tests/saml/test_provider.py b/tests/saml/test_provider.py index 837b11f9a..b07700b3e 100644 --- a/tests/saml/test_provider.py +++ b/tests/saml/test_provider.py @@ -137,7 +137,7 @@ def setup_method(self, _db=None, set_up_circulation_manager=True): "links": [ { "rel": "authenticate", - "href": "http://localhost/default/saml_authenticate?provider=SAML+2.0+Web+SSO&idp_entity_id=http%3A%2F%2Fidp2.hilbertteam.net%2Fidp%2Fshibboleth", + "href": "http://localhost/default/saml_authenticate?provider=SAML+2.0+Web+SSO&idp_entity_id=http://idp2.hilbertteam.net/idp/shibboleth", "display_names": [ { "value": fixtures.IDP_1_UI_INFO_EN_DISPLAY_NAME, @@ -201,7 +201,7 @@ def setup_method(self, _db=None, set_up_circulation_manager=True): "links": [ { "rel": "authenticate", - "href": "http://localhost/default/saml_authenticate?provider=SAML+2.0+Web+SSO&idp_entity_id=http%3A%2F%2Fidp2.hilbertteam.net%2Fidp%2Fshibboleth", + "href": "http://localhost/default/saml_authenticate?provider=SAML+2.0+Web+SSO&idp_entity_id=http://idp2.hilbertteam.net/idp/shibboleth", "display_names": [ { "value": fixtures.IDP_1_ORGANIZATION_EN_ORGANIZATION_DISPLAY_NAME, @@ -232,7 +232,7 @@ def setup_method(self, _db=None, set_up_circulation_manager=True): "links": [ { "rel": "authenticate", - "href": "http://localhost/default/saml_authenticate?provider=SAML+2.0+Web+SSO&idp_entity_id=http%3A%2F%2Fidp1.hilbertteam.net%2Fidp%2Fshibboleth", + "href": "http://localhost/default/saml_authenticate?provider=SAML+2.0+Web+SSO&idp_entity_id=http://idp1.hilbertteam.net/idp/shibboleth", "display_names": [ { "value": SAMLConfiguration.IDP_DISPLAY_NAME_DEFAULT_TEMPLATE.format( @@ -248,7 +248,7 @@ def setup_method(self, _db=None, set_up_circulation_manager=True): }, { "rel": "authenticate", - "href": "http://localhost/default/saml_authenticate?provider=SAML+2.0+Web+SSO&idp_entity_id=http%3A%2F%2Fidp1.hilbertteam.net%2Fidp%2Fshibboleth", + "href": "http://localhost/default/saml_authenticate?provider=SAML+2.0+Web+SSO&idp_entity_id=http://idp1.hilbertteam.net/idp/shibboleth", "display_names": [ { "value": SAMLConfiguration.IDP_DISPLAY_NAME_DEFAULT_TEMPLATE.format(