Skip to content

Commit 37a1e8c

Browse files
✅ [#4606] Test that case type/document type are validated against catalogue
When a catalogue is specified, the case/document type URLs need to be validated not only against the ztc_service configured on the API group, but they also must be members of the specified catalogue. This makes the transition to dynamic resolution smoother.
1 parent f1dbcdf commit 37a1e8c

File tree

3 files changed

+126
-7
lines changed

3 files changed

+126
-7
lines changed

src/openforms/forms/tests/files/vcr_cassettes/ImportZGWAPITests/ImportZGWAPITests.test_import_form_with_zgw_registration_backend_available_group.yaml

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,74 @@ interactions:
77
Accept-Encoding:
88
- gzip, deflate, br
99
Authorization:
10-
- Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTcyMDE2MTMxMSwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9._MrNDZLUpU_8efeRtwbP2r_vwPJPLfHMSrPzvVvFhlE
10+
- Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTcyNDIyNjc2OSwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.K_xu7c4tKgy_6gDE8RX1t-gEwJv3F7TFMCeYqiAU664
1111
Connection:
1212
- keep-alive
1313
User-Agent:
1414
- python-requests/2.32.2
1515
method: GET
16-
uri: http://localhost:8003/catalogi/api/v1/catalogussen
16+
uri: http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc
1717
response:
1818
body:
19-
string: '{"count":1,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","domein":"TEST","rsin":"000000000","contactpersoonBeheerNaam":"Test
20-
name","contactpersoonBeheerTelefoonnummer":"","contactpersoonBeheerEmailadres":"","zaaktypen":["http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc"],"besluittypen":[],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/7a474713-0833-402a-8441-e467c08ac55b","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/b2d83b94-9b9b-4e80-a82f-73ff993c62f3","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"],"naam":"Test
21-
catalog","versie":"","begindatumVersie":null}]}'
19+
string: '{"url":"http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc","identificatie":"ZT-001","omschrijving":"Test","omschrijvingGeneriek":"","vertrouwelijkheidaanduiding":"intern","doel":"testen","aanleiding":"integratietests","toelichting":"","indicatieInternOfExtern":"intern","handelingInitiator":"Formulier
20+
indienen","onderwerp":"Testformulier","handelingBehandelaar":"Controleren","doorlooptijd":"P1D","servicenorm":null,"opschortingEnAanhoudingMogelijk":false,"verlengingMogelijk":false,"verlengingstermijn":null,"trefwoorden":[],"publicatieIndicatie":false,"publicatietekst":"","verantwoordingsrelatie":[],"productenOfDiensten":[],"selectielijstProcestype":"https://selectielijst.openzaak.nl/api/v1/procestypen/aa8aa2fd-b9c6-4e34-9a6c-58a677f60ea0","referentieproces":{"naam":"Testen","link":""},"concept":false,"verantwoordelijke":"Ontwikkelaar","beginGeldigheid":"2024-03-26","eindeGeldigheid":null,"versiedatum":"2024-03-26","beginObject":"2024-03-26","eindeObject":null,"catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","statustypen":["http://localhost:8003/catalogi/api/v1/statustypen/1de05b57-a938-47e4-b808-f129c6406b60","http://localhost:8003/catalogi/api/v1/statustypen/6443ac1a-04a1-4335-9db2-5f3c998dbb34"],"resultaattypen":["http://localhost:8003/catalogi/api/v1/resultaattypen/65b7cedd-5729-41bd-b9c7-1f51d7583340"],"eigenschappen":["http://localhost:8003/catalogi/api/v1/eigenschappen/b659caed-e39e-47e3-ac51-bc8bd2ad797e"],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"],"roltypen":["http://localhost:8003/catalogi/api/v1/roltypen/43e8026c-8abd-4b29-8a4c-ac2a37bc6f5b","http://localhost:8003/catalogi/api/v1/roltypen/7f1887e8-bf22-47e7-ae52-ed6848d7e70e"],"besluittypen":[],"deelzaaktypen":[],"gerelateerdeZaaktypen":[],"zaakobjecttypen":[]}'
2221
headers:
2322
API-version:
2423
- 1.3.1
2524
Allow:
26-
- GET, POST, HEAD, OPTIONS
25+
- GET, PUT, PATCH, DELETE, HEAD, OPTIONS
2726
Content-Length:
28-
- '799'
27+
- '1918'
2928
Content-Type:
3029
- application/json
3130
Cross-Origin-Opener-Policy:
3231
- same-origin
32+
ETag:
33+
- '"4b7814375796d28f29fea94ee27127b8"'
34+
Referrer-Policy:
35+
- same-origin
36+
Vary:
37+
- Accept, origin
38+
X-Content-Type-Options:
39+
- nosniff
40+
X-Frame-Options:
41+
- DENY
42+
status:
43+
code: 200
44+
message: OK
45+
- request:
46+
body: null
47+
headers:
48+
Accept:
49+
- '*/*'
50+
Accept-Encoding:
51+
- gzip, deflate, br
52+
Authorization:
53+
- Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTcyNDIyNjc2OSwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.K_xu7c4tKgy_6gDE8RX1t-gEwJv3F7TFMCeYqiAU664
54+
Connection:
55+
- keep-alive
56+
User-Agent:
57+
- python-requests/2.32.2
58+
method: GET
59+
uri: http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7
60+
response:
61+
body:
62+
string: '{"url":"http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7","catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","omschrijving":"Attachment
63+
Informatieobjecttype","vertrouwelijkheidaanduiding":"openbaar","beginGeldigheid":"2024-03-19","eindeGeldigheid":"2024-07-10","concept":false,"besluittypen":[],"informatieobjectcategorie":"Test
64+
category","trefwoord":[],"omschrijvingGeneriek":{"informatieobjecttypeOmschrijvingGeneriek":"","definitieInformatieobjecttypeOmschrijvingGeneriek":"","herkomstInformatieobjecttypeOmschrijvingGeneriek":"","hierarchieInformatieobjecttypeOmschrijvingGeneriek":"","opmerkingInformatieobjecttypeOmschrijvingGeneriek":""},"zaaktypen":["http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc"],"beginObject":"2024-03-19","eindeObject":"2024-07-10"}'
65+
headers:
66+
API-version:
67+
- 1.3.1
68+
Allow:
69+
- GET, PUT, PATCH, DELETE, HEAD, OPTIONS
70+
Content-Length:
71+
- '899'
72+
Content-Type:
73+
- application/json
74+
Cross-Origin-Opener-Policy:
75+
- same-origin
76+
ETag:
77+
- '"cf350f1b55d7eb0ccd17cceb88c1c6c8"'
3378
Referrer-Policy:
3479
- same-origin
3580
Vary:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- '*/*'
7+
Accept-Encoding:
8+
- gzip, deflate, br
9+
Authorization:
10+
- Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTcyNDE2NjM5NywiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.iMGXMHx8RrBkbuy35NRm2F-FWe-SL0PCEG1PmGMl-p0
11+
Connection:
12+
- keep-alive
13+
User-Agent:
14+
- python-requests/2.32.2
15+
method: GET
16+
uri: http://localhost:8003/catalogi/api/v1/catalogussen?domein=TEST&rsin=000000000
17+
response:
18+
body:
19+
string: '{"count":1,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","domein":"TEST","rsin":"000000000","contactpersoonBeheerNaam":"Test
20+
name","contactpersoonBeheerTelefoonnummer":"","contactpersoonBeheerEmailadres":"","zaaktypen":["http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc"],"besluittypen":[],"informatieobjecttypen":["http://localhost:8003/catalogi/api/v1/informatieobjecttypen/7a474713-0833-402a-8441-e467c08ac55b","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/b2d83b94-9b9b-4e80-a82f-73ff993c62f3","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7","http://localhost:8003/catalogi/api/v1/informatieobjecttypen/29b63e5c-3835-4f68-8fad-f2aea9ae6b71"],"naam":"Test
21+
catalog","versie":"","begindatumVersie":null}]}'
22+
headers:
23+
API-version:
24+
- 1.3.1
25+
Allow:
26+
- GET, POST, HEAD, OPTIONS
27+
Content-Length:
28+
- '898'
29+
Content-Type:
30+
- application/json
31+
Cross-Origin-Opener-Policy:
32+
- same-origin
33+
Referrer-Policy:
34+
- same-origin
35+
Vary:
36+
- Accept, origin
37+
X-Content-Type-Options:
38+
- nosniff
39+
X-Frame-Options:
40+
- DENY
41+
status:
42+
code: 200
43+
message: OK
44+
version: 1

