Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tonial committed Sep 3, 2024
1 parent a5d2e07 commit f1da2b1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
API_DATADOG_API_KEY = "abcde"
API_DATADOG_APPLICATION_KEY = "fghij"

ADD_TEST_URLS = True

if os.getenv("DEBUG_SQL_SNAPSHOT"):
# Mandatory to have detailed stacktrace inside templates
TEMPLATES[0]["OPTIONS"]["debug"] = True # noqa: F405
3 changes: 3 additions & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,7 @@
urlpatterns = [path("__debug__/", include(debug_toolbar.urls))] + urlpatterns


if getattr(settings, "ADD_TEST_URLS", False):
urlpatterns.append(path("tests/inclusion_connect/", include("tests.openid_connect.inclusion_connect.urls")))

handler500 = server_error
3 changes: 2 additions & 1 deletion tests/openid_connect/inclusion_connect/test.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from functools import wraps

from django.conf import settings
from django.test import override_settings

from itou.openid_connect.inclusion_connect import constants
from tests.utils.test import TestCase, reload_module


TEST_SETTINGS = {
"INCLUSION_CONNECT_BASE_URL": "https://inclusion.connect.fake",
"INCLUSION_CONNECT_BASE_URL": f"{settings.ITOU_PROTOCOL}://{settings.ITOU_FQDN}/tests/inclusion_connect",
"INCLUSION_CONNECT_CLIENT_ID": "IC_CLIENT_ID_123",
"INCLUSION_CONNECT_CLIENT_SECRET": "IC_CLIENT_SECRET_123",
}
Expand Down
14 changes: 14 additions & 0 deletions tests/openid_connect/inclusion_connect/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.http import HttpResponseRedirect
from django.urls import path


def logout(request):
post_logout_redirect_uri = request.GET.get("post_logout_redirect_uri")
return HttpResponseRedirect(post_logout_redirect_uri)

Check warning

Code scanning / CodeQL

URL redirection from remote source Medium test

Untrusted URL redirection depends on a
user-provided value
.


app_name = "test_inclusion_connect"

urlpatterns = [
path("auth/logout/", logout, name="logout"),
]
15 changes: 14 additions & 1 deletion tests/www/invitations_views/test_company_accept.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from django.shortcuts import reverse
from django.utils.html import escape

from itou.openid_connect.inclusion_connect import constants
from itou.users.enums import KIND_EMPLOYER, UserKind
from itou.users.models import User
from itou.utils.perms.company import get_current_company_or_404
Expand Down Expand Up @@ -338,7 +339,19 @@ def test_accept_new_user_to_inactive_siae(self):
next_url=next_url,
)
# Follow the redirection.
response = self.client.get(response.url, follow=True)
# respose.url = /invitations/uuid/join-company
response = self.client.get(response.url)
# respose.url = /welcoming_tour/index'
response = self.client.get(response.url)
# respose.url = /accounts/logout/?forced=True
response = self.client.get(response.url)
# respose.url = /inclusion_connect/logout?token=123456'
response = self.client.get(response.url)
# respose.url = 'http://localhost:8000/tests/inclusion_connect/auth/logout/...'
response = self.client.get(response.url)
# respose.url should be http://localhost/search/employers
response = self.client.get(response.url)
assert response.status_code == 200
self.assertContains(response, escape("Cette structure n'est plus active."))
user = User.objects.get(email=invitation.email)
assert user.company_set.count() == 0
Expand Down

0 comments on commit f1da2b1

Please sign in to comment.