mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-05 12:24:58 -04:00
Remove not needed database updates in modify user admin API (#10627)
This commit is contained in:
parent
0c3565da4c
commit
220f901229
5 changed files with 118 additions and 33 deletions
|
@ -1431,12 +1431,14 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
self.assertEqual("Bob's name", channel.json_body["displayname"])
|
||||
self.assertEqual("email", channel.json_body["threepids"][0]["medium"])
|
||||
self.assertEqual("bob@bob.bob", channel.json_body["threepids"][0]["address"])
|
||||
self.assertEqual(1, len(channel.json_body["threepids"]))
|
||||
self.assertEqual(
|
||||
"external_id1", channel.json_body["external_ids"][0]["external_id"]
|
||||
)
|
||||
self.assertEqual(
|
||||
"auth_provider1", channel.json_body["external_ids"][0]["auth_provider"]
|
||||
)
|
||||
self.assertEqual(1, len(channel.json_body["external_ids"]))
|
||||
self.assertFalse(channel.json_body["admin"])
|
||||
self.assertEqual("mxc://fibble/wibble", channel.json_body["avatar_url"])
|
||||
self._check_fields(channel.json_body)
|
||||
|
@ -1676,18 +1678,53 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
Test setting threepid for an other user.
|
||||
"""
|
||||
|
||||
# Delete old and add new threepid to user
|
||||
# Add two threepids to user
|
||||
channel = self.make_request(
|
||||
"PUT",
|
||||
self.url_other_user,
|
||||
access_token=self.admin_user_tok,
|
||||
content={"threepids": [{"medium": "email", "address": "bob3@bob.bob"}]},
|
||||
content={
|
||||
"threepids": [
|
||||
{"medium": "email", "address": "bob1@bob.bob"},
|
||||
{"medium": "email", "address": "bob2@bob.bob"},
|
||||
],
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("@user:test", channel.json_body["name"])
|
||||
self.assertEqual(2, len(channel.json_body["threepids"]))
|
||||
# result does not always have the same sort order, therefore it becomes sorted
|
||||
sorted_result = sorted(
|
||||
channel.json_body["threepids"], key=lambda k: k["address"]
|
||||
)
|
||||
self.assertEqual("email", sorted_result[0]["medium"])
|
||||
self.assertEqual("bob1@bob.bob", sorted_result[0]["address"])
|
||||
self.assertEqual("email", sorted_result[1]["medium"])
|
||||
self.assertEqual("bob2@bob.bob", sorted_result[1]["address"])
|
||||
self._check_fields(channel.json_body)
|
||||
|
||||
# Set a new and remove a threepid
|
||||
channel = self.make_request(
|
||||
"PUT",
|
||||
self.url_other_user,
|
||||
access_token=self.admin_user_tok,
|
||||
content={
|
||||
"threepids": [
|
||||
{"medium": "email", "address": "bob2@bob.bob"},
|
||||
{"medium": "email", "address": "bob3@bob.bob"},
|
||||
],
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("@user:test", channel.json_body["name"])
|
||||
self.assertEqual(2, len(channel.json_body["threepids"]))
|
||||
self.assertEqual("email", channel.json_body["threepids"][0]["medium"])
|
||||
self.assertEqual("bob3@bob.bob", channel.json_body["threepids"][0]["address"])
|
||||
self.assertEqual("bob2@bob.bob", channel.json_body["threepids"][0]["address"])
|
||||
self.assertEqual("email", channel.json_body["threepids"][1]["medium"])
|
||||
self.assertEqual("bob3@bob.bob", channel.json_body["threepids"][1]["address"])
|
||||
self._check_fields(channel.json_body)
|
||||
|
||||
# Get user
|
||||
channel = self.make_request(
|
||||
|
@ -1698,8 +1735,24 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("@user:test", channel.json_body["name"])
|
||||
self.assertEqual(2, len(channel.json_body["threepids"]))
|
||||
self.assertEqual("email", channel.json_body["threepids"][0]["medium"])
|
||||
self.assertEqual("bob3@bob.bob", channel.json_body["threepids"][0]["address"])
|
||||
self.assertEqual("bob2@bob.bob", channel.json_body["threepids"][0]["address"])
|
||||
self.assertEqual("email", channel.json_body["threepids"][1]["medium"])
|
||||
self.assertEqual("bob3@bob.bob", channel.json_body["threepids"][1]["address"])
|
||||
self._check_fields(channel.json_body)
|
||||
|
||||
# Remove threepids
|
||||
channel = self.make_request(
|
||||
"PUT",
|
||||
self.url_other_user,
|
||||
access_token=self.admin_user_tok,
|
||||
content={"threepids": []},
|
||||
)
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("@user:test", channel.json_body["name"])
|
||||
self.assertEqual(0, len(channel.json_body["threepids"]))
|
||||
self._check_fields(channel.json_body)
|
||||
|
||||
def test_set_external_id(self):
|
||||
"""
|
||||
|
@ -1778,6 +1831,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("@user:test", channel.json_body["name"])
|
||||
self.assertEqual(2, len(channel.json_body["external_ids"]))
|
||||
self.assertEqual(
|
||||
channel.json_body["external_ids"],
|
||||
[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue