Skip to content

Commit 6cebabc

Browse files
committed
fix: bugs in the minimal deploy environment
1 parent a64fd85 commit 6cebabc

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

.env

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ SECRET_KEY=a-very-secret-key-for-testing-vipps
55

66
# We'll use this to create the admin user inside the container
77
DJANGO_SUPERUSER_EMAIL=[email protected]
8-
DJANGO_SUPERUSER_PASSWORD=a-strong-password
8+
DJANGO_SUPERUSER_PASSWORD=a-strong-password
9+
10+
# Defines the public domain for the test application
11+
TEST_APP_DOMAIN=https://test.portara.no

tests/settings.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
# tests/settings.py
2+
import os
3+
4+
# Read the public domain from the .env file
5+
TEST_APP_DOMAIN = os.getenv("TEST_APP_DOMAIN", "http://127.0.0.1:8000")
6+
7+
# We point it to the same callback URL that the standard web flow uses.
8+
VIPPS_API_CALLBACK_URL = f"{TEST_APP_DOMAIN}/accounts/vipps/login/callback/"
29

310
SECRET_KEY = "dummy-key-for-testing-2fA9dAtV7v2uwPC$SV&%ZQdss^ia@4^&"
411

tests/urls.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,34 @@
11
# tests/urls.py
2-
2+
from django.contrib import admin
33
from django.urls import path, include
4+
from django.conf import settings
45
from dj_rest_auth.registration.views import SocialLoginView
56
from allauth.socialaccount.providers.oauth2.client import OAuth2Client
67

78
# Import the adapters we need
89
from vipps_auth.views import VippsOAuth2Adapter
9-
from allauth.socialaccount.providers.google.views import GoogleOAuth2Adapter
10-
1110

1211
# --- The Vipps View (Subclassing is Required) ---
1312
class VippsLogin(SocialLoginView):
1413
adapter_class = VippsOAuth2Adapter
1514
client_class = OAuth2Client
16-
callback_url = "http://localhost/callback/vipps"
17-
18-
# --- The Google View (Subclassing is Required) ---
19-
class GoogleLogin(SocialLoginView):
20-
adapter_class = GoogleOAuth2Adapter
21-
client_class = OAuth2Client
22-
callback_url = "http://localhost/callback/google"
15+
callback_url = settings.VIPPS_API_CALLBACK_URL
2316

2417

2518
urlpatterns = [
19+
# This makes the admin panel available at /admin/
20+
path("admin/", admin.site.urls),
21+
2622
# Vipps API endpoint using the required subclass
2723
path(
2824
"api/v1/auth/social/vipps/",
2925
VippsLogin.as_view(),
3026
name="vipps_login_api"
3127
),
32-
33-
# Google API endpoint using the required subclass
34-
path(
35-
"api/v1/auth/social/google/",
36-
GoogleLogin.as_view(),
37-
name="google_login_api"
38-
),
3928

4029
# Browser-flow URLs from our package
4130
path("accounts/", include("vipps_auth.urls")),
31+
32+
# Also include allauth's standard URLs for completeness
33+
path('accounts/', include('allauth.urls')),
4234
]

0 commit comments

Comments
 (0)