src/openforms/registrations/contrib/zgw_apis/tests/test_validators.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,33 @@ def test_catalogue_reference_with_api_calls(self):
299299
self.assertIn("catalogue", serializer2.errors)
300300
err = serializer2.errors["catalogue"][0]
301301
self.assertEqual(err.code, "invalid-catalogue")
302+
303+
def test_validation_case_type_document_type_in_catalogue(self):
304+
data = {
305+
"zgw_api_group": self.zgw_group.pk,
306+
"catalogue": {
307+
"domain": "TEST",
308+
"rsin": "000000000",
309+
},
310+
# Bad UUIDs, they don't exist in the API, so they're definitely not members
311+
# of the catalogue resource
312+
"zaaktype": (
313+
"http://localhost:8003/catalogi/api/v1/"
314+
"zaaktypen/111111111-23fc-4462-bbc8-80be4ae484dc"
315+
),
316+
"informatieobjecttype": (
317+
"http://localhost:8003/catalogi/api/v1/"
318+
"informatieobjecttypen/111111111-97f7-478c-85f0-67d2f23661c7"
319+
),
320+
}
321+
serializer = ZaakOptionsSerializer(data=data)
322+
323+
result = serializer.is_valid()
324+
325+
self.assertFalse(result)
326+
self.assertIn("zaaktype", serializer.errors)
327+
err = serializer.errors["zaaktype"][0]
328+
self.assertEqual(err.code, "not-found")
329+
self.assertIn("informatieobjecttype", serializer.errors)
330+
err = serializer.errors["informatieobjecttype"][0]
331+
self.assertEqual(err.code, "not-found")

0 commit comments

Comments
 (0)