Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add basic SAML tests for mapping users. #8800

Merged
merged 13 commits into from
Dec 2, 2020
Prev Previous commit
Next Next commit
Remove some bits of the tests that were copied from OIDC.
clokep committed Nov 30, 2020
commit bb06478cbe12ed085a884f1e9784ffe32ab13214
15 changes: 3 additions & 12 deletions tests/handlers/test_saml.py
Original file line number Diff line number Diff line change
@@ -89,21 +89,12 @@ def test_map_saml_response_to_user(self):
)
self.assertEqual(mxid, "@test_user:test")

# Some providers return an integer ID.
saml_response = FakeAuthnResponse({"uid": 1234, "username": "test_user_2"})
mxid = self.get_success(
self.handler._map_saml_response_to_user(
saml_response, redirect_url, "user-agent", "10.10.10.10"
)
)
self.assertEqual(mxid, "@test_user_2:test")

# Test if the mxid is already taken
store = self.hs.get_datastore()
self.get_success(
store.register_user(user_id="@test_user_3:test", password_hash=None)
store.register_user(user_id="@test_user_2:test", password_hash=None)
)
saml_response = FakeAuthnResponse({"uid": "test3", "username": "test_user_3"})
saml_response = FakeAuthnResponse({"uid": "test2", "username": "test_user_2"})
e = self.get_failure(
self.handler._map_saml_response_to_user(
saml_response, redirect_url, "user-agent", "10.10.10.10"
@@ -116,7 +107,7 @@ def test_map_saml_response_to_user(self):

def test_map_saml_response_to_invalid_localpart(self):
"""If the mapping provider generates an invalid localpart it should be rejected."""
saml_response = FakeAuthnResponse({"uid": "test2", "username": "föö"})
saml_response = FakeAuthnResponse({"uid": "test", "username": "föö"})
redirect_url = ""
e = self.get_failure(
self.handler._map_saml_response_to_user(