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.
This commit is contained in:
Mateusz Mandera 2023-04-16 22:32:39 +02:00 committed by Tim Abbott
parent ffa3aa8487
commit 72d56d5d59
4 changed files with 12 additions and 19 deletions

View File

@ -294,19 +294,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
INVITES_STANDARD_REALM_DAILY_MAX = 3000 INVITES_STANDARD_REALM_DAILY_MAX = 3000
MESSAGE_VISIBILITY_LIMITED = 10000 MESSAGE_VISIBILITY_LIMITED = 10000
AUTHENTICATION_FLAGS = [
"Google",
"Email",
"GitHub",
"LDAP",
"Dev",
"RemoteUser",
"AzureAD",
"SAML",
"GitLab",
"Apple",
"OpenID Connect",
]
SUBDOMAIN_FOR_ROOT_DOMAIN = "" SUBDOMAIN_FOR_ROOT_DOMAIN = ""
WILDCARD_MENTION_THRESHOLD = 15 WILDCARD_MENTION_THRESHOLD = 15

View File

@ -9,8 +9,13 @@ import orjson
from zerver.data_import.gitter import do_convert_data, get_usermentions from zerver.data_import.gitter import do_convert_data, get_usermentions
from zerver.lib.import_realm import do_import_realm from zerver.lib.import_realm import do_import_realm
from zerver.lib.test_classes import ZulipTestCase from zerver.lib.test_classes import ZulipTestCase
from zerver.models import Message, Realm, UserProfile, get_realm from zerver.models import Message, UserProfile, get_realm
from zproject.backends import GitHubAuthBackend, auth_enabled_helper, github_auth_enabled from zproject.backends import (
AUTH_BACKEND_NAME_MAP,
GitHubAuthBackend,
auth_enabled_helper,
github_auth_enabled,
)
class GitterImporter(ZulipTestCase): class GitterImporter(ZulipTestCase):
@ -131,7 +136,7 @@ class GitterImporter(ZulipTestCase):
self.assertIsNotNone(message.rendered_content, None) self.assertIsNotNone(message.rendered_content, None)
self.assertTrue(github_auth_enabled(realm)) 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: if auth_backend_name == GitHubAuthBackend.auth_backend_name:
continue continue

View File

@ -12,8 +12,9 @@ from zerver.lib.url_redirects import (
LANDING_PAGE_REDIRECTS, LANDING_PAGE_REDIRECTS,
POLICY_DOCUMENTATION_REDIRECTS, POLICY_DOCUMENTATION_REDIRECTS,
) )
from zerver.models import Realm, Stream from zerver.models import Stream
from zproject import urls from zproject import urls
from zproject.backends import AUTH_BACKEND_NAME_MAP
class PublicURLTest(ZulipTestCase): class PublicURLTest(ZulipTestCase):
@ -115,7 +116,7 @@ class PublicURLTest(ZulipTestCase):
Here we simply sanity-check that all the URLs load Here we simply sanity-check that all the URLs load
correctly. 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 [ for auth in [
"azuread", "azuread",
"email", "email",

View File

@ -137,7 +137,7 @@ def auth_enabled_helper(backends_to_check: List[str], realm: Optional[Realm]) ->
if realm is not None: if realm is not None:
enabled_method_dict = realm.authentication_methods_dict() enabled_method_dict = realm.authentication_methods_dict()
else: 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) pad_method_dict(enabled_method_dict)
for supported_backend in supported_auth_backends(): for supported_backend in supported_auth_backends():