Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI option to subscribe existing accounts during bulk invites. #16041

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
tests: Add test for existing user anon_email matching delivery_email.
When the email_address_visibility realm setting is switched to
Realm.EMAIL_ADDRESS_VISIBILITY_EVERYONE, get_existing_user_errors
returns the maybe_anonymous_email parameter, which in this case
should match with the delivery_email.
  • Loading branch information
sumanthvrao committed Aug 25, 2020
commit 8a454aea0bad76993ceb2777cd15e8d1a1da4598
11 changes: 10 additions & 1 deletion zerver/tests/test_auth_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -5005,14 +5005,23 @@ def test_validate_email(self) -> None:
self.assertEqual(error, 'Already has an account.')
self.assertEqual(maybe_anonymous_email, cordelia_anonymous_email)

do_set_realm_property(realm, 'email_address_visibility', Realm.EMAIL_ADDRESS_VISIBILITY_EVERYONE)
cordelia.refresh_from_db()

errors = get_existing_user_errors(realm, {cordelia_email})
error, is_deactivated, maybe_anonymous_email = errors[cordelia_email]
self.assertEqual(False, is_deactivated)
self.assertEqual(error, 'Already has an account.')
self.assertEqual(maybe_anonymous_email, cordelia_email)

cordelia.is_active = False
cordelia.save()

errors = get_existing_user_errors(realm, {cordelia_email})
error, is_deactivated, maybe_anonymous_email = errors[cordelia_email]
self.assertEqual(True, is_deactivated)
self.assertEqual(error, 'Account has been deactivated.')
self.assertEqual(maybe_anonymous_email, cordelia_anonymous_email)
self.assertEqual(maybe_anonymous_email, cordelia_email)

errors = get_existing_user_errors(realm, {'fred-is-fine@zulip.com'})
self.assertEqual(errors, {})
Expand Down