Skip to content

Commit

Permalink
fixup improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
dutrieuc committed Dec 18, 2024
1 parent c648037 commit ed616d7
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions auth_saml/tests/test_pysaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,43 @@ def test_download_metadata(self):
self.saml_provider.action_refresh_metadata_from_url()
self.assertEqual(self.saml_provider.idp_metadata, expected_metadata)

@responses.activate
def test_download_metadata_no_provider(self):
self.saml_provider.idp_metadata_url = "http://localhost:8000/metadata"
self.saml_provider.idp_metadata = ""
self.saml_provider.active = False
self.saml_provider.action_refresh_metadata_from_url()
self.assertFalse(self.saml_provider.idp_metadata)

@responses.activate
def test_download_metadata_error(self):
responses.add(
responses.GET,
"http://localhost:8000/metadata",
status=500,
content_type="text/xml",
)
self.saml_provider.idp_metadata_url = "http://localhost:8000/metadata"
self.saml_provider.idp_metadata = ""
with self.assertRaises(UserError):
self.saml_provider.action_refresh_metadata_from_url()
self.assertFalse(self.saml_provider.idp_metadata)

@responses.activate
def test_download_metadata_no_update(self):
expected_metadata = self.idp.get_metadata()
responses.add(
responses.GET,
"http://localhost:8000/metadata",
status=200,
content_type="text/xml",
body=expected_metadata,
)
self.saml_provider.idp_metadata_url = "http://localhost:8000/metadata"
self.saml_provider.idp_metadata = expected_metadata
self.saml_provider.action_refresh_metadata_from_url()
self.assertEqual(self.saml_provider.idp_metadata, expected_metadata)

@responses.activate
def test_login_with_saml_metadata_empty(self):
self.saml_provider.idp_metadata_url = "http://localhost:8000/metadata"
Expand Down

0 comments on commit ed616d7

Please sign in to comment.