Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ [#1915] Use regular logout endpoint for eHerkenning logout #903

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/eherkenning/mock/eherkenning_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from eherkenning.mock.views.eherkenning import (
eHerkenningAssertionConsumerServiceMockView,
eHerkenningLoginMockView,
eHerkenningLogoutMockView,
)

"""
Expand All @@ -15,5 +14,4 @@
urlpatterns = (
path("login/", eHerkenningLoginMockView.as_view(), name="login"),
path("acs/", eHerkenningAssertionConsumerServiceMockView.as_view(), name="acs"),
path("logout/", eHerkenningLogoutMockView.as_view(), name="logout"),
)
6 changes: 0 additions & 6 deletions src/eherkenning/mock/views/eherkenning.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from django.conf import settings
from django.contrib import auth, messages
from django.contrib.auth.views import LogoutView
from django.http import HttpResponseBadRequest, HttpResponseRedirect
from django.shortcuts import resolve_url
from django.urls import reverse
Expand Down Expand Up @@ -101,8 +100,3 @@ def get(self, request):
auth.login(request, user)

return HttpResponseRedirect(self.get_success_url())


class eHerkenningLogoutMockView(LogoutView):
# in the future we can render a custom template to emulate eHerkenning logout page
pass
17 changes: 1 addition & 16 deletions src/eherkenning/tests/test_mock_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.contrib.auth import get_user_model
from django.test import TestCase, modify_settings, override_settings
from django.urls import reverse, reverse_lazy
from django.urls import reverse

from furl import furl

Expand Down Expand Up @@ -166,18 +166,3 @@ def test_post_redirect_retains_acs_querystring_params(self):
self.assertRedirects(
response, str(expected_redirect), fetch_redirect_response=False
)


@override_settings(**OVERRIDE_SETTINGS)
@modify_settings(**MODIFY_SETTINGS)
class LogoutViewTests(TestCase):
def test_logout(self):
User = get_user_model()
user = User.objects.create_user(email="testuser@localhost", password="test")
self.client.force_login(user)

url = reverse("eherkenning:logout")
response = self.client.get(url)

self.assertEqual(response.status_code, 302)
self.assertFalse("_auth_user_id" in self.client.session)
2 changes: 1 addition & 1 deletion src/open_inwoner/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def get_logout_url(self) -> str:
elif self.login_type == LoginTypeChoices.eherkenning:
if OpenIDConnectEHerkenningConfig.get_solo().enabled:
return reverse("eherkenning_oidc:logout")
return reverse("eherkenning:logout")
return reverse("logout")

def get_contact_update_url(self):
return reverse("profile:contact_edit", kwargs={"uuid": self.uuid})
Expand Down
2 changes: 1 addition & 1 deletion src/open_inwoner/accounts/tests/test_profile_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_show_correct_logout_button_for_login_type_eherkenning(self, mock_solo):
logout_url = (
reverse("eherkenning_oidc:logout")
if oidc_enabled
else reverse("eherkenning:logout")
else reverse("logout")
)

response = self.app.get(self.url, user=self.eherkenning_user)
Expand Down
Loading