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

Commit

Permalink
Move erasure status test to UsersListTestCase
Browse files Browse the repository at this point in the history
  • Loading branch information
tadzik committed Oct 20, 2022
1 parent 15ac386 commit 35c2a88
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions tests/rest/admin/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from synapse.rest.client import devices, login, logout, profile, register, room, sync
from synapse.rest.media.v1.filepath import MediaFilePaths
from synapse.server import HomeServer
from synapse.types import JsonDict, UserID
from synapse.types import JsonDict, UserID, create_requester
from synapse.util import Clock

from tests import unittest
Expand Down Expand Up @@ -924,6 +924,32 @@ def test_filter_out_approved(self) -> None:
self.assertEqual(1, len(non_admin_user_ids), non_admin_user_ids)
self.assertEqual(not_approved_user, non_admin_user_ids[0])

def test_erasure_status(self):
user_id = self.register_user("eraseme", "eraseme")

channel = self.make_request(
"GET",
self.url + "?deactivated=true",
access_token=self.admin_user_tok,
)
users = {user["name"]: user for user in channel.json_body["users"]}
self.assertIs(users[user_id]["erased"], False)

deactivate_account_handler = self.hs.get_deactivate_account_handler()
self.get_success(
deactivate_account_handler.deactivate_account(
user_id, True, create_requester(user_id)
)
)

channel = self.make_request(
"GET",
self.url + "?deactivated=true",
access_token=self.admin_user_tok,
)
users = {user["name"]: user for user in channel.json_body["users"]}
self.assertIs(users[user_id]["erased"], True)

def _order_test(
self,
expected_user_list: List[str],
Expand Down Expand Up @@ -1092,10 +1118,8 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None:

self.other_user = self.register_user("user", "pass", displayname="User1")
self.other_user_token = self.login("user", "pass")
self.url_users = "/_synapse/admin/v2/users"
self.url_other_user = "%s/%s" % (
self.url_users,
urllib.parse.quote(self.other_user),
self.url_other_user = "/_synapse/admin/v2/users/%s" % urllib.parse.quote(
self.other_user
)
self.url = "/_synapse/admin/v1/deactivate/%s" % urllib.parse.quote(
self.other_user
Expand Down Expand Up @@ -1224,16 +1248,6 @@ def test_deactivate_user_erase_true(self) -> None:

self._is_erased("@user:test", True)

channel = self.make_request(
"GET",
self.url_users + "?deactivated=true",
access_token=self.admin_user_tok,
)

users = {user["name"]: user for user in channel.json_body["users"]}

self.assertIs(users["@user:test"]["erased"], True)

@override_config({"max_avatar_size": 1234})
def test_deactivate_user_erase_true_avatar_nonnull_but_empty(self) -> None:
"""Check we can erase a user whose avatar is the empty string.
Expand Down

0 comments on commit 35c2a88

Please sign in to comment.