From 72d56d5d5987e7d10b203af4c1b765b621a1b674 Mon Sep 17 00:00:00 2001 From: Mateusz Mandera Date: Sun, 16 Apr 2023 22:32:39 +0200 Subject: [PATCH] auth: Remove Realm.AUTHENTICATION_FLAGS class attribute. With the removal of the authentication_methods bitfield this is now useless and just duplicates AUTH_BACKEND_NAME_MAP keys. --- zerver/models.py | 13 ------------- zerver/tests/test_gitter_importer.py | 11 ++++++++--- zerver/tests/test_urls.py | 5 +++-- zproject/backends.py | 2 +- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/zerver/models.py b/zerver/models.py index 9ba4613035..8a0678ff6c 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -294,19 +294,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub INVITES_STANDARD_REALM_DAILY_MAX = 3000 MESSAGE_VISIBILITY_LIMITED = 10000 - AUTHENTICATION_FLAGS = [ - "Google", - "Email", - "GitHub", - "LDAP", - "Dev", - "RemoteUser", - "AzureAD", - "SAML", - "GitLab", - "Apple", - "OpenID Connect", - ] SUBDOMAIN_FOR_ROOT_DOMAIN = "" WILDCARD_MENTION_THRESHOLD = 15 diff --git a/zerver/tests/test_gitter_importer.py b/zerver/tests/test_gitter_importer.py index 061e46eea2..09aeb1ffac 100644 --- a/zerver/tests/test_gitter_importer.py +++ b/zerver/tests/test_gitter_importer.py @@ -9,8 +9,13 @@ import orjson from zerver.data_import.gitter import do_convert_data, get_usermentions from zerver.lib.import_realm import do_import_realm from zerver.lib.test_classes import ZulipTestCase -from zerver.models import Message, Realm, UserProfile, get_realm -from zproject.backends import GitHubAuthBackend, auth_enabled_helper, github_auth_enabled +from zerver.models import Message, UserProfile, get_realm +from zproject.backends import ( + AUTH_BACKEND_NAME_MAP, + GitHubAuthBackend, + auth_enabled_helper, + github_auth_enabled, +) class GitterImporter(ZulipTestCase): @@ -131,7 +136,7 @@ class GitterImporter(ZulipTestCase): self.assertIsNotNone(message.rendered_content, None) self.assertTrue(github_auth_enabled(realm)) - for auth_backend_name in Realm.AUTHENTICATION_FLAGS: + for auth_backend_name in AUTH_BACKEND_NAME_MAP: if auth_backend_name == GitHubAuthBackend.auth_backend_name: continue diff --git a/zerver/tests/test_urls.py b/zerver/tests/test_urls.py index bb281534a7..c52a7ae8ca 100644 --- a/zerver/tests/test_urls.py +++ b/zerver/tests/test_urls.py @@ -12,8 +12,9 @@ from zerver.lib.url_redirects import ( LANDING_PAGE_REDIRECTS, POLICY_DOCUMENTATION_REDIRECTS, ) -from zerver.models import Realm, Stream +from zerver.models import Stream from zproject import urls +from zproject.backends import AUTH_BACKEND_NAME_MAP class PublicURLTest(ZulipTestCase): @@ -115,7 +116,7 @@ class PublicURLTest(ZulipTestCase): Here we simply sanity-check that all the URLs load correctly. """ - auth_types = [auth.lower() for auth in Realm.AUTHENTICATION_FLAGS] + auth_types = [auth.lower() for auth in AUTH_BACKEND_NAME_MAP] for auth in [ "azuread", "email", diff --git a/zproject/backends.py b/zproject/backends.py index 6b538fba13..ade8e1252d 100644 --- a/zproject/backends.py +++ b/zproject/backends.py @@ -137,7 +137,7 @@ def auth_enabled_helper(backends_to_check: List[str], realm: Optional[Realm]) -> if realm is not None: enabled_method_dict = realm.authentication_methods_dict() else: - enabled_method_dict = {method: True for method in Realm.AUTHENTICATION_FLAGS} + enabled_method_dict = {method: True for method in AUTH_BACKEND_NAME_MAP} pad_method_dict(enabled_method_dict) for supported_backend in supported_auth_backends():