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

Fixed a bug with reactivating users with the admin API #8362

Merged
merged 5 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/8362.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a regression in v1.19.0 with reactivating users through the admin API.
2 changes: 1 addition & 1 deletion synapse/storage/databases/main/user_erasure_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def f(txn):
return

# They are there, delete them.
self.simple_delete_one_txn(
self.db_pool.simple_delete_one_txn(
txn, "erased_users", keyvalues={"user_id": user_id}
)

Expand Down
14 changes: 14 additions & 0 deletions tests/rest/admin/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,10 @@ def test_reactivate_user(self):
)
self.render(request)
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
self._is_erased("@user:test", False)
d = self.store.mark_user_erased("@user:test")
self.assertIsNone(self.get_success(d))
self._is_erased("@user:test", True)

# Attempt to reactivate the user (without a password).
request, channel = self.make_request(
Expand Down Expand Up @@ -906,6 +910,7 @@ def test_reactivate_user(self):
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
self.assertEqual("@user:test", channel.json_body["name"])
self.assertEqual(False, channel.json_body["deactivated"])
self._is_erased("@user:test", False)

def test_set_user_as_admin(self):
"""
Expand Down Expand Up @@ -996,6 +1001,15 @@ def test_accidental_deactivation_prevention(self):
# Ensure they're still alive
self.assertEqual(0, channel.json_body["deactivated"])

def _is_erased(self, user_id, expect):
"""Assert that the user is erased or not
"""
d = self.store.is_user_erased(user_id)
if expect:
self.assertTrue(self.get_success(d))
else:
self.assertFalse(self.get_success(d))


class UserMembershipRestTestCase(unittest.HomeserverTestCase):

Expand Down