This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Do not propagate profile changes of shadow-banned users into rooms #8157
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f34650b
Move tests to separate file.
clokep 81f432e
Do not allow profile changes to propagate to rooms.
clokep 237f5c8
Add a newsfragment.
clokep 580c0f8
Fix copy and paste errors
clokep 0274414
Ensure the display name in the room was not updated.
clokep 37af103
Also handle directly changing the state for a room.
clokep a2cfbff
Merge remote-tracking branch 'origin/develop' into clokep/shadow-bann…
clokep a4a8c2c
Clarify comment.
clokep c21729d
Merge remote-tracking branch 'origin/develop' into clokep/shadow-bann…
clokep File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,23 +16,13 @@ | |
|
|
||
| import synapse.rest.admin | ||
| from synapse.api.constants import EventTypes | ||
| from synapse.rest.client.v1 import directory, login, room | ||
| from synapse.rest.client.v1 import directory, login, profile, room | ||
| from synapse.rest.client.v2_alpha import room_upgrade_rest_servlet | ||
|
|
||
| from tests import unittest | ||
|
|
||
|
|
||
| # To avoid the tests timing out don't add a delay to "annoy the requester". | ||
| @patch("random.randint", new=lambda a, b: 0) | ||
| class RoomTestCase(unittest.HomeserverTestCase): | ||
| servlets = [ | ||
| synapse.rest.admin.register_servlets_for_client_rest_resource, | ||
| directory.register_servlets, | ||
| login.register_servlets, | ||
| room.register_servlets, | ||
| room_upgrade_rest_servlet.register_servlets, | ||
| ] | ||
|
|
||
| class _ShadowBannedBase(unittest.HomeserverTestCase): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Elegant way to break the classes up 👍 |
||
| def prepare(self, reactor, clock, homeserver): | ||
| # Create two users, one of which is shadow-banned. | ||
| self.banned_user_id = self.register_user("banned", "test") | ||
|
|
@@ -52,6 +42,18 @@ def prepare(self, reactor, clock, homeserver): | |
| self.other_user_id = self.register_user("otheruser", "pass") | ||
| self.other_access_token = self.login("otheruser", "pass") | ||
|
|
||
|
|
||
| # To avoid the tests timing out don't add a delay to "annoy the requester". | ||
| @patch("random.randint", new=lambda a, b: 0) | ||
| class RoomTestCase(_ShadowBannedBase): | ||
| servlets = [ | ||
| synapse.rest.admin.register_servlets_for_client_rest_resource, | ||
| directory.register_servlets, | ||
| login.register_servlets, | ||
| room.register_servlets, | ||
| room_upgrade_rest_servlet.register_servlets, | ||
| ] | ||
|
|
||
| def test_invite(self): | ||
| """Invites from shadow-banned users don't actually get sent.""" | ||
|
|
||
|
|
@@ -176,3 +178,34 @@ def test_upgrade(self): | |
| summary = self.get_success(self.store.get_room_summary(new_room_id)) | ||
| # The summary should be empty since the room doesn't exist. | ||
| self.assertEqual(summary, {}) | ||
|
|
||
|
|
||
| # To avoid the tests timing out don't add a delay to "annoy the requester". | ||
| @patch("random.randint", new=lambda a, b: 0) | ||
| class ProfileTestCase(_ShadowBannedBase): | ||
| servlets = [ | ||
| synapse.rest.admin.register_servlets_for_client_rest_resource, | ||
| login.register_servlets, | ||
| profile.register_servlets, | ||
| ] | ||
|
|
||
| def test_displayname(self): | ||
| """Profile changes should succeed, but don't end up in a room.""" | ||
| # The update should succeed. | ||
| request, channel = self.make_request( | ||
| "PUT", | ||
| "/_matrix/client/r0/profile/%s/displayname" % (self.banned_user_id,), | ||
| {"displayname": "new display name"}, | ||
| access_token=self.banned_access_token, | ||
| ) | ||
| self.render(request) | ||
| self.assertEquals(200, channel.code, channel.result) | ||
| self.assertEqual(channel.json_body, {}) | ||
|
|
||
| # The user's display name should be updated. | ||
| request, channel = self.make_request( | ||
| "GET", "/profile/%s/displayname" % (self.banned_user_id,) | ||
| ) | ||
| self.render(request) | ||
| self.assertEqual(channel.code, 200, channel.result) | ||
| self.assertEqual(channel.json_body["displayname"], "new display name") | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.