Skip to content

Commit

Permalink
✅ [#4606] Test catalogue reference validation
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed Aug 21, 2024
1 parent bfd451d commit f1dbcdf
Show file tree
Hide file tree
Showing 3 changed files with 315 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate, br
Authorization:
- Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTcyNDE2NTk5OSwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.-ct9GFk7N1EH3bjUGRx8Yt0BJuLwrf-v01veAlUXEgA
Connection:
- keep-alive
User-Agent:
- python-requests/2.32.2
method: GET
uri: http://localhost:8003/catalogi/api/v1/catalogussen?domein=TEST&rsin=000000000
response:
body:
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
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
catalog","versie":"","begindatumVersie":null}]}'
headers:
API-version:
- 1.3.1
Allow:
- GET, POST, HEAD, OPTIONS
Content-Length:
- '898'
Content-Type:
- application/json
Cross-Origin-Opener-Policy:
- same-origin
Referrer-Policy:
- same-origin
Vary:
- Accept, origin
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate, br
Authorization:
- Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTcyNDE2NTk5OSwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.-ct9GFk7N1EH3bjUGRx8Yt0BJuLwrf-v01veAlUXEgA
Connection:
- keep-alive
User-Agent:
- python-requests/2.32.2
method: GET
uri: http://localhost:8003/catalogi/api/v1/catalogussen?domein=NOOPE&rsin=000000000
response:
body:
string: '{"count":0,"next":null,"previous":null,"results":[]}'
headers:
API-version:
- 1.3.1
Allow:
- GET, POST, HEAD, OPTIONS
Content-Length:
- '52'
Content-Type:
- application/json
Cross-Origin-Opener-Policy:
- same-origin
Referrer-Policy:
- same-origin
Vary:
- Accept, origin
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
status:
code: 200
message: OK
version: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate, br
Authorization:
- Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTcyNDE2NTk5OSwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.-ct9GFk7N1EH3bjUGRx8Yt0BJuLwrf-v01veAlUXEgA
Connection:
- keep-alive
User-Agent:
- python-requests/2.32.2
method: GET
uri: http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc
response:
body:
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
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":[]}'
headers:
API-version:
- 1.3.1
Allow:
- GET, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Length:
- '1918'
Content-Type:
- application/json
Cross-Origin-Opener-Policy:
- same-origin
ETag:
- '"4b7814375796d28f29fea94ee27127b8"'
Referrer-Policy:
- same-origin
Vary:
- Accept, origin
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate, br
Authorization:
- Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTcyNDE2NTk5OSwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.-ct9GFk7N1EH3bjUGRx8Yt0BJuLwrf-v01veAlUXEgA
Connection:
- keep-alive
User-Agent:
- python-requests/2.32.2
method: GET
uri: http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7
response:
body:
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
Informatieobjecttype","vertrouwelijkheidaanduiding":"openbaar","beginGeldigheid":"2024-03-19","eindeGeldigheid":"2024-07-10","concept":false,"besluittypen":[],"informatieobjectcategorie":"Test
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"}'
headers:
API-version:
- 1.3.1
Allow:
- GET, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Length:
- '899'
Content-Type:
- application/json
Cross-Origin-Opener-Policy:
- same-origin
ETag:
- '"cf350f1b55d7eb0ccd17cceb88c1c6c8"'
Referrer-Policy:
- same-origin
Vary:
- Accept, origin
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate, br
Authorization:
- Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTcyNDE2NTk5OSwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.-ct9GFk7N1EH3bjUGRx8Yt0BJuLwrf-v01veAlUXEgA
Connection:
- keep-alive
User-Agent:
- python-requests/2.32.2
method: GET
uri: http://localhost:8003/catalogi/api/v1/roltypen?zaaktype=http%3A%2F%2Flocalhost%3A8003%2Fcatalogi%2Fapi%2Fv1%2Fzaaktypen%2F1f41885e-23fc-4462-bbc8-80be4ae484dc
response:
body:
string: '{"count":2,"next":null,"previous":null,"results":[{"url":"http://localhost:8003/catalogi/api/v1/roltypen/7f1887e8-bf22-47e7-ae52-ed6848d7e70e","zaaktype":"http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc","zaaktypeIdentificatie":"ZT-001","omschrijving":"Baliemedewerker","omschrijvingGeneriek":"klantcontacter","catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","beginGeldigheid":null,"eindeGeldigheid":null,"beginObject":null,"eindeObject":null},{"url":"http://localhost:8003/catalogi/api/v1/roltypen/43e8026c-8abd-4b29-8a4c-ac2a37bc6f5b","zaaktype":"http://localhost:8003/catalogi/api/v1/zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc","zaaktypeIdentificatie":"ZT-001","omschrijving":"Initiator","omschrijvingGeneriek":"initiator","catalogus":"http://localhost:8003/catalogi/api/v1/catalogussen/bd58635c-793e-446d-a7e0-460d7b04829d","beginGeldigheid":null,"eindeGeldigheid":null,"beginObject":null,"eindeObject":null}]}'
headers:
API-version:
- 1.3.1
Allow:
- GET, POST, HEAD, OPTIONS
Content-Length:
- '1008'
Content-Type:
- application/json
Cross-Origin-Opener-Policy:
- same-origin
Referrer-Policy:
- same-origin
Vary:
- Accept, origin
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
status:
code: 200
message: OK
version: 1
103 changes: 102 additions & 1 deletion src/openforms/registrations/contrib/zgw_apis/tests/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def test_valid_omschrijving(self):
self.assertTrue(is_valid)

@override_settings(LANGUAGE_CODE="en")
def test_invalid_omschrijving(self):
def test_invalid_roltype_omschrijving(self):
data = {
"zgw_api_group": self.zgw_group.pk,
"zaaktype": (
Expand All @@ -198,3 +198,104 @@ def test_invalid_omschrijving(self):
"Could not find a roltype with this description related to the zaaktype.",
serializer.errors["medewerker_roltype"][0],
)

def test_catalogue_reference_badly_formatted_data(self):
base = {
"zgw_api_group": self.zgw_group.pk,
"zaaktype": (
"http://localhost:8003/catalogi/api/v1/"
"zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc"
),
"informatieobjecttype": (
"http://localhost:8003/catalogi/api/v1/"
"informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"
),
}

with self.subTest("domain without rsin"):
serializer = ZaakOptionsSerializer(
data={**base, "catalogue": {"domain": "TEST"}},
)

valid = serializer.is_valid()

self.assertFalse(valid)
self.assertIn("catalogue", serializer.errors)
error = serializer.errors["catalogue"]["non_field_errors"][0]
self.assertIn("domain", error)
self.assertIn("rsin", error)

with self.subTest("rsin without domain"):
serializer = ZaakOptionsSerializer(
data={**base, "catalogue": {"rsin": "123456782"}}
)

valid = serializer.is_valid()

self.assertFalse(valid)
self.assertIn("catalogue", serializer.errors)
error = serializer.errors["catalogue"]["non_field_errors"][0]
self.assertIn("domain", error)
self.assertIn("rsin", error)

with self.subTest("invalid RSIN"):
serializer = ZaakOptionsSerializer(
data={
"catalogue": {
"domain": "ok",
"rsin": "AAAAAAAAA",
}
}
)

valid = serializer.is_valid()

self.assertFalse(valid)
self.assertIn("catalogue", serializer.errors)
self.assertIn("rsin", serializer.errors["catalogue"])

def test_catalogue_reference_with_api_calls(self):
base = {
"zgw_api_group": self.zgw_group.pk,
"zaaktype": (
"http://localhost:8003/catalogi/api/v1/"
"zaaktypen/1f41885e-23fc-4462-bbc8-80be4ae484dc"
),
"informatieobjecttype": (
"http://localhost:8003/catalogi/api/v1/"
"informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"
),
}

with self.subTest("valid catalogue reference"):
serializer1 = ZaakOptionsSerializer(
data={
**base,
"catalogue": {
"domain": "TEST",
"rsin": "000000000",
},
}
)

valid1 = serializer1.is_valid()

self.assertTrue(valid1)

with self.subTest("invalid catalogus reference"):
serializer2 = ZaakOptionsSerializer(
data={
**base,
"catalogue": {
"domain": "NOOPE",
"rsin": "000000000",
},
}
)

valid2 = serializer2.is_valid()

self.assertFalse(valid2)
self.assertIn("catalogue", serializer2.errors)
err = serializer2.errors["catalogue"][0]
self.assertEqual(err.code, "invalid-catalogue")

0 comments on commit f1dbcdf

Please sign in to comment.