diff --git a/templates/zerver/dev_login.html b/templates/zerver/dev_login.html index 8d4ef7a7b2..76d4433d13 100644 --- a/templates/zerver/dev_login.html +++ b/templates/zerver/dev_login.html @@ -43,9 +43,7 @@ {{ csrf_input }}

Realm

- {% if realms_have_subdomains %}

.{{ external_host }}

- {% endif %}

{% if form.realm_subdomain.errors %} @@ -124,11 +118,7 @@ Form is validated both client-side using jquery-validate (see signup.js) and ser {% endif %}
- {% if realms_have_subdomains %} {{ _("The address you'll use to sign in to your organization.") }} - {% else %} - {{ _("a-z, 0-9, and - only.") }} - {% endif %}
{% endif %} diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.py index f5559497d1..22a1ed5c1c 100644 --- a/zerver/tests/test_auth_backends.py +++ b/zerver/tests/test_auth_backends.py @@ -72,7 +72,6 @@ class AuthBackendTest(ZulipTestCase): return username - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def verify_backend(self, backend, good_kwargs=None, bad_kwargs=None): # type: (Any, Optional[Dict[str, Any]], Optional[Dict[str, Any]]) -> None @@ -361,7 +360,6 @@ class GitHubAuthBackendTest(ZulipTestCase): assert(result is not None) self.assertIn('subdomain=1', result.url) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_github_backend_do_auth_with_subdomains(self): # type: () -> None with mock.patch('social_core.backends.github.GithubOAuth2.do_auth', @@ -399,7 +397,6 @@ class GitHubAuthBackendTest(ZulipTestCase): 'return_data': {}} result.assert_called_with(None, 'fake-access-token', **kwargs) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_github_backend_do_auth_for_team(self): # type: () -> None with mock.patch('social_core.backends.github.GithubTeamOAuth2.do_auth', @@ -415,7 +412,6 @@ class GitHubAuthBackendTest(ZulipTestCase): 'return_data': {}} result.assert_called_with(self.user_profile, 'fake-access-token', **kwargs) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_github_backend_do_auth_for_team_auth_failed(self): # type: () -> None with mock.patch('social_core.backends.github.GithubTeamOAuth2.do_auth', @@ -431,7 +427,6 @@ class GitHubAuthBackendTest(ZulipTestCase): 'return_data': {}} result.assert_called_with(None, 'fake-access-token', **kwargs) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_github_backend_do_auth_for_org(self): # type: () -> None with mock.patch('social_core.backends.github.GithubOrganizationOAuth2.do_auth', @@ -447,7 +442,6 @@ class GitHubAuthBackendTest(ZulipTestCase): 'return_data': {}} result.assert_called_with(self.user_profile, 'fake-access-token', **kwargs) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_github_backend_do_auth_for_org_auth_failed(self): # type: () -> None with mock.patch('social_core.backends.github.GithubOrganizationOAuth2.do_auth', @@ -743,7 +737,6 @@ class GoogleSubdomainLoginTest(GoogleOAuthTest): value = ujson.dumps(data) return {key: signing.get_cookie_signer(salt=salt).sign(value)} - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_google_oauth2_start(self): # type: () -> None result = self.client_get('/accounts/login/google/', subdomain="zulip") @@ -752,7 +745,6 @@ class GoogleSubdomainLoginTest(GoogleOAuthTest): subdomain = urllib.parse.parse_qs(parsed_url.query)['subdomain'] self.assertEqual(subdomain, ['zulip']) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_google_oauth2_success(self): # type: () -> None token_response = ResponseMock(200, {'access_token': "unique_token"}) @@ -772,7 +764,6 @@ class GoogleSubdomainLoginTest(GoogleOAuthTest): parsed_url.path) self.assertEqual(uri, 'http://zulip.testserver/accounts/login/subdomain/') - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_google_oauth2_no_fullname(self): # type: () -> None token_response = ResponseMock(200, {'access_token': "unique_token"}) @@ -792,7 +783,6 @@ class GoogleSubdomainLoginTest(GoogleOAuthTest): parsed_url.path) self.assertEqual(uri, 'http://zulip.testserver/accounts/login/subdomain/') - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_google_oauth2_mobile_success(self): # type: () -> None mobile_flow_otp = '1234abcd' * 8 @@ -827,7 +817,6 @@ class GoogleSubdomainLoginTest(GoogleOAuthTest): self.assertEqual(len(mail.outbox), 1) self.assertIn('Zulip on Android', mail.outbox[0].body) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_log_into_subdomain(self): # type: () -> None data = {'name': 'Full Name', @@ -850,7 +839,6 @@ class GoogleSubdomainLoginTest(GoogleOAuthTest): self.assertEqual(result.status_code, 302) self.assertTrue(result['Location'].endswith, '?subdomain=1') - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_log_into_subdomain_when_is_signup_is_true(self): # type: () -> None data = {'name': 'Full Name', @@ -863,7 +851,6 @@ class GoogleSubdomainLoginTest(GoogleOAuthTest): self.assertEqual(result.status_code, 200) self.assert_in_response('hamlet@zulip.com already has an account', result) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_log_into_subdomain_when_is_signup_is_true_and_new_user(self): # type: () -> None data = {'name': 'New User Name', @@ -889,7 +876,6 @@ class GoogleSubdomainLoginTest(GoogleOAuthTest): self.assert_not_in_success_response(['id_password'], result) self.assert_in_success_response(['id_full_name'], result) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_log_into_subdomain_when_using_invite_link(self): # type: () -> None data = {'name': 'New User Name', @@ -952,7 +938,6 @@ class GoogleSubdomainLoginTest(GoogleOAuthTest): self.assertEqual(result.status_code, 302) self.assertEqual(sorted(self.get_streams('new@zulip.com', realm)), stream_names) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_log_into_subdomain_when_email_is_none(self): # type: () -> None data = {'name': None, @@ -967,7 +952,6 @@ class GoogleSubdomainLoginTest(GoogleOAuthTest): self.assert_in_response("Please click the following button if you " "wish to register", result) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_user_cannot_log_into_nonexisting_realm(self): # type: () -> None token_response = ResponseMock(200, {'access_token': "unique_token"}) @@ -980,7 +964,6 @@ class GoogleSubdomainLoginTest(GoogleOAuthTest): self.assert_in_success_response(["There is no Zulip organization hosted at this subdomain."], result) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_user_cannot_log_into_wrong_subdomain(self): # type: () -> None token_response = ResponseMock(200, {'access_token': "unique_token"}) @@ -998,7 +981,6 @@ class GoogleSubdomainLoginTest(GoogleOAuthTest): self.assert_in_success_response(["Your Zulip account is not a member of the organization associated with this subdomain."], result) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_user_cannot_log_into_wrong_subdomain_with_cookie(self): # type: () -> None data = {'name': 'Full Name', @@ -1009,20 +991,17 @@ class GoogleSubdomainLoginTest(GoogleOAuthTest): result = self.client_get('/accounts/login/subdomain/', subdomain="zulip") self.assertEqual(result.status_code, 400) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_log_into_subdomain_when_signature_is_bad(self): # type: () -> None self.client.cookies = SimpleCookie({'subdomain.signature': 'invlaid'}) result = self.client_get('/accounts/login/subdomain/', subdomain="zulip") self.assertEqual(result.status_code, 400) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_log_into_subdomain_when_state_is_not_passed(self): # type: () -> None result = self.client_get('/accounts/login/subdomain/', subdomain="zulip") self.assertEqual(result.status_code, 400) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_google_oauth2_registration(self): # type: () -> None """If the user doesn't exist yet, Google auth can be used to register an account""" @@ -1076,7 +1055,6 @@ class GoogleSubdomainLoginTest(GoogleOAuthTest): self.assertEqual(get_session_dict_user(self.client.session), user_profile.id) class GoogleLoginTest(GoogleOAuthTest): - @override_settings(REALMS_HAVE_SUBDOMAINS=True) @override_settings(ROOT_DOMAIN_LANDING_PAGE=True) def test_google_oauth2_subdomains_homepage(self): # type: () -> None @@ -1368,7 +1346,6 @@ class FetchAuthBackends(ZulipTestCase): if error: raise AssertionError(error) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_get_server_settings(self): # type: () -> None result = self.client_get("/api/v1/server_settings", @@ -1446,7 +1423,6 @@ class FetchAuthBackends(ZulipTestCase): for backend in set(data.keys()) - {'msg', 'result', 'zulip_version'}: self.assertTrue(isinstance(data[backend], bool)) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_fetch_auth_backend(self): # type: () -> None backends = [GoogleMobileOauth2Backend(), DevAuthBackend()] @@ -1532,7 +1508,6 @@ class TestDevAuthBackend(ZulipTestCase): self.assertEqual(result.status_code, 302) self.assertEqual(get_session_dict_user(self.client.session), user_profile.id) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_login_with_subdomain(self): # type: () -> None user_profile = self.example_user('hamlet') @@ -1543,7 +1518,6 @@ class TestDevAuthBackend(ZulipTestCase): self.assertEqual(result.status_code, 302) self.assertEqual(get_session_dict_user(self.client.session), user_profile.id) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_choose_realm(self): # type: () -> None result = self.client_post('/devlogin/', subdomain="zulip") @@ -1564,7 +1538,6 @@ class TestDevAuthBackend(ZulipTestCase): self.assert_in_success_response(["Click on a user to log in to MIT!"], result) self.assert_not_in_success_response(["iago@zulip.com", "hamlet@zulip.com"], result) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_choose_realm_with_subdomains_enabled(self): # type: () -> None with mock.patch('zerver.views.auth.is_subdomain_root_or_alias', return_value=False): @@ -1654,7 +1627,6 @@ class TestZulipRemoteUserBackend(ZulipTestCase): result = self.client_post('/accounts/login/sso/') self.assert_json_error_contains(result, "No REMOTE_USER set.", 400) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_login_failure_due_to_wrong_subdomain(self): # type: () -> None email = self.example_email("hamlet") @@ -1666,7 +1638,6 @@ class TestZulipRemoteUserBackend(ZulipTestCase): self.assertIs(get_session_dict_user(self.client.session), None) self.assert_in_response("No account found for", result) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_login_failure_due_to_empty_subdomain(self): # type: () -> None email = self.example_email("hamlet") @@ -1678,7 +1649,6 @@ class TestZulipRemoteUserBackend(ZulipTestCase): self.assertIs(get_session_dict_user(self.client.session), None) self.assert_in_response("No account found for", result) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_login_success_under_subdomains(self): # type: () -> None user_profile = self.example_user('hamlet') @@ -1771,7 +1741,6 @@ class TestJWTLogin(ZulipTestCase): self.assertEqual(result.status_code, 200) # This should ideally be not 200. self.assertIs(get_session_dict_user(self.client.session), None) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_login_failure_due_to_wrong_subdomain(self): # type: () -> None payload = {'user': 'hamlet', 'realm': 'zulip.com'} @@ -1785,7 +1754,6 @@ class TestJWTLogin(ZulipTestCase): self.assert_json_error_contains(result, "Wrong subdomain", 400) self.assertEqual(get_session_dict_user(self.client.session), None) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_login_failure_due_to_empty_subdomain(self): # type: () -> None payload = {'user': 'hamlet', 'realm': 'zulip.com'} @@ -1799,7 +1767,6 @@ class TestJWTLogin(ZulipTestCase): self.assert_json_error_contains(result, "Wrong subdomain", 400) self.assertEqual(get_session_dict_user(self.client.session), None) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_login_success_under_subdomains(self): # type: () -> None payload = {'user': 'hamlet', 'realm': 'zulip.com'} @@ -2031,7 +1998,6 @@ class TestLDAP(ZulipTestCase): user_profile = self.backend.authenticate(self.example_email("hamlet"), 'pass') self.assertIs(user_profile, None) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) @override_settings(AUTHENTICATION_BACKENDS=('zproject.backends.ZulipLDAPAuthBackend',)) def test_login_failure_due_to_wrong_subdomain(self): # type: () -> None @@ -2041,7 +2007,6 @@ class TestLDAP(ZulipTestCase): } } with self.settings( - REALMS_HAVE_SUBDOMAINS=True, LDAP_APPEND_DOMAIN='zulip.com', AUTH_LDAP_BIND_PASSWORD='', AUTH_LDAP_USER_DN_TEMPLATE='uid=%(user)s,ou=users,dc=zulip,dc=com'): @@ -2049,7 +2014,6 @@ class TestLDAP(ZulipTestCase): realm_subdomain='acme') self.assertIs(user_profile, None) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) @override_settings(AUTHENTICATION_BACKENDS=('zproject.backends.ZulipLDAPAuthBackend',)) def test_login_failure_due_to_empty_subdomain(self): # type: () -> None @@ -2066,7 +2030,6 @@ class TestLDAP(ZulipTestCase): realm_subdomain='') self.assertIs(user_profile, None) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) @override_settings(AUTHENTICATION_BACKENDS=('zproject.backends.ZulipLDAPAuthBackend',)) def test_login_success_when_subdomain_is_none(self): # type: () -> None @@ -2084,7 +2047,6 @@ class TestLDAP(ZulipTestCase): assert(user_profile is not None) self.assertEqual(user_profile.email, self.example_email("hamlet")) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) @override_settings(AUTHENTICATION_BACKENDS=('zproject.backends.ZulipLDAPAuthBackend',)) def test_login_success_with_valid_subdomain(self): # type: () -> None @@ -2102,7 +2064,6 @@ class TestLDAP(ZulipTestCase): assert(user_profile is not None) self.assertEqual(user_profile.email, self.example_email("hamlet")) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) @override_settings(AUTHENTICATION_BACKENDS=('zproject.backends.ZulipLDAPAuthBackend',)) def test_login_success_when_user_does_not_exist_with_valid_subdomain(self): # type: () -> None diff --git a/zerver/tests/test_bots.py b/zerver/tests/test_bots.py index 19defb03cd..06ff7e79fb 100644 --- a/zerver/tests/test_bots.py +++ b/zerver/tests/test_bots.py @@ -26,7 +26,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): self.assert_json_success(result) self.assertEqual(count, len(result.json()['bots'])) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def create_bot(self, **extras): # type: (**Any) -> Dict[str, Any] bot_info = { @@ -131,7 +130,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): self.assertEqual(bot['bot_owner'], self.example_email('hamlet')) self.assertEqual(bot['user_id'], get_user(email, realm).id) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_add_bot_with_username_in_use(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -164,7 +162,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): self.assertEqual(profile.avatar_source, UserProfile.AVATAR_FROM_USER) self.assertTrue(os.path.exists(avatar_disk_path(profile))) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_add_bot_with_too_many_files(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -294,7 +291,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): ) self.assertEqual(event['users'], {user_profile.id, }) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_add_bot_with_default_sending_stream_private_denied(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -365,7 +361,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): ) self.assertEqual(event['users'], {user_profile.id, }) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_add_bot_with_default_events_register_stream_private_denied(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -516,7 +511,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): profile = get_user(bot_email, bot_realm) self.assertEqual(profile.bot_type, UserProfile.INCOMING_WEBHOOK_BOT) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_add_bot_with_bot_type_invalid(self): # type: () -> None bot_info = { @@ -531,7 +525,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): self.assert_num_bots_equal(0) self.assert_json_error(result, 'Invalid bot type') - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_patch_bot_full_name(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -552,7 +545,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): bot = self.get_bot() self.assertEqual('Fred', bot['full_name']) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_patch_bot_owner(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -575,7 +567,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): bot = self.get_bot() self.assertEqual('The Bot of Hamlet', bot['full_name']) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) @override_settings(LOCAL_UPLOADS_DIR='var/bot_avatar') def test_patch_bot_avatar(self): # type: () -> None @@ -619,7 +610,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): self.assertEqual(profile.avatar_source, UserProfile.AVATAR_FROM_USER) self.assertTrue(os.path.exists(avatar_disk_path(profile))) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_patch_bot_to_stream(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -640,7 +630,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): bot = self.get_bot() self.assertEqual('Denmark', bot['default_sending_stream']) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_patch_bot_to_stream_not_subscribed(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -661,7 +650,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): bot = self.get_bot() self.assertEqual('Rome', bot['default_sending_stream']) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_patch_bot_to_stream_none(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -685,7 +673,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): bot = self.get_bot() self.assertEqual(None, bot['default_sending_stream']) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_patch_bot_to_stream_private_allowed(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -711,7 +698,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): bot = self.get_bot() self.assertEqual('Denmark', bot['default_sending_stream']) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_patch_bot_to_stream_private_denied(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -733,7 +719,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): result = self.client_patch("/json/bots/hambot-bot@zulip.testserver", bot_info) self.assert_json_error(result, "Invalid stream name 'Denmark'") - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_patch_bot_to_stream_not_found(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -749,7 +734,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): result = self.client_patch("/json/bots/hambot-bot@zulip.testserver", bot_info) self.assert_json_error(result, "Invalid stream name 'missing'") - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_patch_bot_events_register_stream(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -770,7 +754,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): bot = self.get_bot() self.assertEqual('Denmark', bot['default_events_register_stream']) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_patch_bot_events_register_stream_allowed(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -795,7 +778,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): bot = self.get_bot() self.assertEqual('Denmark', bot['default_events_register_stream']) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_patch_bot_events_register_stream_denied(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -816,7 +798,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): result = self.client_patch("/json/bots/hambot-bot@zulip.testserver", bot_info) self.assert_json_error(result, "Invalid stream name 'Denmark'") - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_patch_bot_events_register_stream_none(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -840,7 +821,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): bot = self.get_bot() self.assertEqual(None, bot['default_events_register_stream']) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_patch_bot_events_register_stream_not_found(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -856,7 +836,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): result = self.client_patch("/json/bots/hambot-bot@zulip.testserver", bot_info) self.assert_json_error(result, "Invalid stream name 'missing'") - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_patch_bot_default_all_public_streams_true(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -877,7 +856,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): bot = self.get_bot() self.assertEqual(bot['default_all_public_streams'], True) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_patch_bot_default_all_public_streams_false(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -898,7 +876,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): bot = self.get_bot() self.assertEqual(bot['default_all_public_streams'], False) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_patch_bot_via_post(self): # type: () -> None self.login(self.example_email('hamlet')) @@ -920,7 +897,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): bot = self.get_bot() self.assertEqual('Fred', bot['full_name']) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_patch_bogus_bot(self): # type: () -> None """Deleting a bogus bot will succeed silently.""" @@ -933,7 +909,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): self.assert_json_error(result, 'No such user') self.assert_num_bots_equal(1) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_create_outgoing_webhook_bot(self, **extras): # type: (**Any) -> None self.login(self.example_email('hamlet')) @@ -963,7 +938,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): result = self.client_post("/json/bots", bot_info) self.assert_json_error(result, "Enter a valid URL.") - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_get_bot_handler(self): # type: () -> None # Test for valid service. @@ -987,7 +961,6 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): bot_handler_class_name = class_bot_handler.format(name=bot_name, Name=bot_name.title()) self.assertEqual(str(type(embedded_bot_handler)), bot_handler_class_name) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_outgoing_webhook_interface_type(self): # type: () -> None self.login(self.example_email('hamlet')) diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.py index cd5a54aecd..bb7871e4de 100644 --- a/zerver/tests/test_decorators.py +++ b/zerver/tests/test_decorators.py @@ -211,7 +211,6 @@ class DecoratorTestCase(TestCase): pass # nocoverage # this function isn't meant to be called test(request) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_api_key_only_webhook_view(self): # type: () -> None @api_key_only_webhook_view('ClientName') @@ -919,7 +918,6 @@ class TestValidateApiKey(ZulipTestCase): is_webhook=True) self.assertEqual(profile.pk, self.webhook_bot.pk) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_valid_api_key_if_user_is_on_wrong_subdomain(self): # type: () -> None with self.settings(RUNNING_INSIDE_TORNADO=False): @@ -1061,13 +1059,11 @@ class TestAuthenticatedJsonPostViewDecorator(ZulipTestCase): response = self._do_test(user_email) self.assertEqual(response.status_code, 200) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_authenticated_json_post_view_if_subdomain_is_invalid(self): # type: () -> None user_email = self.example_email('hamlet') user_realm = get_realm('zulip') self._login(user_email, user_realm) - with mock.patch('logging.warning') as mock_warning, \ mock.patch('zerver.decorator.get_subdomain', return_value=''): self.assert_json_error_contains(self._do_test(user_email), @@ -1132,7 +1128,6 @@ class TestAuthenticatedJsonPostViewDecorator(ZulipTestCase): self.login(user_email, password) class TestAuthenticatedJsonViewDecorator(ZulipTestCase): - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_authenticated_json_view_if_subdomain_is_invalid(self): # type: () -> None user_email = self.example_email("hamlet") @@ -1162,7 +1157,6 @@ class TestAuthenticatedJsonViewDecorator(ZulipTestCase): return self.client_post(r'/json/tutorial_status', data) class TestZulipLoginRequiredDecorator(ZulipTestCase): - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_zulip_login_required_if_subdomain_is_invalid(self): # type: () -> None user_email = self.example_email("hamlet") diff --git a/zerver/tests/test_docs.py b/zerver/tests/test_docs.py index 84ad954e1e..d2b057b91e 100644 --- a/zerver/tests/test_docs.py +++ b/zerver/tests/test_docs.py @@ -18,7 +18,6 @@ from zerver.views.integrations import ( ) class DocPageTest(ZulipTestCase): - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def _test(self, url, expected_content, extra_strings=[], landing_page=True): # type: (str, str, List[str], bool) -> None diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py index 94c0b1f16b..14ab58941f 100644 --- a/zerver/tests/test_home.py +++ b/zerver/tests/test_home.py @@ -22,7 +22,6 @@ from zerver.models import ( from zerver.views.home import home, sent_time_in_epoch_seconds class HomeTest(ZulipTestCase): - @override_settings(REALMS_HAVE_SUBDOMAINS=True) @slow('big method') def test_home(self): # type: () -> None diff --git a/zerver/tests/test_messages.py b/zerver/tests/test_messages.py index 0f5aa66c4e..c085816918 100644 --- a/zerver/tests/test_messages.py +++ b/zerver/tests/test_messages.py @@ -1224,7 +1224,6 @@ class MessagePOSTTest(ZulipTestCase): subdomain="notzephyr") self.assert_json_error(result, "Invalid mirrored realm") - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_send_message_irc_mirror(self): # type: () -> None self.login(self.example_email('hamlet')) diff --git a/zerver/tests/test_notifications.py b/zerver/tests/test_notifications.py index 42c35e1adc..12f1a4b2da 100644 --- a/zerver/tests/test_notifications.py +++ b/zerver/tests/test_notifications.py @@ -328,7 +328,6 @@ class TestMissedMessages(ZulipTestCase): # type: () -> None self._deleted_message_in_huddle_missed_stream_messages(False) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) @patch('zerver.lib.email_mirror.generate_random_token') def test_realm_emoji_in_missed_message(self, mock_random_token): # type: (MagicMock) -> None @@ -342,7 +341,6 @@ class TestMissedMessages(ZulipTestCase): subject = 'Othello, the Moor of Venice sent you a message' self._test_cases(tokens, msg_id, body, subject, send_as_user=False, verify_html_body=True) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) @patch('zerver.lib.email_mirror.generate_random_token') def test_stream_link_in_missed_message(self, mock_random_token): # type: (MagicMock) -> None diff --git a/zerver/tests/test_outgoing_webhook_system.py b/zerver/tests/test_outgoing_webhook_system.py index 8fa198165e..c6d5c90761 100644 --- a/zerver/tests/test_outgoing_webhook_system.py +++ b/zerver/tests/test_outgoing_webhook_system.py @@ -68,7 +68,6 @@ class DoRestCallTests(ZulipTestCase): do_rest_call(self.rest_operation, None, self.mock_event, service_handler, None) self.assertTrue(mock_succeed_with_message.called) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_retry_request(self): # type: (mock.Mock) -> None response = ResponseMock(500, {"message": "testing"}, '') @@ -83,7 +82,6 @@ The webhook got a response with status code *500*.''') self.assertEqual(bot_owner_notification.recipient_id, self.bot_user.bot_owner.id) self.mock_event['failed_tries'] = 0 - @override_settings(REALMS_HAVE_SUBDOMAINS=True) @mock.patch('zerver.lib.outgoing_webhook.fail_with_message') def test_fail_request(self, mock_fail_with_message): # type: (mock.Mock) -> None @@ -97,7 +95,6 @@ The webhook got a response with status code *500*.''') The webhook got a response with status code *400*.''') self.assertEqual(bot_owner_notification.recipient_id, self.bot_user.bot_owner.id) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) @mock.patch('logging.info') @mock.patch('requests.request', side_effect=timeout_error) def test_timeout_request(self, mock_requests_request, mock_logger): @@ -112,7 +109,6 @@ Time is up! ```''') self.assertEqual(bot_owner_notification.recipient_id, self.bot_user.bot_owner.id) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) @mock.patch('logging.exception') @mock.patch('requests.request', side_effect=request_exception_error) @mock.patch('zerver.lib.outgoing_webhook.fail_with_message') diff --git a/zerver/tests/test_presence.py b/zerver/tests/test_presence.py index 093bb4e308..4b0a5b791b 100644 --- a/zerver/tests/test_presence.py +++ b/zerver/tests/test_presence.py @@ -28,8 +28,6 @@ from zerver.models import ( import datetime class ActivityTest(ZulipTestCase): - - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_activity(self): # type: () -> None self.login(self.example_email("hamlet")) diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py index c95e748918..6fbb9a9b73 100644 --- a/zerver/tests/test_push_notifications.py +++ b/zerver/tests/test_push_notifications.py @@ -131,10 +131,9 @@ class PushBouncerNotificationTest(BouncerTestCase): **self.get_auth()) self.assert_json_error(result, "Invalid token type") - with self.settings(REALMS_HAVE_SUBDOMAINS=True): - result = self.client_post(endpoint, {'user_id': user_id, 'token_kind': token_kind, - 'token': token}, - **self.api_auth(self.example_email("hamlet"))) + result = self.client_post(endpoint, {'user_id': user_id, 'token_kind': token_kind, + 'token': token}, + **self.api_auth(self.example_email("hamlet"))) self.assert_json_error(result, "Account is not associated with this subdomain", status_code=401) diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py index a57301982c..153172df9c 100644 --- a/zerver/tests/test_signup.py +++ b/zerver/tests/test_signup.py @@ -84,7 +84,6 @@ class RedirectAndLogIntoSubdomainTestCase(ZulipTestCase): 'is_signup': True}) class DeactivationNoticeTestCase(ZulipTestCase): - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_redirection_for_deactivated_realm(self): # type: () -> None realm = get_realm("zulip") @@ -96,7 +95,6 @@ class DeactivationNoticeTestCase(ZulipTestCase): self.assertEqual(result.status_code, 302) self.assertIn('deactivated', result.url) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_redirection_for_active_realm(self): # type: () -> None for url in ('/register/', '/login/'): @@ -109,7 +107,6 @@ class DeactivationNoticeTestCase(ZulipTestCase): self.assertEqual(result.status_code, 302) self.assertIn('login', result.url) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_deactivation_notice_when_deactivated(self): # type: () -> None realm = get_realm("zulip") @@ -195,7 +192,6 @@ class PasswordResetTest(ZulipTestCase): # make sure old password no longer works self.login(email, password=old_password, fails=True) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_invalid_subdomain(self): # type: () -> None email = self.example_email("hamlet") @@ -228,7 +224,6 @@ class PasswordResetTest(ZulipTestCase): self.assertIn("hamlet@zulip.com does not\nhave an active account in http://", message.body) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_correct_subdomain(self): # type: () -> None email = self.example_email("hamlet") @@ -293,7 +288,6 @@ class LoginTest(ZulipTestCase): result = self.login_with_return("xxx@zulip.com", "xxx") self.assert_in_response("Please enter a correct email and password", result) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_register(self): # type: () -> None realm = get_realm("zulip") @@ -316,7 +310,6 @@ class LoginTest(ZulipTestCase): self.assertEqual(get_session_dict_user(self.client.session), user_profile.id) self.assertFalse(user_profile.enable_stream_desktop_notifications) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_register_deactivated(self): # type: () -> None """ @@ -335,7 +328,6 @@ class LoginTest(ZulipTestCase): with self.assertRaises(UserProfile.DoesNotExist): self.nonreg_user('test') - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_register_deactivated_partway_through(self): # type: () -> None """ @@ -360,7 +352,6 @@ class LoginTest(ZulipTestCase): with self.assertRaises(UserProfile.DoesNotExist): self.nonreg_user('test') - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_login_deactivated(self): # type: () -> None """ @@ -926,7 +917,6 @@ class MultiuseInviteTest(ZulipTestCase): self.assertEqual(result.status_code, 200) self.assert_in_response("Whoops. The confirmation link is malformed.", result) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_invalid_multiuse_link_in_open_realm(self): # type: () -> None self.realm.invite_required = False @@ -1043,7 +1033,6 @@ class EmailUnsubscribeTests(ZulipTestCase): self.assertEqual(0, ScheduledEmail.objects.filter(user=user_profile).count()) class RealmCreationTest(ZulipTestCase): - def test_create_realm(self): # type: () -> None password = "test" @@ -1127,7 +1116,6 @@ class RealmCreationTest(ZulipTestCase): self.assertEqual(result.status_code, 200) self.assert_in_response('New organization creation disabled.', result) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) @override_settings(OPEN_REALM_CREATION=True) def test_create_realm_with_subdomain(self): # type: () -> None @@ -1174,7 +1162,6 @@ class RealmCreationTest(ZulipTestCase): result = self.client_post('/create_realm/', {'email': "hi@mailinator.com"}) self.assert_in_response('Please use your real email address.', result) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) @override_settings(OPEN_REALM_CREATION=True) def test_subdomain_restrictions(self): # type: () -> None @@ -1468,7 +1455,6 @@ class UserSignUpTest(ZulipTestCase): mock_error.assert_called_once() self.assertEqual(result.status_code, 302) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_failed_signup_due_to_restricted_domain(self): # type: () -> None realm = get_realm('zulip') @@ -1494,7 +1480,6 @@ class UserSignUpTest(ZulipTestCase): self.assertIn("Please request an invite for {} from".format(email), form.errors['email'][0]) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_failed_signup_due_to_nonexistent_realm(self): # type: () -> None request = HostRequestMock(host = 'acme.' + settings.EXTERNAL_HOST) @@ -1693,7 +1678,6 @@ class UserSignUpTest(ZulipTestCase): mock_ldap.reset() mock_initialize.stop() - @override_settings(REALMS_HAVE_SUBDOMAINS=True) @patch('DNS.dnslookup', return_value=[['sipbtest:*:20922:101:Fred Sipb,,,:/mit/sipbtest:/bin/athena/tcsh']]) def test_registration_of_mirror_dummy_user(self, ignored): # type: (Any) -> None @@ -1814,9 +1798,7 @@ class TestLoginPage(ZulipTestCase): def test_login_page_redirects_for_root_alias(self, mock_get_host): # type: (MagicMock) -> None mock_get_host.return_value = 'www.testserver' - with self.settings(REALMS_HAVE_SUBDOMAINS=True, - ROOT_DOMAIN_LANDING_PAGE=True, - ROOT_SUBDOMAIN_ALIASES=['www']): + with self.settings(ROOT_DOMAIN_LANDING_PAGE=True): result = self.client_get("/en/login/") self.assertEqual(result.status_code, 302) self.assertEqual(result.url, '/accounts/find/') @@ -1825,16 +1807,13 @@ class TestLoginPage(ZulipTestCase): def test_login_page_redirects_for_root_domain(self, mock_get_host): # type: (MagicMock) -> None mock_get_host.return_value = 'testserver' - with self.settings(REALMS_HAVE_SUBDOMAINS=True, - ROOT_DOMAIN_LANDING_PAGE=True, - ROOT_SUBDOMAIN_ALIASES=['www']): + with self.settings(ROOT_DOMAIN_LANDING_PAGE=True): result = self.client_get("/en/login/") self.assertEqual(result.status_code, 302) self.assertEqual(result.url, '/accounts/find/') mock_get_host.return_value = 'www.testserver.com' - with self.settings(REALMS_HAVE_SUBDOMAINS=True, - ROOT_DOMAIN_LANDING_PAGE=True, + with self.settings(ROOT_DOMAIN_LANDING_PAGE=True, EXTERNAL_HOST='www.testserver.com', ROOT_SUBDOMAIN_ALIASES=['test']): result = self.client_get("/en/login/") @@ -2048,7 +2027,6 @@ class LoginOrAskForRegistrationTestCase(ZulipTestCase): self.assert_in_response('Please click the following button if ' 'you wish to register', response) - @override_settings(REALMS_HAVE_SUBDOMAINS=True) def test_login_under_subdomains(self): # type: () -> None request = HostRequestMock() diff --git a/zproject/settings.py b/zproject/settings.py index dd6beafa57..798b638b97 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -225,8 +225,8 @@ DEFAULT_SETTINGS.update({ # Whether anyone can create a new organization on the Zulip server. 'OPEN_REALM_CREATION': False, - # Setting for where the system bot users are. Likely will have no - # purpose after the REALMS_HAVE_SUBDOMAINS migration finishes. + # Setting for where the system bot users are. Likely has no + # purpose now that the REALMS_HAVE_SUBDOMAINS migration is finished. 'SYSTEM_ONLY_REALMS': {"zulip"}, # Whether the server is using the Pgroonga full-text search