Skip to content

Commit 5b30e4e

Browse files
authored
chore: upgrade dependencies (#599)
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent ddee212 commit 5b30e4e

34 files changed

Lines changed: 93 additions & 64 deletions

File tree

‎dje/tests/test_two_factor.py‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
from django.urls import reverse
1212

1313
import django_otp
14-
from django_otp.forms import OTPTokenForm
1514
from django_otp.oath import totp as oauth_totp
1615
from django_otp.plugins.otp_totp.models import TOTPDevice
1716

1817
from dje.models import Dataspace
1918
from dje.tests import create_user
19+
from dje.two_factor import TwoFactorDisableForm
20+
from dje.two_factor import TwoFactorVerifyForm
2021

2122

2223
class TwoFactorAuthenticationTestCase(TestCase):
@@ -132,7 +133,7 @@ def test_two_factor_authentication_disable_2fa(self):
132133
response = self.client.post(self.tfa_disable_url, data=data)
133134
self.assertContains(response, "Please enter your OTP token.")
134135

135-
device_form_value = OTPTokenForm.device_choices(self.user)[0][0]
136+
device_form_value = device.persistent_id
136137
data = {"otp_token": "123456", "otp_device": device_form_value}
137138
response = self.client.post(self.tfa_disable_url, data=data)
138139
form_error = "Invalid token. Please make sure you have entered it correctly."
@@ -178,7 +179,7 @@ def test_two_factor_authentication_login_with_2fa(self):
178179
self.assertContains(response, "Please enter your OTP token.")
179180

180181
valid_token = self._get_valid_token(device.bin_key)
181-
device_form_value = OTPTokenForm.device_choices(self.user)[0][0]
182+
device_form_value = device.persistent_id
182183
data = {
183184
"otp_token": valid_token,
184185
"otp_device": device_form_value,
@@ -190,3 +191,12 @@ def test_two_factor_authentication_login_with_2fa(self):
190191
self.assertIn("_auth_user_id", session_keys)
191192
self.assertIn("_auth_user_hash", session_keys)
192193
self.assertIn("otp_device_id", session_keys)
194+
195+
def test_two_factor_authentication_token_form_preselects_user_device(self):
196+
device = self._create_device(self.user)
197+
expected = f'<option value="{device.persistent_id}" selected>default</option>'
198+
199+
for form_class in [TwoFactorDisableForm, TwoFactorVerifyForm]:
200+
form = form_class(user=self.user)
201+
self.assertEqual(device.persistent_id, form.fields["otp_device"].initial)
202+
self.assertInHTML(expected, str(form["otp_device"]))

‎dje/two_factor.py‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,21 @@ def helper(self):
139139
return helper
140140

141141

142-
class TwoFactorDisableForm(OTPTokenForm):
142+
class TwoFactorTokenForm(OTPTokenForm):
143+
"""
144+
Preselect the user device: the `otp_device` select is hidden and its first
145+
choice is blank.
146+
"""
147+
148+
def __init__(self, user, *args, **kwargs):
149+
super().__init__(user, *args, **kwargs)
150+
151+
user_device = next(django_otp.devices_for_user(user), None)
152+
if user_device:
153+
self.fields["otp_device"].initial = user_device.persistent_id
154+
155+
156+
class TwoFactorDisableForm(TwoFactorTokenForm):
143157
@property
144158
def helper(self):
145159
helper = FormHelper()
@@ -168,7 +182,7 @@ def helper(self):
168182
return helper
169183

170184

171-
class TwoFactorVerifyForm(OTPTokenForm):
185+
class TwoFactorVerifyForm(TwoFactorTokenForm):
172186
"""Verify that the user provided `otp_token` is valid."""
173187

174188
@property

‎notification/tests/test_models.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ def test_webhook_subscription_deliver_inactive_returns_false(self, mock_post):
9797
@patch("requests.post")
9898
def test_webhook_subscription_deliver_request_exception_saves_error(self, mock_post):
9999
mock_post.side_effect = req.exceptions.ConnectionError("Connection refused")
100-
delivery = self.webhook.deliver(None, payload_override={"key": "val"})
100+
with self.assertLogs("aboutcode.notifications", level="ERROR") as captured:
101+
delivery = self.webhook.deliver(None, payload_override={"key": "val"})
102+
self.assertEqual(
103+
["Connection refused"], [record.getMessage() for record in captured.records]
104+
)
101105
self.assertIsNotNone(delivery)
102106
self.assertFalse(delivery.delivered)
103107
self.assertIn("Connection refused", delivery.delivery_error)

‎pyproject.toml‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ dependencies = [
3434
"setuptools==84.0.0",
3535
"packaging==26.3",
3636
# Django
37-
"django==6.1.1",
37+
"django==6.1.2",
3838
"asgiref==3.12.1",
3939
"typing-extensions==4.16.0",
4040
"sqlparse==0.6.0",
4141
# Django apps
4242
"django-crispy-forms==2.7",
4343
"crispy-bootstrap5==2026.9",
4444
"django-grappelli==5.0.0",
45-
"django-filter==26.1",
45+
"django-filter==26.2",
4646
"django-registration==5.2.1",
4747
"confusable_homoglyphs==3.3.1",
4848
"django-guardian==3.5.0",
@@ -54,16 +54,18 @@ dependencies = [
5454
"altcha==1.0.0",
5555
"django-altcha==1.0.0",
5656
# REST API
57-
"djangorestframework==3.18.1",
57+
"djangorestframework==3.18.3",
5858
# API documentation
59+
# Do not upgrade: 1.21.17+ requires swagger-spec-validator, which pulls jsonschema,
60+
# referencing, rpds-py, jsonschema-specifications, and importlib-resources.
5961
"drf-yasg==1.21.15",
6062
"uritemplate==4.2.0",
6163
"inflection==0.5.1",
62-
"pytz==2026.4",
64+
"pytz==2026.5",
6365
# Track failed login attempts
6466
"django-axes==8.3.1",
6567
# Multi-factor authentication
66-
"django-otp==1.7.3",
68+
"django-otp==1.7.4",
6769
"qrcode==8.2",
6870
# Database
6971
"psycopg==3.3.6",
@@ -72,20 +74,20 @@ dependencies = [
7274
# Antivirus
7375
"clamd==1.0.2",
7476
# Testing
75-
"model-bakery==1.24.1",
77+
"model-bakery==1.24.2",
7678
# Task queue
7779
"rq==2.12.0",
7880
"croniter==6.2.4",
7981
"django-rq==4.2.0",
80-
"fakeredis==2.38.0",
82+
"fakeredis==2.39.0",
8183
# Libs
8284
"certifi==2026.7.22",
8385
"urllib3==2.8.0",
8486
"python-dateutil==2.9.0.post0",
8587
"six==1.17.0",
8688
"requests==2.34.2",
8789
"idna==3.20",
88-
"charset-normalizer==3.5.1",
90+
"charset-normalizer==3.5.2",
8991
"PyYAML==6.0.3",
9092
"XlsxWriter==3.2.9",
9193
# Markdown
@@ -111,7 +113,7 @@ dependencies = [
111113
"attrs==26.1.0",
112114
"click==8.5.0",
113115
"Jinja2==3.1.6",
114-
"MarkupSafe==3.0.3",
116+
"markupsafe==3.0.4",
115117
"saneyaml==0.6.1",
116118
"openpyxl==3.1.5",
117119
"et-xmlfile==2.0.0",
@@ -124,14 +126,14 @@ dependencies = [
124126
"sortedcontainers==2.4.0",
125127
"py-serializable==2.1.0",
126128
# CSAF
127-
"pydantic==2.13.5",
128-
"pydantic-core==2.46.5",
129+
"pydantic==2.14.1",
130+
"pydantic-core==2.50.1",
129131
"typing-inspection==0.4.4",
130132
"annotated-types==0.8.0",
131133
# OpenVEX
132-
"msgspec==0.21.1",
134+
"msgspec==0.22.0",
133135
# OpenDocument Format
134-
"odfdo==3.26.3",
136+
"odfdo==3.27.1",
135137
"lxml==6.1.3",
136138
]
137139

Binary file not shown.
Binary file not shown.
8.03 MB
Binary file not shown.
91.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)