summary refs log tree commit diff
path: root/tests/handlers/test_password_providers.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/handlers/test_password_providers.py71
1 files changed, 0 insertions, 71 deletions
diff --git a/tests/handlers/test_password_providers.py b/tests/handlers/test_password_providers.py

index ed203eb299..d0351a8509 100644 --- a/tests/handlers/test_password_providers.py +++ b/tests/handlers/test_password_providers.py
@@ -768,17 +768,6 @@ class PasswordAuthProviderTests(unittest.HomeserverTestCase): # Check that the callback has been called. m.assert_called_once() - # Set some email configuration so the test doesn't fail because of its absence. - @override_config({"email": {"notif_from": "noreply@test"}}) - def test_3pid_allowed(self) -> None: - """Tests that an is_3pid_allowed_callbacks forbidding a 3PID makes Synapse refuse - to bind the new 3PID, and that one allowing a 3PID makes Synapse accept to bind - the 3PID. Also checks that the module is passed a boolean indicating whether the - user to bind this 3PID to is currently registering. - """ - self._test_3pid_allowed("rin", False) - self._test_3pid_allowed("kitay", True) - def test_displayname(self) -> None: """Tests that the get_displayname_for_registration callback can define the display name of a user when registering. @@ -829,66 +818,6 @@ class PasswordAuthProviderTests(unittest.HomeserverTestCase): # Check that the callback has been called. m.assert_called_once() - def _test_3pid_allowed(self, username: str, registration: bool) -> None: - """Tests that the "is_3pid_allowed" module callback is called correctly, using - either /register or /account URLs depending on the arguments. - - Args: - username: The username to use for the test. - registration: Whether to test with registration URLs. - """ - self.hs.get_identity_handler().send_threepid_validation = AsyncMock( # type: ignore[method-assign] - return_value=0 - ) - - m = AsyncMock(return_value=False) - self.hs.get_password_auth_provider().is_3pid_allowed_callbacks = [m] - - self.register_user(username, "password") - tok = self.login(username, "password") - - if registration: - url = "/register/email/requestToken" - else: - url = "/account/3pid/email/requestToken" - - channel = self.make_request( - "POST", - url, - { - "client_secret": "foo", - "email": "foo@test.com", - "send_attempt": 0, - }, - access_token=tok, - ) - self.assertEqual(channel.code, HTTPStatus.FORBIDDEN, channel.result) - self.assertEqual( - channel.json_body["errcode"], - Codes.THREEPID_DENIED, - channel.json_body, - ) - - m.assert_called_once_with("email", "foo@test.com", registration) - - m = AsyncMock(return_value=True) - self.hs.get_password_auth_provider().is_3pid_allowed_callbacks = [m] - - channel = self.make_request( - "POST", - url, - { - "client_secret": "foo", - "email": "bar@test.com", - "send_attempt": 0, - }, - access_token=tok, - ) - self.assertEqual(channel.code, HTTPStatus.OK, channel.result) - self.assertIn("sid", channel.json_body) - - m.assert_called_once_with("email", "bar@test.com", registration) - def _setup_get_name_for_registration(self, callback_name: str) -> Mock: """Registers either a get_username_for_registration callback or a get_displayname_for_registration callback that appends "-foo" to the username the