Skip to content

Commit

Permalink
Fix test for missing authlib
Browse files Browse the repository at this point in the history
  • Loading branch information
V02460 committed Jan 20, 2025
1 parent 6d0b5d0 commit fb2ffff
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions tests/config/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import tempfile
from typing import Callable
from unittest import mock
from unittest.mock import Mock

import yaml
from parameterized import parameterized
Expand All @@ -33,6 +32,11 @@

from tests.config.utils import ConfigFileTestCase

try:
import authlib
except ImportError:
authlib = None

try:
import hiredis
except ImportError:
Expand Down Expand Up @@ -190,14 +194,25 @@ def test_secret_files_existing(
"recaptcha_private_key: 53C237",
"recaptcha_public_key: ¬53C237",
"experimental_features:\n msc3861:\n enabled: true\n client_secret: 53C237",
'experimental_features:\n msc3861:\n enabled: true\n client_auth_method: private_key_jwt\n jwk: {"mock": "mock"}',
*[
"experimental_features:\n"
" msc3861:\n"
" enabled: true\n"
" client_auth_method: private_key_jwt\n"
' jwk: {"mock": "mock"}'
]
* (authlib is not None),
"experimental_features:\n msc3861:\n enabled: true\n admin_token: 53C237",
"form_secret: 53C237",
*["redis:\n enabled: true\n password: 53C237"] * (hiredis is not None),
]
)
@mock.patch("authlib.jose.rfc7517.JsonWebKey.import_key")
def test_no_secrets_in_config(self, config_line: str, _jwkmock: Mock) -> None:
def test_no_secrets_in_config(self, config_line: str) -> None:
if authlib is not None:
patcher = mock.patch("authlib.jose.rfc7517.JsonWebKey.import_key")
self.addCleanup(patcher.stop)
patcher.start()

self.generate_config_and_remove_lines_containing(
["form_secret", "macaroon_secret_key", "registration_shared_secret"]
)
Expand Down

0 comments on commit fb2ffff

Please sign in to comment.