Skip to content

Commit

Permalink
Merge pull request #1392 from open-zaak/issue/978-visible-auth-compon…
Browse files Browse the repository at this point in the history
…ents

Autorisarties visible without existing zaaktypen and iotypen
  • Loading branch information
annashamray committed Jul 10, 2023
2 parents ba3e621 + ca66064 commit b926b19
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/openzaak/components/autorisaties/admin_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ def get_initial_for_component(
autorisatie
)

# if spec is created but no records exist
# we need to add the spec here
if spec and spec.max_vertrouwelijkheidaanduiding not in grouped_by_va:
grouped_by_va[spec.max_vertrouwelijkheidaanduiding] = []

for va, _autorisaties in grouped_by_va.items():
_initial = {"vertrouwelijkheidaanduiding": va}
relevant_ids = {
Expand Down Expand Up @@ -141,6 +146,11 @@ def get_initial_for_component(
autorisatie
)

# if spec is created but no records exist
# we need to add the spec here
if spec and spec.max_vertrouwelijkheidaanduiding not in grouped_by_va:
grouped_by_va[spec.max_vertrouwelijkheidaanduiding] = []

for va, _autorisaties in grouped_by_va.items():
_initial = {"vertrouwelijkheidaanduiding": va}
relevant_ids = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ def test_add_autorisatie_overlap_without_types(self):
)

@tag("gh-1080")
def test_autorisaties_visible_even_if_only_a_spec_exists(self):
def test_autorisaties_visible_even_if_only_a_spec_exists_brc(self):
"""
Assert that the initial form data contains autorisatiespecs if only the spec exists.
Expand All @@ -920,6 +920,58 @@ def test_autorisaties_visible_even_if_only_a_spec_exists(self):
)
self.assertEqual(form_data["values"]["scopes"], ["besluiten.lezen"])

def test_autorisaties_visible_even_if_only_a_spec_exists_zrc(self):
"""
Assert that the initial form data contains autorisatiespecs if only the spec exists.
Regression test for Github issue #978.
"""
AutorisatieSpecFactory.create(
applicatie=self.applicatie,
component=ComponentTypes.zrc,
scopes=["zaken.lezen"],
)

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

self.assertEqual(response.status_code, 200)
initial_data = response.context["formdata"]
self.assertEqual(len(initial_data), 2) # 1 form, 1 empty form
form_data = initial_data[0]

self.assertEqual(form_data["values"]["component"], ComponentTypes.zrc)
self.assertEqual(
form_data["values"]["related_type_selection"],
RelatedTypeSelectionMethods.all_current_and_future,
)
self.assertEqual(form_data["values"]["scopes"], ["zaken.lezen"])

def test_autorisaties_visible_even_if_only_a_spec_exists_drc(self):
"""
Assert that the initial form data contains autorisatiespecs if only the spec exists.
Regression test for Github issue #978.
"""
AutorisatieSpecFactory.create(
applicatie=self.applicatie,
component=ComponentTypes.drc,
scopes=["documenten.lezen"],
)

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

self.assertEqual(response.status_code, 200)
initial_data = response.context["formdata"]
self.assertEqual(len(initial_data), 2) # 1 form, 1 empty form
form_data = initial_data[0]

self.assertEqual(form_data["values"]["component"], ComponentTypes.drc)
self.assertEqual(
form_data["values"]["related_type_selection"],
RelatedTypeSelectionMethods.all_current_and_future,
)
self.assertEqual(form_data["values"]["scopes"], ["documenten.lezen"])

@tag("gh-1081")
def test_remove_iotype_with_autorisaties_linked(self):
"""
Expand Down

0 comments on commit b926b19

Please sign in to comment.