Skip to content

Commit

Permalink
[18.0][MIG] auth_saml: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BT-dlagin committed Jan 14, 2025
1 parent d8560a2 commit 0c707e2
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions auth_saml/tests/test_pysaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,35 @@ def test_saml_metadata_missing_parameters(self):
response = self.url_open("/auth_saml/metadata")
self.assertEqual(response.status_code, 404)
self.assertIn("Missing parameters", response.text)

def test_saml_provider_deactivation(self):
"""A deactivated SAML provider should not be usable for authentication."""
self.saml_provider.active = False

redirect_url = self.saml_provider._get_auth_request()
response = self.idp.fake_login(redirect_url)
unpacked_response = response._unpack()

with self.assertRaises(AccessDenied):
self.env["res.users"].sudo().auth_saml(
self.saml_provider.id, unpacked_response.get("SAMLResponse"), None
)

def test_compute_sp_metadata_url_for_new_record(self):
"""Test that sp_metadata_url is set to False for a new (unsaved) provider."""
new_provider = self.env["auth.saml.provider"].new(
{"name": "New SAML Provider", "sp_baseurl": "http://example.com"}
)
new_provider._compute_sp_metadata_url()
self.assertFalse(new_provider.sp_metadata_url)

def test_store_outstanding_request(self):
"""Test that the SAML request ID is stored in the auth_saml.request model."""
reqid = "test-request-id"
self.saml_provider._store_outstanding_request(reqid)

request = self.env["auth_saml.request"].search(
[("saml_request_id", "=", reqid)]
)
self.assertTrue(request)
self.assertEqual(request.saml_provider_id.id, self.saml_provider.id)

0 comments on commit 0c707e2

Please sign in to comment.