diff --git a/src/openforms/forms/tests/files/vcr_cassettes/ImportZGWAPITests/ImportZGWAPITests.test_import_form_with_zgw_registration_backend_cant_determine_objects_api_group.yaml b/src/openforms/forms/tests/files/vcr_cassettes/ImportZGWAPITests/ImportZGWAPITests.test_import_form_with_zgw_registration_backend_cant_determine_objects_api_group.yaml
new file mode 100644
index 0000000000..565e1ba882
--- /dev/null
+++ b/src/openforms/forms/tests/files/vcr_cassettes/ImportZGWAPITests/ImportZGWAPITests.test_import_form_with_zgw_registration_backend_cant_determine_objects_api_group.yaml
@@ -0,0 +1,176 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate, br
+ Authorization:
+ - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTcwMjAzNywiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.A8XMplId4rR330Oj1ruGK-9HVMz2m9guLm-G7TNb20s
+ 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":"2023-01-01","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.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTcwMjAzNywiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.A8XMplId4rR330Oj1ruGK-9HVMz2m9guLm-G7TNb20s
+ 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","http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400"],"beginObject":"2024-03-19","eindeObject":"2024-07-10"}'
+ headers:
+ API-version:
+ - 1.3.1
+ Allow:
+ - GET, PUT, PATCH, DELETE, HEAD, OPTIONS
+ Content-Length:
+ - '986'
+ Content-Type:
+ - application/json
+ Cross-Origin-Opener-Policy:
+ - same-origin
+ ETag:
+ - '"9b92accfbfdb5c0d2c8d040a5825abfd"'
+ 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.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTcwMjAzOCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.iI2goeNIs-W9S6ITpjRxFlq2trxwCc87bRoynekCz4c
+ 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":"2023-01-01","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.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTczMTcwMjAzOCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.iI2goeNIs-W9S6ITpjRxFlq2trxwCc87bRoynekCz4c
+ 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","http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400"],"beginObject":"2024-03-19","eindeObject":"2024-07-10"}'
+ headers:
+ API-version:
+ - 1.3.1
+ Allow:
+ - GET, PUT, PATCH, DELETE, HEAD, OPTIONS
+ Content-Length:
+ - '986'
+ Content-Type:
+ - application/json
+ Cross-Origin-Opener-Policy:
+ - same-origin
+ ETag:
+ - '"9b92accfbfdb5c0d2c8d040a5825abfd"'
+ Referrer-Policy:
+ - same-origin
+ Vary:
+ - Accept, origin
+ X-Content-Type-Options:
+ - nosniff
+ X-Frame-Options:
+ - DENY
+ status:
+ code: 200
+ message: OK
+version: 1
diff --git a/src/openforms/forms/tests/files/vcr_cassettes/ImportZGWAPITests/ImportZGWAPITests.test_import_form_with_zgw_registration_backend_with_objects_api_group_apply_default.yaml b/src/openforms/forms/tests/files/vcr_cassettes/ImportZGWAPITests/ImportZGWAPITests.test_import_form_with_zgw_registration_backend_with_objects_api_group_apply_default.yaml
new file mode 100644
index 0000000000..ebe80629af
--- /dev/null
+++ b/src/openforms/forms/tests/files/vcr_cassettes/ImportZGWAPITests/ImportZGWAPITests.test_import_form_with_zgw_registration_backend_with_objects_api_group_apply_default.yaml
@@ -0,0 +1,89 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate, br
+ Authorization:
+ - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTcyOTUyMTkwMSwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.Kx29lEhQextaXDK4gn8pvVqMHrY5_P529Suf2ijKwPM
+ 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":"2023-01-01","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.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTcyOTUyMTkwMSwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.Kx29lEhQextaXDK4gn8pvVqMHrY5_P529Suf2ijKwPM
+ 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","http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400"],"beginObject":"2024-03-19","eindeObject":"2024-07-10"}'
+ headers:
+ API-version:
+ - 1.3.1
+ Allow:
+ - GET, PUT, PATCH, DELETE, HEAD, OPTIONS
+ Content-Length:
+ - '986'
+ Content-Type:
+ - application/json
+ Cross-Origin-Opener-Policy:
+ - same-origin
+ ETag:
+ - '"9b92accfbfdb5c0d2c8d040a5825abfd"'
+ Referrer-Policy:
+ - same-origin
+ Vary:
+ - Accept, origin
+ X-Content-Type-Options:
+ - nosniff
+ X-Frame-Options:
+ - DENY
+ status:
+ code: 200
+ message: OK
+version: 1
diff --git a/src/openforms/forms/tests/test_import_export.py b/src/openforms/forms/tests/test_import_export.py
index cadabb0d12..0722b2578e 100644
--- a/src/openforms/forms/tests/test_import_export.py
+++ b/src/openforms/forms/tests/test_import_export.py
@@ -61,13 +61,17 @@ class TempdirMixin:
"""
def setUp(self):
- super().setUp()
+ super().setUp() # pyright: ignore[reportAttributeAccessIssue]
test_dir = Path(tempfile.mkdtemp())
self.filepath = test_dir / "export_test.zip"
- self.addCleanup(lambda: self.filepath.unlink(missing_ok=True))
- self.addCleanup(lambda: rmtree(test_dir, ignore_errors=True))
+ self.addCleanup( # pyright: ignore[reportAttributeAccessIssue]
+ lambda: self.filepath.unlink(missing_ok=True)
+ )
+ self.addCleanup( # pyright: ignore[reportAttributeAccessIssue]
+ lambda: rmtree(test_dir, ignore_errors=True)
+ )
class ImportExportTests(TempdirMixin, TestCase):
@@ -1606,35 +1610,39 @@ class ImportZGWAPITests(TempdirMixin, OFVCRMixin, TestCase):
VCR_TEST_FILES = PATH / "files"
- def test_import_form_with_zgw_registration_backend_no_available_group(self):
-
+ @staticmethod
+ def _create_export(filepath: Path, *backends: dict):
resources = {
"forms": [
{
"active": True,
"name": "Test Form 1",
"internal_name": "Test Form Internal 1",
- "slug": "zgw-no-group",
+ "slug": "zgw-group",
"uuid": "324cadce-a627-4e3f-b117-37ca232f16b2",
- "registration_backends": [
- {
- "key": "test-backend",
- "name": "Test backend",
- "backend": "zgw-create-zaak",
- "options": {
- "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
- "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
- },
- }
- ],
+ "registration_backends": list(backends),
}
]
}
- with zipfile.ZipFile(self.filepath, "w") as zip_file:
+ with zipfile.ZipFile(filepath, "w") as zip_file:
for name, data in resources.items():
zip_file.writestr(f"{name}.json", json.dumps(data))
+ def test_import_form_with_zgw_registration_backend_no_available_group(self):
+ self._create_export(
+ self.filepath,
+ {
+ "key": "test-backend",
+ "name": "Test backend",
+ "backend": "zgw-create-zaak",
+ "options": {
+ "zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
+ "informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ },
+ },
+ )
+
with self.assertRaises(CommandError) as exc:
call_command("import", import_file=self.filepath)
@@ -1644,34 +1652,19 @@ def test_import_form_with_zgw_registration_backend_no_available_group(self):
self.assertEqual(error_detail.code, "invalid")
def test_import_form_with_zgw_registration_backend_available_group(self):
- resources = {
- "forms": [
- {
- "active": True,
- "name": "Test Form 1",
- "internal_name": "Test Form Internal 1",
- "slug": "zgw-group",
- "uuid": "324cadce-a627-4e3f-b117-37ca232f16b2",
- "registration_backends": [
- {
- "key": "test-backend",
- "name": "Test backend",
- "backend": "zgw-create-zaak",
- "options": {
- "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",
- },
- }
- ],
- }
- ]
- }
-
zgw_group = ZGWApiGroupConfigFactory.create(for_test_docker_compose=True)
-
- with zipfile.ZipFile(self.filepath, "w") as zip_file:
- for name, data in resources.items():
- zip_file.writestr(f"{name}.json", json.dumps(data))
+ self._create_export(
+ self.filepath,
+ {
+ "key": "test-backend",
+ "name": "Test backend",
+ "backend": "zgw-create-zaak",
+ "options": {
+ "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",
+ },
+ },
+ )
call_command("import", import_file=self.filepath)
@@ -1681,6 +1674,103 @@ def test_import_form_with_zgw_registration_backend_available_group(self):
zgw_group.pk,
)
+ def test_import_form_with_zgw_registration_backend_with_objects_api_group_apply_default(
+ self,
+ ):
+ """
+ In legacy imports, `options.objects_api_group` was not required, because the plugin
+ always used the ObjectsAPIGroup with the lowest primary key at runtime. Because
+ `options.objects_api_group` has now been made required, this should be injected
+ into the import data to make sure the import still works
+ """
+ objects_api_group = ObjectsAPIGroupConfigFactory.create(
+ for_test_docker_compose=True
+ )
+ ZGWApiGroupConfigFactory.create(for_test_docker_compose=True)
+ self._create_export(
+ self.filepath,
+ {
+ "key": "test-backend",
+ "name": "Test backend",
+ "backend": "zgw-create-zaak",
+ "options": {
+ "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",
+ "objecttype": "http://localhost:8001/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48",
+ "objecttype_version": 1,
+ },
+ },
+ )
+
+ call_command("import", import_file=self.filepath)
+
+ registration_backend = FormRegistrationBackend.objects.get(key="test-backend")
+ self.assertEqual(
+ registration_backend.options["objects_api_group"],
+ objects_api_group.pk,
+ )
+
+ def test_import_form_with_zgw_registration_backend_cant_determine_objects_api_group(
+ self,
+ ):
+ zgw_group = ZGWApiGroupConfigFactory.create(for_test_docker_compose=True)
+
+ with self.subTest("no default group exists"):
+ self._create_export(
+ self.filepath,
+ {
+ "key": "test-backend",
+ "name": "Test backend",
+ "backend": "zgw-create-zaak",
+ "options": {
+ "zgw_api_group": 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",
+ "objecttype": "http://localhost:8001/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48",
+ "objecttype_version": 1,
+ },
+ },
+ )
+
+ with self.assertRaises(CommandError) as exc:
+ call_command("import", import_file=self.filepath)
+
+ error_detail = exc.exception.args[0].detail["registration_backends"][0][
+ "options"
+ ]["objects_api_group"][0]
+ self.assertEqual(error_detail.code, "required")
+
+ with self.subTest("objects API group present in export"):
+ objects_api_group = ObjectsAPIGroupConfigFactory.create(
+ for_test_docker_compose=True
+ )
+ self._create_export(
+ self.filepath,
+ {
+ "key": "test-backend",
+ "name": "Test backend",
+ "backend": "zgw-create-zaak",
+ "options": {
+ "zgw_api_group": 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",
+ "objects_api_group": objects_api_group.pk,
+ "objecttype": "http://localhost:8001/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48",
+ "objecttype_version": 1,
+ },
+ },
+ )
+
+ call_command("import", import_file=self.filepath)
+
+ registration_backend = FormRegistrationBackend.objects.get(
+ key="test-backend"
+ )
+ self.assertEqual(
+ registration_backend.options["objects_api_group"],
+ objects_api_group.pk,
+ )
+
class ImportStUFZDSTests(TempdirMixin, TestCase):
def test_extension_plugin_id_is_converted(self):
diff --git a/src/openforms/forms/utils.py b/src/openforms/forms/utils.py
index 95d09efcb8..121f505690 100644
--- a/src/openforms/forms/utils.py
+++ b/src/openforms/forms/utils.py
@@ -59,7 +59,7 @@ def _get_mock_request():
)
server_name = first_allowed_host if first_allowed_host != "*" else "testserver"
request = factory.get("/", SERVER_NAME=server_name)
- request.is_mock_request = True
+ request.is_mock_request = True # pyright: ignore[reportAttributeAccessIssue]
return request
diff --git a/src/openforms/js/components/admin/form_design/RegistrationFields.stories.js b/src/openforms/js/components/admin/form_design/RegistrationFields.stories.js
index d714bf95d2..189aa648b7 100644
--- a/src/openforms/js/components/admin/form_design/RegistrationFields.stories.js
+++ b/src/openforms/js/components/admin/form_design/RegistrationFields.stories.js
@@ -40,6 +40,10 @@ export default {
enum: ['openbaar', 'geheim'],
enumNames: ['Openbaar', 'Geheim'],
},
+ objectsApiGroup: {
+ enum: [1],
+ enumNames: ['Objects API Group'],
+ },
},
},
},
diff --git a/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsForm.js b/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsForm.js
index e200b9fcea..82954b9982 100644
--- a/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsForm.js
+++ b/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsForm.js
@@ -11,8 +11,12 @@ import ZGWFormFields from './ZGWOptionsFormFields';
const ZGWOptionsForm = ({name, label, schema, formData, onChange}) => {
const validationErrors = useContext(ValidationErrorContext);
- const {zgwApiGroup, zaakVertrouwelijkheidaanduiding} = schema.properties;
+ const {zgwApiGroup, zaakVertrouwelijkheidaanduiding, objectsApiGroup} = schema.properties;
const apiGroupChoices = getChoicesFromSchema(zgwApiGroup.enum, zgwApiGroup.enumNames);
+ const objectsApiGroupChoices = getChoicesFromSchema(
+ objectsApiGroup.enum,
+ objectsApiGroup.enumNames
+ );
const confidentialityLevelChoices = getChoicesFromSchema(
zaakVertrouwelijkheidaanduiding.enum,
zaakVertrouwelijkheidaanduiding.enumNames
@@ -41,6 +45,9 @@ const ZGWOptionsForm = ({name, label, schema, formData, onChange}) => {
zaakVertrouwelijkheidaanduiding: '',
medewerkerRoltype: '',
propertyMappings: [],
+ // Ensure that this is explicitly set to null instead of undefined,
+ // because the field is required by the serializer
+ objectsApiGroup: null,
// saved data, overwrites defaults
...formData,
// Ensure that if there's only one option, it is automatically selected.
@@ -51,6 +58,7 @@ const ZGWOptionsForm = ({name, label, schema, formData, onChange}) => {
@@ -70,6 +78,10 @@ ZGWOptionsForm.propTypes = {
enum: PropTypes.arrayOf(PropTypes.string).isRequired,
enumNames: PropTypes.arrayOf(PropTypes.string).isRequired,
}).isRequired,
+ objectsApiGroup: PropTypes.shape({
+ enum: PropTypes.arrayOf(PropTypes.number).isRequired,
+ enumNames: PropTypes.arrayOf(PropTypes.string).isRequired,
+ }).isRequired,
}).isRequired,
}).isRequired,
formData: PropTypes.shape({
@@ -85,6 +97,7 @@ ZGWOptionsForm.propTypes = {
eigenschap: PropTypes.string,
})
),
+ objectsApiGroup: PropTypes.number,
objecttype: PropTypes.string,
objecttypeVersion: PropTypes.string,
contentJson: PropTypes.string,
diff --git a/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsFormFields.js b/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsFormFields.js
index 69a381bf16..5b022a12d6 100644
--- a/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsFormFields.js
+++ b/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsFormFields.js
@@ -12,6 +12,7 @@ import {
ValidationErrorsProvider,
filterErrors,
} from 'components/admin/forms/ValidationErrors';
+import {ObjectsAPIGroup} from 'components/admin/forms/objects_api';
import BasicOptionsFieldset from './BasicOptionsFieldset';
import ManageVariableToPropertyMappings from './ManageVariableToPropertyMappings';
@@ -25,9 +26,23 @@ import {
OrganisationRSIN,
} from './fields';
-const ZGWFormFields = ({name, apiGroupChoices, confidentialityLevelChoices}) => {
+/**
+ * Callback to invoke when the API group changes - used to reset the dependent fields.
+ */
+const onApiGroupChange = prevValues => ({
+ ...prevValues,
+ objecttype: '',
+ objecttypeVersion: undefined,
+});
+
+const ZGWFormFields = ({
+ name,
+ apiGroupChoices,
+ objectsApiGroupChoices,
+ confidentialityLevelChoices,
+}) => {
const {
- values: {propertyMappings = []},
+ values: {propertyMappings = [], objecttype = ''},
} = useFormikContext();
const validationErrors = useContext(ValidationErrorContext);
const relevantErrors = filterErrors(name, validationErrors);
@@ -112,6 +127,12 @@ const ZGWFormFields = ({name, apiGroupChoices, confidentialityLevelChoices}) =>
collapsible
fieldNames={['objecttype', 'objecttypeVersion', 'contentJson']}
>
+
@@ -137,6 +158,14 @@ ZGWFormFields.propTypes = {
])
)
).isRequired,
+ objectsApiGroupChoices: PropTypes.arrayOf(
+ PropTypes.arrayOf(
+ PropTypes.oneOfType([
+ PropTypes.number, // value
+ PropTypes.string, // label
+ ])
+ )
+ ),
confidentialityLevelChoices: PropTypes.arrayOf(
PropTypes.arrayOf(PropTypes.string) // value & label are both string
).isRequired,
diff --git a/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsFormFields.stories.js b/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsFormFields.stories.js
index 168db28dcd..2eec66b996 100644
--- a/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsFormFields.stories.js
+++ b/src/openforms/js/components/admin/form_design/registrations/zgw/ZGWOptionsFormFields.stories.js
@@ -13,13 +13,14 @@ import {mockCaseTypesGet, mockCataloguesGet} from './mocks';
const NAME = 'form.registrationBackends.0.options';
-const render = ({apiGroups, confidentialityLevelChoices, formData}) => (
+const render = ({apiGroups, objectsApiGroupChoices, confidentialityLevelChoices, formData}) => (
@@ -33,6 +34,7 @@ export default {
render,
args: {
apiGroups: [[1, 'ZGW API']],
+ objectsApiGroupChoices: [[1, 'Objects API']],
confidentialityLevelChoices: [
['openbaar', 'Openbaar'],
['geheim', 'Geheim'],
diff --git a/src/openforms/js/components/admin/forms/objects_api/ObjectsAPIGroup.js b/src/openforms/js/components/admin/forms/objects_api/ObjectsAPIGroup.js
index e155210651..3354714044 100644
--- a/src/openforms/js/components/admin/forms/objects_api/ObjectsAPIGroup.js
+++ b/src/openforms/js/components/admin/forms/objects_api/ObjectsAPIGroup.js
@@ -12,6 +12,8 @@ const ObjectsAPIGroup = ({
onChangeCheck,
name = 'objectsApiGroup',
onApiGroupChange,
+ isClearable = false,
+ required = true,
}) => {
const [{onChange: onChangeFormik, ...fieldProps}, , {setValue}] = useField(name);
const {setValues} = useFormikContext();
@@ -24,11 +26,20 @@ const ObjectsAPIGroup = ({
}, [setValues, onApiGroupChange, value]);
const options = apiGroupChoices.map(([value, label]) => ({value, label}));
+
+ // React doesn't like null/undefined as it leads to uncontrolled component warnings,
+ // so we translate null -> '' and vice versa in the change handler
+ const normalizedValue = value === null ? '' : value;
+ const normalizedOptions = options.map(option => ({
+ ...option,
+ value: option.value === null ? '' : option.value,
+ }));
+
return (
option.value === normalizedValue)}
+ required={required}
onChange={selectedOption => {
const okToProceed = onChangeCheck === undefined || onChangeCheck();
- if (okToProceed) setValue(selectedOption.value);
+ if (okToProceed) {
+ // normalize empty string back to null
+ const newValue = selectedOption ? selectedOption.value : null;
+ setValue(newValue);
+ }
}}
+ isClearable={isClearable}
/>
@@ -91,6 +108,17 @@ ObjectsAPIGroup.propTypes = {
* fire unexpectedly during re-renders.
*/
onApiGroupChange: PropTypes.func,
+
+ /**
+ * Optional boolean to indicate whether or not it should be possible to clear the
+ * select (default `false`)
+ */
+ isClearable: PropTypes.bool,
+
+ /**
+ * Indicate if the field is required or optional.
+ */
+ required: PropTypes.bool,
};
export default ObjectsAPIGroup;
diff --git a/src/openforms/registrations/contrib/zgw_apis/migrations/0015_explicit_objects_api_groups.py b/src/openforms/registrations/contrib/zgw_apis/migrations/0015_explicit_objects_api_groups.py
new file mode 100644
index 0000000000..e4f4fe5726
--- /dev/null
+++ b/src/openforms/registrations/contrib/zgw_apis/migrations/0015_explicit_objects_api_groups.py
@@ -0,0 +1,35 @@
+# Generated by Django 4.2.16 on 2024-10-21 10:23
+
+from django.db import migrations
+
+PLUGIN_ID = "zgw-create-zaak"
+
+
+def define_explicit_objects_api_groups(apps, schema_editor):
+ ObjectsAPIGroupConfig = apps.get_model("objects_api", "ObjectsAPIGroupConfig")
+ FormRegistrationBackend = apps.get_model("forms", "FormRegistrationBackend")
+
+ # Behaviour before the objects API group could be defined explicity: always use the
+ # objects API group with the lowest primary key
+ objects_api_group = ObjectsAPIGroupConfig.objects.order_by("pk").first()
+ objects_api_group_pk = None if objects_api_group is None else objects_api_group.pk
+
+ for backend in FormRegistrationBackend.objects.filter(backend=PLUGIN_ID):
+ group = objects_api_group_pk if backend.options.get("objecttype") else None
+ backend.options["objects_api_group"] = group
+ backend.save()
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("forms", "0001_initial_to_v250"),
+ ("registrations_objects_api", "0016_objectsapigroupconfig"),
+ ("zgw_apis", "0014_zgwapigroupconfig_catalogue_domain_and_more"),
+ ]
+
+ operations = [
+ migrations.RunPython(
+ define_explicit_objects_api_groups, migrations.RunPython.noop
+ )
+ ]
diff --git a/src/openforms/registrations/contrib/zgw_apis/options.py b/src/openforms/registrations/contrib/zgw_apis/options.py
index 2eb6400aae..695c57469f 100644
--- a/src/openforms/registrations/contrib/zgw_apis/options.py
+++ b/src/openforms/registrations/contrib/zgw_apis/options.py
@@ -10,6 +10,7 @@
from zgw_consumers.api_models.constants import VertrouwelijkheidsAanduidingen
from openforms.api.fields import PrimaryKeyRelatedAsChoicesField
+from openforms.contrib.objects_api.models import ObjectsAPIGroupConfig
from openforms.contrib.zgw.clients.catalogi import (
CaseType,
CatalogiClient,
@@ -104,6 +105,15 @@ class ZaakOptionsSerializer(JsonSchemaSerializerMixin, serializers.Serializer):
)
# Objects API
+ objects_api_group = PrimaryKeyRelatedAsChoicesField(
+ queryset=ObjectsAPIGroupConfig.objects.exclude(
+ Q(objects_service=None) | Q(objecttypes_service=None)
+ ),
+ help_text=_("Which Objects API set to use."),
+ label=_("Objects API set"),
+ allow_null=True,
+ default=None,
+ )
objecttype = serializers.URLField(
label=_("objects API - objecttype"),
help_text=_(
@@ -152,7 +162,36 @@ def get_fields(self):
fields["zgw_api_group"].required = False
return fields
+ def _handle_import(self, attrs) -> None:
+ # we're not importing, nothing to do
+ if not self.context.get("is_import", False):
+ return
+
+ # it's already present in some form, nothing to do
+ if "objects_api_group" in self.initial_data:
+ return
+
+ # no objecttype specified, no need to set a group
+ if not attrs.get("objecttype"):
+ return
+
+ # at this point we know there's no api group provided and there *is* an
+ # objecttype specified -> add the default group mimicking the legacy behaviour
+
+ default_group = ObjectsAPIGroupConfig.objects.order_by("pk").first()
+ # can't start making up groups, unfortunately we can only let validation block
+ # the import now :(
+ if default_group is None:
+ return
+
+ # patch up the data and set the default group as explicit option. it could be
+ # the wrong one, which will be caught by downstream configuration and the only
+ # way to resolve this is by fixing the import file
+ attrs["objects_api_group"] = default_group
+
def validate(self, attrs: RegistrationOptions) -> RegistrationOptions:
+ self._handle_import(attrs)
+
# Legacy forms will have zaaktype set, new forms can set case_type_identification.
# Both may be set - in that case, `case_type_identification` is preferred.
if not attrs["case_type_identification"] and not attrs["zaaktype"]:
@@ -188,6 +227,9 @@ def validate(self, attrs: RegistrationOptions) -> RegistrationOptions:
_validate_against_catalogi_api(attrs)
+ if attrs.get("objecttype"):
+ _validate_against_objects_api_group(attrs)
+
return attrs
@@ -245,6 +287,43 @@ def _validate_against_catalogi_api(attrs: RegistrationOptions) -> None:
)
+def _validate_against_objects_api_group(attrs: RegistrationOptions) -> None:
+ """
+ Validate the configuration options against the specified objects API group.
+
+ 1. An `objects_api_group` must be specified
+ 2. The specified `objecttype` must have the same base URL as the defined `objects_api_group.objecttypes_service`
+ """
+ assert "objecttype" in attrs
+
+ objects_api_group = attrs["objects_api_group"]
+ if objects_api_group is None:
+ raise serializers.ValidationError(
+ {
+ "objects_api_group": _(
+ "Objects API group must be specified if an objecttype is specified."
+ )
+ },
+ code="required",
+ )
+
+ # `objecttypes_service` is required on `ObjectsAPIGroup`
+ assert objects_api_group.objecttypes_service
+ if not attrs["objecttype"].startswith(
+ objects_api_group.objecttypes_service.api_root
+ ):
+ raise serializers.ValidationError(
+ {
+ "objecttype": _(
+ "The specified objecttype is not present in the selected "
+ "Objecttypes API (the URL does not start with the API root of "
+ "the Objecttypes API)."
+ )
+ },
+ code="invalid",
+ )
+
+
class _CatalogueAndTypeValidationResult(TypedDict):
catalogue: Catalogus | None
diff --git a/src/openforms/registrations/contrib/zgw_apis/plugin.py b/src/openforms/registrations/contrib/zgw_apis/plugin.py
index 9913f4e870..4739cd2505 100644
--- a/src/openforms/registrations/contrib/zgw_apis/plugin.py
+++ b/src/openforms/registrations/contrib/zgw_apis/plugin.py
@@ -23,7 +23,6 @@
create_attachment_document,
create_report_document,
)
-from openforms.registrations.contrib.objects_api.models import ObjectsAPIGroupConfig
from openforms.submissions.mapping import SKIP, FieldConf, apply_data_mapping
from openforms.submissions.models import Submission, SubmissionReport
from openforms.utils.date import datetime_in_amsterdam
@@ -441,7 +440,8 @@ def register_submission(
# Register submission to Objects API if configured
if (
- (object_type := options.get("objecttype"))
+ options["objects_api_group"]
+ and (object_type := options.get("objecttype"))
and (object_type_version := options.get("objecttype_version"))
and options.get("content_json")
):
@@ -577,10 +577,8 @@ def register_submission_to_objects_api(
submission, object_mapping, REGISTRATION_ATTRIBUTE, record_data
)
- # In a follow up PR: the group will be configurable:
- api_group = ObjectsAPIGroupConfig.objects.order_by("pk").first()
- if not api_group: # pragma: no cover
- raise RegistrationFailed("No API group available at all")
+ api_group = options["objects_api_group"]
+ assert api_group is not None
with get_objects_client(api_group) as objects_client:
response = execute_unless_result_exists(
partial(
diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/OptionsSerializerTests/OptionsSerializerTests.test_validation_objects_api_group_not_null_if_objecttype_is_defined.yaml b/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/OptionsSerializerTests/OptionsSerializerTests.test_validation_objects_api_group_not_null_if_objecttype_is_defined.yaml
new file mode 100644
index 0000000000..6bf1e60e85
--- /dev/null
+++ b/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/OptionsSerializerTests/OptionsSerializerTests.test_validation_objects_api_group_not_null_if_objecttype_is_defined.yaml
@@ -0,0 +1,44 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate, br
+ Authorization:
+ - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTcyOTUyNDUyNCwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.xRLJzlUqbKi8Vj6jMqClyRWvPxoyXXiKKIXr3AVoq5s
+ 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","http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400"],"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:
+ - '985'
+ 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
diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/OptionsSerializerTests/OptionsSerializerTests.test_validation_objecttype_api_root_must_match_objecttypes_service_api_root.yaml b/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/OptionsSerializerTests/OptionsSerializerTests.test_validation_objecttype_api_root_must_match_objecttypes_service_api_root.yaml
new file mode 100644
index 0000000000..3cfd107622
--- /dev/null
+++ b/src/openforms/registrations/contrib/zgw_apis/tests/files/vcr_cassettes/OptionsSerializerTests/OptionsSerializerTests.test_validation_objecttype_api_root_must_match_objecttypes_service_api_root.yaml
@@ -0,0 +1,44 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate, br
+ Authorization:
+ - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0X2NsaWVudF9pZCIsImlhdCI6MTcyOTUyNDY4NiwiY2xpZW50X2lkIjoidGVzdF9jbGllbnRfaWQiLCJ1c2VyX2lkIjoiIiwidXNlcl9yZXByZXNlbnRhdGlvbiI6IiJ9.8SibHZC696ygWjw3AtJt_TIzZ9C-sSHDrou3aze1Esk
+ 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","http://localhost:8003/catalogi/api/v1/zaaktypen/b79d9c2f-5ec4-4e23-bb66-ec6dd959a400"],"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:
+ - '985'
+ 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
diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py b/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py
index 5a39bfc857..1fa721fae8 100644
--- a/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py
+++ b/src/openforms/registrations/contrib/zgw_apis/tests/test_backend.py
@@ -247,6 +247,7 @@ def test_submission_with_zgw_backend_with_natuurlijk_persoon_initiator(self, m):
"organisatie_rsin": "000000000",
"zaak_vertrouwelijkheidaanduiding": "openbaar",
"doc_vertrouwelijkheidaanduiding": "openbaar",
+ "objects_api_group": None,
}
self.install_mocks(m)
@@ -469,6 +470,7 @@ def test_submission_with_zgw_backend_with_vestiging_and_kvk_initiator(self, m):
"organisatie_rsin": "000000000",
"zaak_vertrouwelijkheidaanduiding": "openbaar",
"doc_vertrouwelijkheidaanduiding": "openbaar",
+ "objects_api_group": None,
}
self.install_mocks(m)
@@ -677,6 +679,7 @@ def test_submission_with_zgw_backend_with_kvk_only_initiator(self, m):
"organisatie_rsin": "000000000",
"zaak_vertrouwelijkheidaanduiding": "openbaar",
"doc_vertrouwelijkheidaanduiding": "openbaar",
+ "objects_api_group": None,
}
self.install_mocks(m)
@@ -755,6 +758,7 @@ def test_submission_with_zgw_backend_with_vestiging_initiator_kvk_only(self, m):
"organisatie_rsin": "000000000",
"zaak_vertrouwelijkheidaanduiding": "openbaar",
"doc_vertrouwelijkheidaanduiding": "openbaar",
+ "objects_api_group": None,
}
self.install_mocks(m)
@@ -964,6 +968,7 @@ def test_submission_with_registrator(self, m):
"zaak_vertrouwelijkheidaanduiding": "openbaar",
"doc_vertrouwelijkheidaanduiding": "openbaar",
"medewerker_roltype": "Some description",
+ "objects_api_group": None,
}
self.install_mocks(m)
m.get(
@@ -1037,6 +1042,7 @@ def test_submission_roltype_initiator_not_found(self, m):
"organisatie_rsin": "000000000",
"zaak_vertrouwelijkheidaanduiding": "openbaar",
"doc_vertrouwelijkheidaanduiding": "openbaar",
+ "objects_api_group": None,
}
self.install_mocks(m)
roltypen_url = furl("https://catalogus.nl/api/v1/roltypen").set(
@@ -1074,6 +1080,7 @@ def test_retried_registration_with_internal_reference(self, m):
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
"organisatie_rsin": "000000000",
"vertrouwelijkheidaanduiding": "openbaar",
+ "objects_api_group": None,
},
)
self.install_mocks(m)
@@ -1109,6 +1116,7 @@ def test_register_and_update_paid_product(self, m):
"organisatie_rsin": "000000000",
"zaak_vertrouwelijkheidaanduiding": "openbaar",
"doc_vertrouwelijkheidaanduiding": "openbaar",
+ "objects_api_group": None,
}
self.install_mocks(m)
m.patch(
@@ -1193,6 +1201,7 @@ def test_submission_with_zgw_backend_override_fields(self, m):
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
"organisatie_rsin": "000000000",
"zaak_vertrouwelijkheidaanduiding": "openbaar",
+ "objects_api_group": None,
}
SubmissionFileAttachmentFactory.create(
submission_step=SubmissionStep.objects.first(),
@@ -1300,6 +1309,7 @@ def test_zgw_backend_default_author(self, m):
"case_type_identification": "",
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
}
self.install_mocks(m)
@@ -1372,6 +1382,7 @@ def test_zgw_backend_document_ontvangstdatum(self, m):
"case_type_identification": "",
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
}
self.install_mocks(m)
@@ -1425,6 +1436,7 @@ def test_zgw_backend_defaults_empty_string(self, m):
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
"auteur": "",
+ "objects_api_group": None,
}
self.install_mocks(m)
@@ -1459,6 +1471,7 @@ def test_zgw_backend_unspecified_zaakvertrouwelijkheidaanduiding(self, m):
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
"auteur": "",
"zaak_vertrouwelijkheidaanduiding": "", # type: ignore
+ "objects_api_group": None,
}
self.install_mocks(m)
plugin = ZGWRegistration("zgw")
@@ -1489,6 +1502,7 @@ def test_zgw_backend_has_reference_after_pre_submission(self, m):
"zgw_api_group": self.zgw_group.pk,
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
},
completed_not_preregistered=True,
)
@@ -1517,6 +1531,7 @@ def test_document_size_argument_present(self, m):
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
"organisatie_rsin": "000000000",
"zaak_vertrouwelijkheidaanduiding": "openbaar",
+ "objects_api_group": None,
}
SubmissionFileAttachmentFactory.create(
submission_step=SubmissionStep.objects.first(),
@@ -1583,7 +1598,12 @@ def test_submission_with_zgw_and_objects_api_backends(self, m, obj_api_config):
),
)
+ # unused group
ObjectsAPIGroupConfigFactory.create(
+ objects_service__api_root="https://objecten2.nl/api/v1/",
+ organisatie_rsin="111222333",
+ )
+ objects_api_group = ObjectsAPIGroupConfigFactory.create(
objects_service__api_root="https://objecten.nl/api/v1/",
organisatie_rsin="000000000",
)
@@ -1723,6 +1743,7 @@ def get_create_json_for_zaakobject(req, ctx):
"organisatie_rsin": "000000000",
"zaak_vertrouwelijkheidaanduiding": "openbaar",
"doc_vertrouwelijkheidaanduiding": "openbaar",
+ "objects_api_group": objects_api_group,
"objecttype": "https://objecttypen.nl/api/v1/objecttypes/2",
"objecttype_version": 1,
}
@@ -1838,6 +1859,7 @@ def test_submission_with_multiple_eigenschappen_creation(self, m):
{"component_key": "textField1", "eigenschap": "a property name"},
{"component_key": "textField2", "eigenschap": "second property"},
],
+ "objects_api_group": None,
}
self.install_mocks(m)
@@ -2043,6 +2065,7 @@ def test_submission_with_nested_component_columns_and_eigenschap(self, m):
{"component_key": "textField2", "eigenschap": "second property"},
{"component_key": "textField3.blah", "eigenschap": "third property"},
],
+ "objects_api_group": None,
}
self.install_mocks(m)
@@ -2265,6 +2288,7 @@ def test_zgw_backend_zaak_omschrijving(self, m):
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
"auteur": "",
"zaak_vertrouwelijkheidaanduiding": "", # type: ignore
+ "objects_api_group": None,
}
self.install_mocks(m)
plugin = ZGWRegistration("zgw")
@@ -2290,6 +2314,7 @@ def test_zgw_backend_zaak_omschrijving(self, m):
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
"auteur": "",
"zaak_vertrouwelijkheidaanduiding": "", # type: ignore
+ "objects_api_group": None,
}
self.install_mocks(m)
plugin = ZGWRegistration("zgw")
@@ -2356,6 +2381,7 @@ def test_create_zaak_with_case_identification_reference(self):
"eigenschap": "a property name",
}
],
+ "objects_api_group": None,
}
plugin = ZGWRegistration("zgw")
@@ -2443,6 +2469,7 @@ def test_allow_registration_with_unpublished_case_types(self):
"http://localhost:8003/catalogi/api/v1/"
"informatieobjecttypen/3628d25f-f491-4375-a752-39d16bf2dd59"
),
+ "objects_api_group": None,
}
plugin = ZGWRegistration("zgw")
diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/test_backend_partial_failure.py b/src/openforms/registrations/contrib/zgw_apis/tests/test_backend_partial_failure.py
index 3710655828..ff3f4052f2 100644
--- a/src/openforms/registrations/contrib/zgw_apis/tests/test_backend_partial_failure.py
+++ b/src/openforms/registrations/contrib/zgw_apis/tests/test_backend_partial_failure.py
@@ -65,6 +65,7 @@ def setUpTestData(cls):
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
"organisatie_rsin": "000000000",
"vertrouwelijkheidaanduiding": "openbaar",
+ "objects_api_group": None,
},
completed_not_preregistered=True,
bsn="111222333",
@@ -416,7 +417,7 @@ def test_failure_after_object_creation(self, m, obj_api_config):
}"""
),
)
- ObjectsAPIGroupConfigFactory.create(
+ objects_api_group = ObjectsAPIGroupConfigFactory.create(
objects_service__api_root="https://objecten.nl/api/v1/",
organisatie_rsin="000000000",
)
@@ -507,6 +508,7 @@ def test_failure_after_object_creation(self, m, obj_api_config):
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
"organisatie_rsin": "000000000",
"vertrouwelijkheidaanduiding": "openbaar",
+ "objects_api_group": objects_api_group.pk,
"objecttype": "https://objecttypen.nl/api/v1/objecttypes/2",
"objecttype_version": 1,
},
@@ -693,6 +695,7 @@ def test_failure_after_eigenschappen_retrieval(self, m):
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
"organisatie_rsin": "000000000",
"vertrouwelijkheidaanduiding": "openbaar",
+ "objects_api_group": None,
"property_mappings": [
{"component_key": "textField1", "eigenschap": "a property name"}
],
diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/test_migrations.py b/src/openforms/registrations/contrib/zgw_apis/tests/test_migrations.py
new file mode 100644
index 0000000000..d5acd005b4
--- /dev/null
+++ b/src/openforms/registrations/contrib/zgw_apis/tests/test_migrations.py
@@ -0,0 +1,43 @@
+from django.db.migrations.state import StateApps
+
+from openforms.utils.tests.test_migrations import TestMigrations
+
+
+class MigrateToExplicitObjectsAPIGroupsTests(TestMigrations):
+ app = "zgw_apis"
+ migrate_from = "0014_zgwapigroupconfig_catalogue_domain_and_more"
+ migrate_to = "0015_explicit_objects_api_groups"
+
+ def setUpBeforeMigration(self, apps: StateApps):
+ ObjectsAPIGroupConfig = apps.get_model("objects_api", "ObjectsAPIGroupConfig")
+ Form = apps.get_model("forms", "Form")
+ FormRegistrationBackend = apps.get_model("forms", "FormRegistrationBackend")
+ form1 = Form.objects.create(name="form1")
+ form2 = Form.objects.create(name="form2")
+ self.objects_api_group = ObjectsAPIGroupConfig.objects.create(name="Group 1")
+ ObjectsAPIGroupConfig.objects.create(name="Group 2")
+ self.backend_without_api_group = FormRegistrationBackend.objects.create(
+ form=form1, backend="zgw-create-zaak", options={}
+ )
+ self.backend_with_api_group = FormRegistrationBackend.objects.create(
+ form=form2,
+ backend="zgw-create-zaak",
+ options={"objecttype": "https://objecttypes.com/foo/bar"},
+ )
+
+ def test_set_explicit_objects_api_groups_on_zgw_api_group_configs(self):
+ FormRegistrationBackend = self.apps.get_model(
+ "forms", "FormRegistrationBackend"
+ )
+ backend_without_api_group = FormRegistrationBackend.objects.get(
+ pk=self.backend_without_api_group.pk
+ )
+ backend_with_api_group = FormRegistrationBackend.objects.get(
+ pk=self.backend_with_api_group.pk
+ )
+
+ self.assertIsNone(backend_without_api_group.options["objects_api_group"])
+ self.assertEqual(
+ backend_with_api_group.options["objects_api_group"],
+ self.objects_api_group.pk,
+ )
diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/test_validators.py b/src/openforms/registrations/contrib/zgw_apis/tests/test_validators.py
index e5b24e818c..c4c5e92795 100644
--- a/src/openforms/registrations/contrib/zgw_apis/tests/test_validators.py
+++ b/src/openforms/registrations/contrib/zgw_apis/tests/test_validators.py
@@ -4,6 +4,7 @@
from typing_extensions import deprecated
+from openforms.contrib.objects_api.tests.factories import ObjectsAPIGroupConfigFactory
from openforms.utils.tests.vcr import OFVCRMixin
from ..plugin import ZaakOptionsSerializer
@@ -56,6 +57,7 @@ def test_bad_case_type_document_type_api_roots(self):
"zgw_api_group": self.zgw_group.pk,
"zaaktype": "https://other-host.local/api/v1/zt/123",
"informatieobjecttype": "https://other-host.local/api/v1/iot/456",
+ "objects_api_group": None,
}
serializer = ZaakOptionsSerializer(data=data)
is_valid = serializer.is_valid()
@@ -79,6 +81,7 @@ def test_existing_provided_variable_in_specific_zaaktype(self):
"property_mappings": [
{"component_key": "textField", "eigenschap": "a property name"}
],
+ "objects_api_group": None,
}
serializer = ZaakOptionsSerializer(data=data)
is_valid = serializer.is_valid()
@@ -102,6 +105,7 @@ def test_property_mappings_validated_against_case_type_identification(self):
{"component_key": "textField", "eigenschap": "a property name"},
{"component_key": "textField", "eigenschap": "wrong property name"},
],
+ "objects_api_group": None,
}
serializer = ZaakOptionsSerializer(data=data)
is_valid = serializer.is_valid()
@@ -129,6 +133,7 @@ def test_provided_variable_does_not_exist_in_specific_zaaktype(self):
"property_mappings": [
{"component_key": "textField", "eigenschap": "wrong variable"}
],
+ "objects_api_group": None,
}
serializer = ZaakOptionsSerializer(data=data)
is_valid = serializer.is_valid()
@@ -156,6 +161,7 @@ def test_validate_zaaktype_within_configured_ztc_service(self):
"http://localhost:8003/catalogi/api/v1/"
"informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"
),
+ "objects_api_group": None,
}
serializer = ZaakOptionsSerializer(data=data)
@@ -177,6 +183,7 @@ def test_validate_informatieobjecttype_within_configured_ztc_service(self):
"http://localhost:8003/catalogi/api/v1/"
"informatieobjecttypen/ca5ffa84-3806-4663-a226-f2d163b79643" # bad UUID
),
+ "objects_api_group": None,
}
serializer = ZaakOptionsSerializer(data=data)
@@ -200,6 +207,7 @@ def test_valid_omschrijving(self):
"informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"
),
"medewerker_roltype": "Baliemedewerker",
+ "objects_api_group": None,
}
serializer = ZaakOptionsSerializer(data=data)
@@ -222,6 +230,7 @@ def test_invalid_roltype_omschrijving(self):
"informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"
),
"medewerker_roltype": "Absent roltype",
+ "objects_api_group": None,
}
serializer = ZaakOptionsSerializer(data=data)
@@ -247,6 +256,7 @@ def test_roltype_omschrijving_validated_against_case_type_identification(self):
"http://localhost:8003/catalogi/api/v1/"
"informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"
),
+ "objects_api_group": None,
}
with self.subTest("valid"):
@@ -336,6 +346,7 @@ def test_catalogue_reference_with_api_calls(self):
"http://localhost:8003/catalogi/api/v1/"
"informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"
),
+ "objects_api_group": None,
}
with self.subTest("valid catalogue reference"):
@@ -388,6 +399,7 @@ def test_validation_case_type_document_type_in_catalogue(self):
"http://localhost:8003/catalogi/api/v1/"
"informatieobjecttypen/111111111-97f7-478c-85f0-67d2f23661c7"
),
+ "objects_api_group": None,
}
serializer = ZaakOptionsSerializer(data=data)
@@ -412,6 +424,7 @@ def test_case_type_identification_or_zaaktype_url_required(self):
"http://localhost:8003/catalogi/api/v1/"
"informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"
),
+ "objects_api_group": None,
}
serializer = ZaakOptionsSerializer(data=data)
@@ -430,6 +443,7 @@ def test_catalogue_required_when_case_type_identification_provided(self):
"http://localhost:8003/catalogi/api/v1/"
"informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"
),
+ "objects_api_group": None,
}
serializer = ZaakOptionsSerializer(data=data)
@@ -451,6 +465,7 @@ def test_validate_case_type_exists_when_case_type_identification_is_provided(sel
"http://localhost:8003/catalogi/api/v1/"
"informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7"
),
+ "objects_api_group": None,
}
with self.subTest("case type exists"):
@@ -477,3 +492,62 @@ def test_validate_case_type_exists_when_case_type_identification_is_provided(sel
self.assertIn("case_type_identification", serializer.errors)
err = serializer.errors["case_type_identification"][0]
self.assertEqual(err.code, "not-found")
+
+ def test_validation_objects_api_group_not_null_if_objecttype_is_defined(self):
+ data = {
+ "zgw_api_group": self.zgw_group.pk,
+ "catalogue": {
+ "domain": "TEST",
+ "rsin": "000000000",
+ },
+ "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"
+ ),
+ "objects_api_group": None,
+ "objecttype": "http://localhost:8001/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48",
+ }
+ serializer = ZaakOptionsSerializer(data=data)
+
+ result = serializer.is_valid()
+
+ self.assertFalse(result)
+ self.assertIn("objects_api_group", serializer.errors)
+ err = serializer.errors["objects_api_group"][0]
+ self.assertEqual(err.code, "required")
+
+ def test_validation_objecttype_api_root_must_match_objecttypes_service_api_root(
+ self,
+ ):
+ objects_api_group = ObjectsAPIGroupConfigFactory.create(
+ for_test_docker_compose=True,
+ )
+ data = {
+ "zgw_api_group": self.zgw_group.pk,
+ "catalogue": {
+ "domain": "TEST",
+ "rsin": "000000000",
+ },
+ "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"
+ ),
+ "objects_api_group": objects_api_group.pk,
+ "objecttype": "http://incorrect.domain/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48",
+ }
+ serializer = ZaakOptionsSerializer(data=data)
+
+ result = serializer.is_valid()
+
+ self.assertFalse(result)
+ self.assertIn("objecttype", serializer.errors)
+ err = serializer.errors["objecttype"][0]
+ self.assertEqual(err.code, "invalid")
diff --git a/src/openforms/registrations/contrib/zgw_apis/tests/test_zgw_api_config.py b/src/openforms/registrations/contrib/zgw_apis/tests/test_zgw_api_config.py
index 1c14249db8..38f67cd9ca 100644
--- a/src/openforms/registrations/contrib/zgw_apis/tests/test_zgw_api_config.py
+++ b/src/openforms/registrations/contrib/zgw_apis/tests/test_zgw_api_config.py
@@ -324,6 +324,7 @@ def test_the_right_api_is_used(self, m):
"case_type_identification": "",
"zaaktype": "https://catalogi-2.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi-2.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
}
self.install_mocks(m)
@@ -362,6 +363,7 @@ def test_per_form_overwrites(self, m):
"organisatie_rsin": "000000123",
"zaak_vertrouwelijkheidaanduiding": VertrouwelijkheidsAanduidingen.confidentieel, # type: ignore
"doc_vertrouwelijkheidaanduiding": VertrouwelijkheidsAanduidingen.geheim, # type: ignore
+ "objects_api_group": None,
}
self.install_mocks(m)
@@ -452,6 +454,7 @@ def test_uses_field_overwrites_for_documents(self, m):
"organisatie_rsin": "000000123",
"zaak_vertrouwelijkheidaanduiding": VertrouwelijkheidsAanduidingen.confidentieel, # type: ignore
"doc_vertrouwelijkheidaanduiding": VertrouwelijkheidsAanduidingen.geheim, # type: ignore
+ "objects_api_group": None,
}
self.install_mocks(m)
diff --git a/src/openforms/registrations/contrib/zgw_apis/typing.py b/src/openforms/registrations/contrib/zgw_apis/typing.py
index e2a971ea52..a821320b71 100644
--- a/src/openforms/registrations/contrib/zgw_apis/typing.py
+++ b/src/openforms/registrations/contrib/zgw_apis/typing.py
@@ -3,6 +3,8 @@
from typing import TYPE_CHECKING, Literal, NotRequired, TypedDict
if TYPE_CHECKING:
+ from openforms.contrib.objects_api.models import ObjectsAPIGroupConfig
+
from .models import ZGWApiGroupConfig
@@ -37,6 +39,7 @@ class RegistrationOptions(TypedDict):
organisatie_rsin: NotRequired[str]
zaak_vertrouwelijkheidaanduiding: NotRequired[VertrouwelijkheidAanduiding]
medewerker_roltype: NotRequired[str]
+ objects_api_group: ObjectsAPIGroupConfig | None
objecttype: NotRequired[str]
objecttype_version: NotRequired[int]
content_json: NotRequired[str]
diff --git a/src/openforms/registrations/tests/test_pre_registration.py b/src/openforms/registrations/tests/test_pre_registration.py
index e08afa240d..7b422c8bbc 100644
--- a/src/openforms/registrations/tests/test_pre_registration.py
+++ b/src/openforms/registrations/tests/test_pre_registration.py
@@ -61,6 +61,7 @@ def test_if_preregistration_complete_retry_doesnt_repeat_it(self):
"zgw_api_group": zgw_group.pk,
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
},
completed_not_preregistered=True,
)
@@ -113,6 +114,7 @@ def test_pre_registration_task_errors_but_does_not_raise_error(self):
"zgw_api_group": zgw_group.pk,
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
},
completed_not_preregistered=True,
)
@@ -212,6 +214,7 @@ def test_retry_doesnt_overwrite_internal_reference(self):
"zgw_api_group": zgw_group.pk,
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
},
completed_not_preregistered=True,
)
@@ -247,6 +250,7 @@ def test_retry_keeps_track_of_internal_reference(self):
"zgw_api_group": zgw_group.pk,
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
},
completed_not_preregistered=True,
)
@@ -285,6 +289,7 @@ def test_retry_after_too_many_attempts_skips(self, m_get_solo):
"zgw_api_group": zgw_group.pk,
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
},
completed_not_preregistered=True,
registration_attempts=3,
@@ -318,6 +323,7 @@ def test_update_registration_result_after_pre_registration(self):
"zgw_api_group": zgw_group.pk,
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
},
completed_not_preregistered=True,
)
@@ -345,6 +351,7 @@ def test_traceback_removed_from_result_after_success(self, m_get_solo):
"zgw_api_group": zgw_group.pk,
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
},
completed_not_preregistered=True,
registration_attempts=1,
diff --git a/src/openforms/submissions/tests/test_on_completion_retry_chain.py b/src/openforms/submissions/tests/test_on_completion_retry_chain.py
index de65913e45..73f1953014 100644
--- a/src/openforms/submissions/tests/test_on_completion_retry_chain.py
+++ b/src/openforms/submissions/tests/test_on_completion_retry_chain.py
@@ -44,6 +44,7 @@ def test_payment_status_update_now_succeeds(self):
"zgw_api_group": zgw_group.pk,
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
},
form__payment_backend="ogone-legacy",
registration_result={
@@ -98,6 +99,7 @@ def test_payment_status_update_still_fails(self):
"zgw_api_group": zgw_group.pk,
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
},
form__payment_backend="ogone-legacy",
registration_result={
@@ -163,6 +165,7 @@ def test_backend_registration_still_fails(self, mock_update_payment):
"zgw_api_group": zgw_group.pk,
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
},
# registration failed, so an internal reference was created
public_registration_reference="OF-1234",
@@ -200,6 +203,7 @@ def test_backend_preregistration_still_fails(self, mock_update_payment):
"zgw_api_group": zgw_group.pk,
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
},
# registration failed, so an internal reference was created
public_registration_reference="OF-1234",
@@ -243,6 +247,7 @@ def test_backend_registration_succeeds(self, mock_update_payment):
"zgw_api_group": zgw_group.pk,
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
},
# registration failed, so an internal reference was created
public_registration_reference="OF-1234",
@@ -277,6 +282,7 @@ def test_backend_registration_succeeds(self, mock_update_payment):
"case_type_identification": "",
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
},
)
self.assertNotEqual(submission.last_register_date, original_register_date)
diff --git a/src/openforms/submissions/tests/test_post_submission_event.py b/src/openforms/submissions/tests/test_post_submission_event.py
index 295e395580..69c09ea18f 100644
--- a/src/openforms/submissions/tests/test_post_submission_event.py
+++ b/src/openforms/submissions/tests/test_post_submission_event.py
@@ -1038,6 +1038,7 @@ def test_successful_registration_records_registration_counter_and_date(self):
"zgw_api_group": zgw_group.pk,
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
},
completed=True,
)
@@ -1070,6 +1071,7 @@ def test_preregister_success_and_registration_failure_records_counter_and_date_o
"zgw_api_group": zgw_group.pk,
"zaaktype": "https://catalogi.nl/api/v1/zaaktypen/1",
"informatieobjecttype": "https://catalogi.nl/api/v1/informatieobjecttypen/1",
+ "objects_api_group": None,
},
completed_not_preregistered=True,
)