Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

settings: Extract unnecessary test specific settings.

Zixuan James Li1d7abb3f5da1
diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.py
index b4101ccd5f5..09eb8fb1e66 100644
--- a/zerver/tests/test_auth_backends.py
+++ b/zerver/tests/test_auth_backends.py
@@ -156,10 +156,16 @@ from zproject.backends import (
saml_auth_enabled,
sync_user_from_ldap,
)
+from zproject.config import get_from_file_if_exists
if TYPE_CHECKING:
from django.test.client import _MonkeyPatchedWSGIResponse as TestHttpResponse
+APPLE_ID_TOKEN_GENERATION_KEY = get_from_file_if_exists(
+ "zerver/tests/fixtures/apple/token_gen_private_key"
+)
+EXAMPLE_JWK = get_from_file_if_exists("zerver/tests/fixtures/example_jwk")
+
class AuthBackendTest(ZulipTestCase):
def get_email(self) -> str:
@@ -2957,7 +2963,7 @@ class AppleAuthMixin:
payload["aud"] = audience
headers = {"kid": "SOMEKID"}
- private_key = settings.APPLE_ID_TOKEN_GENERATION_KEY
+ private_key = APPLE_ID_TOKEN_GENERATION_KEY
id_token = jwt.encode(payload, private_key, algorithm="RS256", headers=headers)
@@ -3011,7 +3017,7 @@ class AppleIdAuthBackendTest(AppleAuthMixin, SocialAuthBase):
requests_mock.GET,
self.BACKEND_CLASS.JWK_URL,
status=200,
- json=json.loads(settings.EXAMPLE_JWK),
+ json=json.loads(EXAMPLE_JWK),
)
def generate_access_token_url_payload(self, account_data_dict: Dict[str, str]) -> str:
@@ -3209,7 +3215,7 @@ class AppleAuthBackendNativeFlowTest(AppleAuthMixin, SocialAuthBase):
requests_mock.GET,
self.BACKEND_CLASS.JWK_URL,
status=200,
- json=json.loads(settings.EXAMPLE_JWK),
+ json=json.loads(EXAMPLE_JWK),
)
yield
@@ -3386,7 +3392,7 @@ class GenericOpenIdConnectTest(SocialAuthBase):
requests_mock.GET,
self.JWKS_URL,
status=200,
- json=json.loads(settings.EXAMPLE_JWK),
+ json=json.loads(EXAMPLE_JWK),
)
def generate_access_token_url_payload(self, account_data_dict: Dict[str, str]) -> str:
diff --git a/zproject/test_extra_settings.py b/zproject/test_extra_settings.py
index 02b80376cfd..fa9bcac9cf9 100644
--- a/zproject/test_extra_settings.py
+++ b/zproject/test_extra_settings.py
@@ -185,10 +185,6 @@ SOCIAL_AUTH_APPLE_KEY = "KEYISKEY"
SOCIAL_AUTH_APPLE_TEAM = "TEAMSTRING"
SOCIAL_AUTH_APPLE_SECRET = get_from_file_if_exists("zerver/tests/fixtures/apple/private_key.pem")
-EXAMPLE_JWK = get_from_file_if_exists("zerver/tests/fixtures/example_jwk")
-APPLE_ID_TOKEN_GENERATION_KEY = get_from_file_if_exists(
- "zerver/tests/fixtures/apple/token_gen_private_key"
-)
SOCIAL_AUTH_OIDC_ENABLED_IDPS: Dict[str, OIDCIdPConfigDict] = {
"testoidc": {