Skip to content

Commit aa2a2e3

Browse files
authored
Merge pull request #134 from maykinmedia/issue/127-Lazy-LOGIN_URL-breaks-rosettas-login-URL-functionality
🐛 #127 Fix: Lazy LOGIN_URL breaks rosetta's login URL functionality
2 parents d3f7dc0 + 4c673b9 commit aa2a2e3

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

open_api_framework/conf/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,7 @@
564564
help_text="For how long, in seconds, the session cookie will be valid.",
565565
)
566566

567-
568-
LOGIN_URL = reverse_lazy("admin:login")
567+
LOGIN_URL = "admin:login"
569568
LOGIN_REDIRECT_URL = reverse_lazy("admin:index")
570569
LOGOUT_REDIRECT_URL = reverse_lazy("admin:index")
571570

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ tests = [
7575
"black",
7676
"flake8",
7777
"factory-boy",
78+
"django-rosetta",
79+
"django-webtest"
7880
]
7981
coverage = [
8082
"pytest-cov",

testapp/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
),
2929
auto_display_default=False,
3030
)
31+
STATIC_URL = "/static/"
32+
LOGIN_URL = "admin:login"
3133

3234
USE_TZ = config("USE_TZ", True, add_to_docs=False)
3335

@@ -47,6 +49,7 @@
4749
"open_api_framework",
4850
"sessionprofile",
4951
"testapp",
52+
"rosetta",
5053
]
5154

5255
MIDDLEWARE = [

tests/test_settings.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
1+
from django.conf import settings
2+
from django.urls import reverse
3+
4+
import requests_mock
5+
from django_webtest import WebTest
6+
7+
18
def test_sentry_settings():
29
"""
310
test that sentry settings are initialized
411
"""
5-
from django.conf import settings
612

713
assert hasattr(settings, "SENTRY_CONFIG") is True
814
assert hasattr(settings, "SENTRY_DSN") is True
15+
16+
17+
@requests_mock.Mocker()
18+
class RosettaTests(WebTest):
19+
def test_rosetta_redirect_fails_with_lazy_login_url(self, m):
20+
response = self.app.get("/admin/rosetta/files/project/")
21+
22+
expected_login_url = (
23+
reverse(settings.LOGIN_URL) + "?next=/admin/rosetta/files/project/"
24+
)
25+
self.assertEqual(response.status_code, 302)
26+
self.assertEqual(response.location, expected_login_url)

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ extras =
2626
tests
2727
coverage
2828
deps =
29+
django-rosetta
30+
django-webtest
2931
django42: Django~=4.2.0
3032
django51: Django~=5.1.0
3133
commands =

0 commit comments

Comments
 (0)