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

Commit

Permalink
Add test that ensures new users are not registered if the enabled reg…
Browse files Browse the repository at this point in the history
…istration flag is disabled
  • Loading branch information
agrimpard authored Sep 6, 2023
1 parent 46cd6aa commit c42c8f6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/handlers/test_cas.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,29 @@ def test_required_attributes(self) -> None:
auth_provider_session_id=None,
)

@override_config(
{
"cas_config": {
"enable_registration": False
}
}
)
def test_map_cas_user_does_not_register_new_user(self) -> None:
"""Ensures new users are not registered if the enabled registration flag is disabled."""

auth_handler = self.hs.get_auth_handler()
auth_handler.complete_sso_login = AsyncMock() # type: ignore[method-assign]
cas_response = CasResponse("test_user", {})
request = _mock_request()
self.get_success(
self.handler._handle_cas_response(request, cas_response, "redirect_uri", "")
)
self.complete_sso_login.assert_not_called()
self.assertRenderedError(
"mapping_error",
"User does not exist and registrations are disabled",
)


def _mock_request() -> Mock:
"""Returns a mock which will stand in as a SynapseRequest"""
Expand Down

0 comments on commit c42c8f6

Please sign in to comment.