Skip to content

Commit f180294

Browse files
committed
Reduce scope of changes
1 parent 5d1ccd5 commit f180294

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

ansible_base/jwt_consumer/common/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from cryptography.hazmat.primitives import hashes, serialization
88
from cryptography.hazmat.primitives.asymmetric import padding
99

10-
from ansible_base.jwt_consumer.common.cert import JWTCert, JWTCertException
1110
from ansible_base.lib.utils.settings import get_setting
1211

1312
logger = logging.getLogger('ansible_base.jwt_consumer.common.util')
@@ -32,6 +31,8 @@ def generate_x_trusted_proxy_header(key: str) -> str:
3231

3332

3433
def validate_x_trusted_proxy_header(header_value: str, ignore_cache=False) -> bool:
34+
from ansible_base.jwt_consumer.common.cert import JWTCert, JWTCertException
35+
3536
try:
3637
cert = JWTCert()
3738
cert.get_decryption_key(ignore_cache=ignore_cache)

ansible_base/lib/templatetags/requests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def is_proxied_request():
1111
# Auto-register when imported in Django context
1212
try:
1313
from django import template
14+
1415
register = template.Library()
1516
register.simple_tag(is_proxied_request)
1617
except ImportError:

ansible_base/lib/utils/create_system_user.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,5 @@ def get_system_username() -> Tuple[Optional[str], str]:
6868

6969
from django.core.exceptions import ImproperlyConfigured
7070
from django.utils.translation import gettext as _
71+
7172
raise ImproperlyConfigured(_("Setting %(setting_name)s needs to be a string not a %(type)s") % {'setting_name': setting_name, 'type': type(value)})

test_app/tests/lib/utils/test_requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def test_get_remote_hosts_alternate_headers_behind_trusted_proxy(rsa_keypair):
103103
assert remote_hosts == ['5.6.7.8', '9.10.11.12', '5.6.7.8', 'a.b.c.d']
104104

105105

106-
@mock.patch("ansible_base.lib.utils.requests.validate_x_trusted_proxy_header", side_effect=Exception)
106+
@mock.patch("ansible_base.jwt_consumer.common.util.validate_x_trusted_proxy_header", side_effect=Exception)
107107
def test_get_remote_hosts_validate_trusted_proxy_header_exception(mock_validate: mock.MagicMock, rsa_keypair, caplog):
108108
with override_settings(ANSIBLE_BASE_JWT_KEY=rsa_keypair.public):
109109
headers = {

0 commit comments

Comments
 (0)