Skip to content

Commit

Permalink
[#2932] Skip KVK branch selection if vestigingsnummer already in session
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Schilling committed Dec 12, 2024
1 parent bb00825 commit b4a51f2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/eherkenning/mock/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class eHerkenningBackend(BaseBackend):
}
)

# TODO: update mock to test retrieval/storage of vestigingsnummer

def get_or_create_user(self, request, kvk):
created = False
try:
Expand Down
1 change: 1 addition & 0 deletions src/open_inwoner/accounts/tests/test_oidc_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Literal
from unittest.mock import patch

from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.exceptions import ValidationError
from django.test import TestCase, modify_settings, override_settings
Expand Down
18 changes: 18 additions & 0 deletions src/open_inwoner/kvk/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,24 @@ def test_get_branches_page_one_branch_found_sets_branch_check_done(
# Following redirect should not result in endless redirect
self.assertEqual(response.status_code, 200)

def test_get_branches_page_skips_if_vestigingsnummer_present(self):
session = self.client.session
session[KVK_BRANCH_SESSION_VARIABLE] = "12345678"
session.save()

self.client.force_login(user=self.user)

response = self.client.get(self.url)

self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, reverse("pages-root"))
self.assertEqual(kvk_branch_selected_done(self.client.session), True)

response = self.client.get(response.url)

# Following redirect should not result in endless redirect
self.assertEqual(response.status_code, 200)

@patch("open_inwoner.kvk.client.KvKClient.get_all_company_branches")
@patch(
"open_inwoner.kvk.models.KvKConfig.get_solo",
Expand Down

0 comments on commit b4a51f2

Please sign in to comment.