do_delete_user: Use get_fake_email_domain for dummy user email domain.

Otherwise the dummy user can be created with an invalid email domain -
e.g. in development environment with the domain
"@http://localhost:9991". get_fake_email_domain exists exactly for
handling these kinds of scenarios.
This commit is contained in:
Mateusz Mandera 2021-10-05 22:03:49 +02:00 committed by Tim Abbott
parent dffdeb48e7
commit 208c0c3034
2 changed files with 3 additions and 2 deletions

View File

@ -239,6 +239,7 @@ from zerver.models import (
get_bot_services,
get_client,
get_default_stream_groups,
get_fake_email_domain,
get_huddle_recipient,
get_huddle_user_ids,
get_old_unclaimed_attachments,
@ -1224,7 +1225,7 @@ def do_delete_user(user_profile: UserProfile) -> None:
personal_recipient.delete()
replacement_user = create_user(
force_id=user_id,
email=f"deleteduser{user_id}@{realm.uri}",
email=f"deleteduser{user_id}@{get_fake_email_domain(realm)}",
password=None,
realm=realm,
full_name=f"Deleted User {user_id}",

View File

@ -2068,7 +2068,7 @@ class DeleteUserTest(ZulipTestCase):
replacement_dummy_user = UserProfile.objects.get(id=hamlet_user_id, realm=realm)
self.assertEqual(
replacement_dummy_user.delivery_email, f"deleteduser{hamlet_user_id}@{realm.uri}"
replacement_dummy_user.delivery_email, f"deleteduser{hamlet_user_id}@zulip.testserver"
)
self.assertEqual(replacement_dummy_user.is_mirror_dummy, True)
self.assertEqual(replacement_dummy_user.is_active, False)