summary refs log tree commit diff
path: root/tests/rest/admin
diff options
context:
space:
mode:
authorThomas Weston <thomasweston12@gmail.com>2022-07-13 11:33:21 +0100
committerGitHub <noreply@github.com>2022-07-13 11:33:21 +0100
commit0312ff44c69ba16371206fc42b9f886b24253bcd (patch)
treeb5d5cfdec89e3313273a9a0f2ec2b11aa560b36c /tests/rest/admin
parentInline URL preview documentation. (#13261) (diff)
downloadsynapse-0312ff44c69ba16371206fc42b9f886b24253bcd.tar.xz
Fix "add user" admin api error when request contains a "msisdn" threepid (#13263)
Co-authored-by: Thomas Weston <thomas.weston@clearspancloud.com>
Co-authored-by: David Robertson <david.m.robertson1@gmail.com>
Diffstat (limited to 'tests/rest/admin')
-rw-r--r--tests/rest/admin/test_user.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/rest/admin/test_user.py b/tests/rest/admin/test_user.py
index e32aaadb98..97693cd1e2 100644
--- a/tests/rest/admin/test_user.py
+++ b/tests/rest/admin/test_user.py
@@ -1636,6 +1636,41 @@ class UserRestTestCase(unittest.HomeserverTestCase):
         )
         self.assertEqual(len(pushers), 0)
 
+    @override_config(
+        {
+            "email": {
+                "enable_notifs": True,
+                "notif_for_new_users": True,
+                "notif_from": "test@example.com",
+            },
+            "public_baseurl": "https://example.com",
+        }
+    )
+    def test_create_user_email_notif_for_new_users_with_msisdn_threepid(self) -> None:
+        """
+        Check that a new regular user is created successfully when they have a msisdn
+        threepid and email notif_for_new_users is set to True.
+        """
+        url = self.url_prefix % "@bob:test"
+
+        # Create user
+        body = {
+            "password": "abc123",
+            "threepids": [{"medium": "msisdn", "address": "1234567890"}],
+        }
+
+        channel = self.make_request(
+            "PUT",
+            url,
+            access_token=self.admin_user_tok,
+            content=body,
+        )
+
+        self.assertEqual(201, channel.code, msg=channel.json_body)
+        self.assertEqual("@bob:test", channel.json_body["name"])
+        self.assertEqual("msisdn", channel.json_body["threepids"][0]["medium"])
+        self.assertEqual("1234567890", channel.json_body["threepids"][0]["address"])
+
     def test_set_password(self) -> None:
         """
         Test setting a new password for another user.