From d92b3138d9f7b795bf54f0e62fa07594ca339a71 Mon Sep 17 00:00:00 2001 From: Viktor van Wijk Date: Mon, 20 Jan 2025 15:47:39 +0100 Subject: [PATCH] :white_check_mark: [#4980] Update tests In the JSON dump docker app, explicitly load the received data before sending again. This prevents the data from being interpreted as a string instead of a JSON object. --- docker/json-dump/app.py | 5 +- src/openforms/formio/components/utils.py | 1 + .../tests/test_component_json_schemas.py | 21 ++-- .../forms/tests/test_form_to_json_schema.py | 114 +++++++++++++++++- .../registrations/contrib/json_dump/plugin.py | 7 +- ...ervice_returns_unexpected_status_code.yaml | 19 +-- ...ckendTests.test_multiple_file_uploads.yaml | 41 ++++--- ...NDumpBackendTests.test_no_file_upload.yaml | 34 +++--- ...ent_with_form_variable_as_data_source.yaml | 47 ++++++++ ...ty_if_select_boxes_component_unfilled.yaml | 50 ++++++++ ...ent_with_form_variable_as_data_source.yaml | 55 +++++++++ ...ed_is_empty_when_no_data_is_submitted.yaml | 52 ++++++++ ...ent_with_form_variable_as_data_source.yaml | 49 ++++++++ ...ckendTests.test_submission_happy_flow.yaml | 46 ++++--- .../contrib/json_dump/tests/test_backend.py | 65 +++++++--- 15 files changed, 504 insertions(+), 102 deletions(-) create mode 100644 src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_radio_component_with_form_variable_as_data_source.yaml create mode 100644 src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_required_in_schema_is_empty_if_select_boxes_component_unfilled.yaml create mode 100644 src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_select_boxes_component_with_form_variable_as_data_source.yaml create mode 100644 src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_select_boxes_schema_required_is_empty_when_no_data_is_submitted.yaml create mode 100644 src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_select_component_with_form_variable_as_data_source.yaml diff --git a/docker/json-dump/app.py b/docker/json-dump/app.py index e2e8b08bcb..abcb3069e3 100644 --- a/docker/json-dump/app.py +++ b/docker/json-dump/app.py @@ -1,5 +1,6 @@ -from flask import Flask, jsonify, request +import json +from flask import Flask, jsonify, request app = Flask(__name__) @@ -8,7 +9,7 @@ def json_plugin_post(): data = request.get_json() message = "No data" if data is None else "Data received" - return jsonify({"message": message, "data": data}), 201 + return jsonify({"message": message, "data": json.loads(data)}), 201 @app.route("/test_connection", methods=["GET"]) diff --git a/src/openforms/formio/components/utils.py b/src/openforms/formio/components/utils.py index c5b80f23e7..d2dad97b2b 100644 --- a/src/openforms/formio/components/utils.py +++ b/src/openforms/formio/components/utils.py @@ -4,6 +4,7 @@ from ..typing import Component + def _normalize_pattern(pattern: str) -> str: """ Normalize a regex pattern so that it matches from beginning to the end of the value. diff --git a/src/openforms/formio/tests/test_component_json_schemas.py b/src/openforms/formio/tests/test_component_json_schemas.py index d44cfb4eb6..a883a1cede 100644 --- a/src/openforms/formio/tests/test_component_json_schemas.py +++ b/src/openforms/formio/tests/test_component_json_schemas.py @@ -33,6 +33,7 @@ from openforms.formio.typing import ( AddressNLComponent, Component, + ContentComponent, DateComponent, DatetimeComponent, EditGridComponent, @@ -80,7 +81,7 @@ def test_checkbox(self): def test_content(self): component_class = Content - component = { + component: ContentComponent = { "label": "Content", "key": "content", "html": "ASDF", @@ -303,13 +304,14 @@ def test_postcode(self): class RadioTests(TestCase): def test_manual_data_source(self): - component = { + component: RadioComponent = { "label": "Radio label", "key": "radio", "values": [ {"label": "A", "value": "a"}, {"label": "B", "value": "b"}, ], + "type": "radio", } expected_schema = { @@ -321,13 +323,14 @@ def test_manual_data_source(self): self.assertEqual(expected_schema, schema) def test_data_source_is_another_form_variable(self): - component = { + component: RadioComponent = { "label": "Radio label", "key": "radio", "values": [ {"label": "", "value": ""}, ], "openForms": {"dataSrc": "variable"}, + "type": "radio", } expected_schema = {"title": "Radio label", "type": "string"} @@ -339,7 +342,7 @@ def test_data_source_is_another_form_variable(self): class SelectTests(TestCase): def test_manual_data_source(self): - component = { + component: SelectComponent = { "label": "Select label", "key": "select", "data": { @@ -369,7 +372,7 @@ def test_manual_data_source(self): self.assertEqual(schema, expected_schema) def test_data_source_is_another_form_variable(self): - component = { + component: SelectComponent = { "label": "Select label", "key": "select", "data": { @@ -397,13 +400,14 @@ def test_data_source_is_another_form_variable(self): class SelectBoxesTests(TestCase): def test_manual_data_source(self): - component = { + component: SelectBoxesComponent = { "label": "Select boxes label", "key": "selectBoxes", "values": [ {"label": "A", "value": "a"}, {"label": "B", "value": "b"}, - ] + ], + "type": "selectboxes", } expected_schema = { @@ -420,13 +424,14 @@ def test_manual_data_source(self): self.assertEqual(schema, expected_schema) def test_data_source_is_another_form_variable(self): - component = { + component: SelectBoxesComponent = { "label": "Select boxes label", "key": "selectBoxes", "values": [ {"label": "", "value": ""}, ], "openForms": {"dataSrc": "variable"}, + "type": "selectboxes", } expected_schema = { diff --git a/src/openforms/forms/tests/test_form_to_json_schema.py b/src/openforms/forms/tests/test_form_to_json_schema.py index 99262eba83..b1f1b6bbde 100644 --- a/src/openforms/forms/tests/test_form_to_json_schema.py +++ b/src/openforms/forms/tests/test_form_to_json_schema.py @@ -4,12 +4,18 @@ FormDefinitionFactory, FormFactory, FormStepFactory, + FormVariableFactory, ) -from openforms.forms.utils import form_variables_to_json_schema +from openforms.forms.utils import ( + form_variables_to_json_schema, + get_json_schema_from_form_variable, + is_form_variable_required, +) +from openforms.variables.constants import FormVariableDataTypes, FormVariableSources class FormToJsonSchemaTestCase(TestCase): - def test_form_to_json_schema(self): + def test_correct_variables_included_in_schema(self): form = FormFactory.create() form_def_1 = FormDefinitionFactory.create( configuration={ @@ -59,16 +65,26 @@ def test_form_to_json_schema(self): ] } ) - form_step_1 = FormStepFactory.create(form=form, form_definition=form_def_1) + FormStepFactory.create(form=form, form_definition=form_def_1) form_def_2 = FormDefinitionFactory.create( configuration={ "components": [ - {"key": "file", "type": "file", "label": "File"}, + { + "key": "file", + "type": "file", + "label": "File", + "validate": {"required": True}, + }, + { + "key": "notIncluded", + "type": "textfield", + "label": "Not included text field", + }, ] } ) - form_step_2 = FormStepFactory.create(form=form, form_definition=form_def_2) + FormStepFactory.create(form=form, form_definition=form_def_2) vars_to_include = ( "firstName", @@ -81,3 +97,91 @@ def test_form_to_json_schema(self): "today", ) schema = form_variables_to_json_schema(form, vars_to_include) + + self.assertEqual(set(schema["properties"]), set(vars_to_include)) + self.assertEqual(schema["required"], ["auth_bsn", "today", "file"]) + + +class TestGetJsonSchemaFromFormVariableTests(TestCase): + + def test_component(self): + form = FormFactory.create() + form_def = FormDefinitionFactory.create( + configuration={ + "components": [ + { + "key": "textfield", + "type": "textfield", + "label": "Foo", + "source": FormVariableSources.component, + }, + ] + } + ) + FormStepFactory.create(form=form, form_definition=form_def) + + var = form_def.formvariable_set.first() + schema = get_json_schema_from_form_variable(var) + + expected_schema = {"title": "Foo", "type": "string"} + self.assertEqual(schema, expected_schema) + + def test_user_defined(self): + var = FormVariableFactory.create( + name="Foo", + key="foo", + source=FormVariableSources.user_defined, + data_type=FormVariableDataTypes.array, + initial_value=["A", "B", "C"], + ) + + schema = get_json_schema_from_form_variable(var) + + expected_schema = {"title": "Foo", "type": "array"} + self.assertEqual(schema, expected_schema) + + +class TestIsFormVariableRequired(TestCase): + + def test_component_default(self): + form = FormFactory.create() + form_def = FormDefinitionFactory.create( + configuration={ + "components": [ + { + "key": "textfield", + "type": "textfield", + "label": "Foo", + "source": FormVariableSources.component, + }, + ] + } + ) + FormStepFactory.create(form=form, form_definition=form_def) + + var = form_def.formvariable_set.first() + required = is_form_variable_required(var) + + self.assertFalse(required) + + def test_component_required(self): + form = FormFactory.create() + form_def = FormDefinitionFactory.create( + configuration={ + "components": [ + { + "key": "textfield", + "type": "textfield", + "label": "Foo", + "source": FormVariableSources.component, + "validate": {"required": True}, + }, + ] + } + ) + FormStepFactory.create(form=form, form_definition=form_def) + + var = form_def.formvariable_set.first() + required = is_form_variable_required(var) + + self.assertTrue(required) diff --git a/src/openforms/registrations/contrib/json_dump/plugin.py b/src/openforms/registrations/contrib/json_dump/plugin.py index 9a25f88a48..09162e17fa 100644 --- a/src/openforms/registrations/contrib/json_dump/plugin.py +++ b/src/openforms/registrations/contrib/json_dump/plugin.py @@ -5,11 +5,10 @@ from glom import assign, glom from zgw_consumers.client import build_client -from openforms.formio.dynamic_config import rewrite_formio_components from openforms.formio.components.utils import to_multiple +from openforms.formio.dynamic_config import rewrite_formio_components from openforms.formio.typing import Component -from openforms.forms.utils import to_json -from openforms.forms.utils import form_variables_to_json_schema +from openforms.forms.utils import form_variables_to_json_schema, to_json from openforms.submissions.logic.datastructures import DataContainer from openforms.submissions.models import ( Submission, @@ -208,7 +207,7 @@ def encode_attachment(attachment: SubmissionFileAttachment) -> str: def get_component( - variable: SubmissionValueVariable, submission : Submission + variable: SubmissionValueVariable, submission: Submission ) -> Component | None: """Get the component from a submission value variable. diff --git a/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_exception_raised_when_service_returns_unexpected_status_code.yaml b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_exception_raised_when_service_returns_unexpected_status_code.yaml index c3c4216aa5..7658991171 100644 --- a/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_exception_raised_when_service_returns_unexpected_status_code.yaml +++ b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_exception_raised_when_service_returns_unexpected_status_code.yaml @@ -1,22 +1,23 @@ interactions: - request: - body: '{"values": {"auth_bsn": "123456789", "firstName": "We Are"}, "schema": - {"$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", - "properties": {"static_var_1": {"type": "string", "pattern": "^cool_pattern$"}, - "form_var_1": {"type": "string"}, "form_var_2": {"type": "string"}, "attachment": - {"type": "string", "contentEncoding": "base64"}}, "required": ["static_var_1", - "form_var_1", "form_var_2"], "additionalProperties": false}}' + body: '"{\"values\": {\"auth_bsn\": \"123456789\", \"firstName\": \"We Are\"}, + \"schema\": {\"$schema\": \"https://json-schema.org/draft/2020-12/schema\", + \"type\": \"object\", \"properties\": {\"auth_bsn\": {\"title\": \"BSN\", \"description\": + \"Uniquely identifies the authenticated person. This value follows the rules + for Dutch social security numbers.\", \"type\": \"string\", \"pattern\": \"^\\\\d{9}$\", + \"format\": \"nl-bsn\"}, \"firstName\": {\"title\": \"Firstname\", \"type\": + \"string\"}}, \"required\": [\"auth_bsn\"], \"additionalProperties\": false}}"' headers: Accept: - '*/*' Accept-Encoding: - gzip, deflate, br Authorization: - - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIiLCJpYXQiOjE3MzcwMzM3OTcsImNsaWVudF9pZCI6IiIsInVzZXJfaWQiOiIiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiIn0.ZE3A4AQZ8omE_KsvI_LcDSMrmBa9-AJoUiiAdjhtSqo + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIiLCJpYXQiOjE3MzczODQzMTgsImNsaWVudF9pZCI6IiIsInVzZXJfaWQiOiIiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiIn0.nphs3uH7g9ZebNyJz3HhM5_fMld0N4MgD_01_MTgL8k Connection: - keep-alive Content-Length: - - '450' + - '560' Content-Type: - application/json User-Agent: @@ -45,7 +46,7 @@ interactions: Content-Type: - text/html; charset=utf-8 Date: - - Thu, 16 Jan 2025 13:23:17 GMT + - Mon, 20 Jan 2025 14:45:18 GMT Server: - Werkzeug/3.1.3 Python/3.12.8 status: diff --git a/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_multiple_file_uploads.yaml b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_multiple_file_uploads.yaml index 313645f52a..541290b6f9 100644 --- a/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_multiple_file_uploads.yaml +++ b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_multiple_file_uploads.yaml @@ -1,23 +1,24 @@ interactions: - request: - body: '{"values": {"file": [{"file_name": "file1.txt", "content": "VGhpcyBpcyBleGFtcGxlIGNvbnRlbnQu"}, - {"file_name": "file2.txt", "content": "Q29udGVudCBleGFtcGxlIGlzIHRoaXMu"}]}, - "schema": {"$schema": "https://json-schema.org/draft/2020-12/schema", "type": - "object", "properties": {"static_var_1": {"type": "string", "pattern": "^cool_pattern$"}, - "form_var_1": {"type": "string"}, "form_var_2": {"type": "string"}, "attachment": - {"type": "string", "contentEncoding": "base64"}}, "required": ["static_var_1", - "form_var_1", "form_var_2"], "additionalProperties": false}}' + body: '"{\"values\": {\"file\": [{\"file_name\": \"file1.txt\", \"content\": \"VGhpcyBpcyBleGFtcGxlIGNvbnRlbnQu\"}, + {\"file_name\": \"file2.txt\", \"content\": \"Q29udGVudCBleGFtcGxlIGlzIHRoaXMu\"}]}, + \"schema\": {\"$schema\": \"https://json-schema.org/draft/2020-12/schema\", + \"type\": \"object\", \"properties\": {\"file\": {\"title\": \"File\", \"type\": + \"array\", \"items\": {\"type\": \"object\", \"properties\": {\"file_name\": + {\"type\": \"string\"}, \"content\": {\"type\": \"string\", \"format\": \"base64\"}}, + \"required\": [\"file_name\", \"content\"], \"additionalProperties\": false}}}, + \"required\": [], \"additionalProperties\": false}}"' headers: Accept: - '*/*' Accept-Encoding: - gzip, deflate, br Authorization: - - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIiLCJpYXQiOjE3MzcwMzM3OTcsImNsaWVudF9pZCI6IiIsInVzZXJfaWQiOiIiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiIn0.ZE3A4AQZ8omE_KsvI_LcDSMrmBa9-AJoUiiAdjhtSqo + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIiLCJpYXQiOjE3MzczODQzMTgsImNsaWVudF9pZCI6IiIsInVzZXJfaWQiOiIiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiIn0.nphs3uH7g9ZebNyJz3HhM5_fMld0N4MgD_01_MTgL8k Connection: - keep-alive Content-Length: - - '562' + - '646' Content-Type: - application/json User-Agent: @@ -27,14 +28,16 @@ interactions: response: body: string: "{\n \"data\": {\n \"schema\": {\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n - \ \"additionalProperties\": false,\n \"properties\": {\n \"attachment\": - {\n \"contentEncoding\": \"base64\",\n \"type\": \"string\"\n - \ },\n \"form_var_1\": {\n \"type\": \"string\"\n },\n - \ \"form_var_2\": {\n \"type\": \"string\"\n },\n \"static_var_1\": - {\n \"pattern\": \"^cool_pattern$\",\n \"type\": \"string\"\n - \ }\n },\n \"required\": [\n \"static_var_1\",\n \"form_var_1\",\n - \ \"form_var_2\"\n ],\n \"type\": \"object\"\n },\n \"values\": - {\n \"file\": [\n {\n \"content\": \"VGhpcyBpcyBleGFtcGxlIGNvbnRlbnQu\",\n + \ \"additionalProperties\": false,\n \"properties\": {\n \"file\": + {\n \"items\": {\n \"additionalProperties\": false,\n + \ \"properties\": {\n \"content\": {\n \"format\": + \"base64\",\n \"type\": \"string\"\n },\n \"file_name\": + {\n \"type\": \"string\"\n }\n },\n + \ \"required\": [\n \"file_name\",\n \"content\"\n + \ ],\n \"type\": \"object\"\n },\n \"title\": + \"File\",\n \"type\": \"array\"\n }\n },\n \"required\": + [],\n \"type\": \"object\"\n },\n \"values\": {\n \"file\": + [\n {\n \"content\": \"VGhpcyBpcyBleGFtcGxlIGNvbnRlbnQu\",\n \ \"file_name\": \"file1.txt\"\n },\n {\n \"content\": \"Q29udGVudCBleGFtcGxlIGlzIHRoaXMu\",\n \"file_name\": \"file2.txt\"\n \ }\n ]\n }\n },\n \"message\": \"Data received\"\n}\n" @@ -42,11 +45,11 @@ interactions: Connection: - close Content-Length: - - '923' + - '1035' Content-Type: - application/json Date: - - Thu, 16 Jan 2025 13:23:17 GMT + - Mon, 20 Jan 2025 14:45:18 GMT Server: - Werkzeug/3.1.3 Python/3.12.8 status: diff --git a/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_no_file_upload.yaml b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_no_file_upload.yaml index ee0a25b750..ecaa29b181 100644 --- a/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_no_file_upload.yaml +++ b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_no_file_upload.yaml @@ -1,21 +1,21 @@ interactions: - request: - body: '{"values": {"file": {}}, "schema": {"$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "properties": {"static_var_1": {"type": "string", "pattern": - "^cool_pattern$"}, "form_var_1": {"type": "string"}, "form_var_2": {"type": - "string"}, "attachment": {"type": "string", "contentEncoding": "base64"}}, "required": - ["static_var_1", "form_var_1", "form_var_2"], "additionalProperties": false}}' + body: '"{\"values\": {\"file\": {}}, \"schema\": {\"$schema\": \"https://json-schema.org/draft/2020-12/schema\", + \"type\": \"object\", \"properties\": {\"file\": {\"title\": \"File\", \"type\": + \"object\", \"properties\": {\"file_name\": {\"type\": \"string\"}, \"content\": + {\"type\": \"string\", \"format\": \"base64\"}}, \"required\": [], \"additionalProperties\": + false}}, \"required\": [], \"additionalProperties\": false}}"' headers: Accept: - '*/*' Accept-Encoding: - gzip, deflate, br Authorization: - - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIiLCJpYXQiOjE3MzcwMzM3OTcsImNsaWVudF9pZCI6IiIsInVzZXJfaWQiOiIiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiIn0.ZE3A4AQZ8omE_KsvI_LcDSMrmBa9-AJoUiiAdjhtSqo + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIiLCJpYXQiOjE3MzczODQzMTgsImNsaWVudF9pZCI6IiIsInVzZXJfaWQiOiIiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiIn0.nphs3uH7g9ZebNyJz3HhM5_fMld0N4MgD_01_MTgL8k Connection: - keep-alive Content-Length: - - '414' + - '422' Content-Type: - application/json User-Agent: @@ -25,23 +25,23 @@ interactions: response: body: string: "{\n \"data\": {\n \"schema\": {\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n - \ \"additionalProperties\": false,\n \"properties\": {\n \"attachment\": - {\n \"contentEncoding\": \"base64\",\n \"type\": \"string\"\n - \ },\n \"form_var_1\": {\n \"type\": \"string\"\n },\n - \ \"form_var_2\": {\n \"type\": \"string\"\n },\n \"static_var_1\": - {\n \"pattern\": \"^cool_pattern$\",\n \"type\": \"string\"\n - \ }\n },\n \"required\": [\n \"static_var_1\",\n \"form_var_1\",\n - \ \"form_var_2\"\n ],\n \"type\": \"object\"\n },\n \"values\": - {\n \"file\": {}\n }\n },\n \"message\": \"Data received\"\n}\n" + \ \"additionalProperties\": false,\n \"properties\": {\n \"file\": + {\n \"additionalProperties\": false,\n \"properties\": {\n + \ \"content\": {\n \"format\": \"base64\",\n \"type\": + \"string\"\n },\n \"file_name\": {\n \"type\": + \"string\"\n }\n },\n \"required\": [],\n \"title\": + \"File\",\n \"type\": \"object\"\n }\n },\n \"required\": + [],\n \"type\": \"object\"\n },\n \"values\": {\n \"file\": + {}\n }\n },\n \"message\": \"Data received\"\n}\n" headers: Connection: - close Content-Length: - - '691' + - '655' Content-Type: - application/json Date: - - Thu, 16 Jan 2025 13:23:17 GMT + - Mon, 20 Jan 2025 14:45:18 GMT Server: - Werkzeug/3.1.3 Python/3.12.8 status: diff --git a/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_radio_component_with_form_variable_as_data_source.yaml b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_radio_component_with_form_variable_as_data_source.yaml new file mode 100644 index 0000000000..fcbfba2006 --- /dev/null +++ b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_radio_component_with_form_variable_as_data_source.yaml @@ -0,0 +1,47 @@ +interactions: +- request: + body: '"{\"values\": {\"radio\": \"A\"}, \"schema\": {\"$schema\": \"https://json-schema.org/draft/2020-12/schema\", + \"type\": \"object\", \"properties\": {\"radio\": {\"title\": \"Radio\", \"type\": + \"string\", \"enum\": [\"A\", \"B\", \"C\", \"\"]}}, \"required\": [], \"additionalProperties\": + false}}"' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIiLCJpYXQiOjE3MzczODQzMTgsImNsaWVudF9pZCI6IiIsInVzZXJfaWQiOiIiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiIn0.nphs3uH7g9ZebNyJz3HhM5_fMld0N4MgD_01_MTgL8k + Connection: + - keep-alive + Content-Length: + - '298' + Content-Type: + - application/json + User-Agent: + - python-requests/2.32.2 + method: POST + uri: http://localhost/json_plugin + response: + body: + string: "{\n \"data\": {\n \"schema\": {\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n + \ \"additionalProperties\": false,\n \"properties\": {\n \"radio\": + {\n \"enum\": [\n \"A\",\n \"B\",\n \"C\",\n + \ \"\"\n ],\n \"title\": \"Radio\",\n \"type\": + \"string\"\n }\n },\n \"required\": [],\n \"type\": + \"object\"\n },\n \"values\": {\n \"radio\": \"A\"\n }\n },\n + \ \"message\": \"Data received\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '475' + Content-Type: + - application/json + Date: + - Mon, 20 Jan 2025 14:45:18 GMT + Server: + - Werkzeug/3.1.3 Python/3.12.8 + status: + code: 201 + message: CREATED +version: 1 diff --git a/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_required_in_schema_is_empty_if_select_boxes_component_unfilled.yaml b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_required_in_schema_is_empty_if_select_boxes_component_unfilled.yaml new file mode 100644 index 0000000000..4ec51e58cb --- /dev/null +++ b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_required_in_schema_is_empty_if_select_boxes_component_unfilled.yaml @@ -0,0 +1,50 @@ +interactions: +- request: + body: '"{\"values\": {\"selectboxes\": {}}, \"schema\": {\"$schema\": \"https://json-schema.org/draft/2020-12/schema\", + \"type\": \"object\", \"properties\": {\"selectboxes\": {\"title\": \"Selectboxes\", + \"type\": \"object\", \"properties\": {\"option1\": {\"type\": \"boolean\"}, + \"option2\": {\"type\": \"boolean\"}}, \"required\": [], \"additionalProperties\": + false}}, \"required\": [], \"additionalProperties\": false}}"' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIiLCJpYXQiOjE3MzczODQzMTgsImNsaWVudF9pZCI6IiIsInVzZXJfaWQiOiIiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiIn0.nphs3uH7g9ZebNyJz3HhM5_fMld0N4MgD_01_MTgL8k + Connection: + - keep-alive + Content-Length: + - '419' + Content-Type: + - application/json + User-Agent: + - python-requests/2.32.2 + method: POST + uri: http://localhost/json_plugin + response: + body: + string: "{\n \"data\": {\n \"schema\": {\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n + \ \"additionalProperties\": false,\n \"properties\": {\n \"selectboxes\": + {\n \"additionalProperties\": false,\n \"properties\": {\n + \ \"option1\": {\n \"type\": \"boolean\"\n },\n + \ \"option2\": {\n \"type\": \"boolean\"\n }\n + \ },\n \"required\": [],\n \"title\": \"Selectboxes\",\n + \ \"type\": \"object\"\n }\n },\n \"required\": [],\n + \ \"type\": \"object\"\n },\n \"values\": {\n \"selectboxes\": + {}\n }\n },\n \"message\": \"Data received\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '642' + Content-Type: + - application/json + Date: + - Mon, 20 Jan 2025 14:45:18 GMT + Server: + - Werkzeug/3.1.3 Python/3.12.8 + status: + code: 201 + message: CREATED +version: 1 diff --git a/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_select_boxes_component_with_form_variable_as_data_source.yaml b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_select_boxes_component_with_form_variable_as_data_source.yaml new file mode 100644 index 0000000000..fcbc954e4c --- /dev/null +++ b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_select_boxes_component_with_form_variable_as_data_source.yaml @@ -0,0 +1,55 @@ +interactions: +- request: + body: '"{\"values\": {\"selectBoxes\": {\"A\": true, \"B\": false, \"C\": true}}, + \"schema\": {\"$schema\": \"https://json-schema.org/draft/2020-12/schema\", + \"type\": \"object\", \"properties\": {\"selectBoxes\": {\"title\": \"Select + Boxes\", \"type\": \"object\", \"additionalProperties\": false, \"properties\": + {\"A\": {\"type\": \"boolean\"}, \"B\": {\"type\": \"boolean\"}, \"C\": {\"type\": + \"boolean\"}}, \"required\": [\"A\", \"B\", \"C\"]}}, \"required\": [], \"additionalProperties\": + false}}"' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIiLCJpYXQiOjE3MzczODQzMTgsImNsaWVudF9pZCI6IiIsInVzZXJfaWQiOiIiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiIn0.nphs3uH7g9ZebNyJz3HhM5_fMld0N4MgD_01_MTgL8k + Connection: + - keep-alive + Content-Length: + - '497' + Content-Type: + - application/json + User-Agent: + - python-requests/2.32.2 + method: POST + uri: http://localhost/json_plugin + response: + body: + string: "{\n \"data\": {\n \"schema\": {\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n + \ \"additionalProperties\": false,\n \"properties\": {\n \"selectBoxes\": + {\n \"additionalProperties\": false,\n \"properties\": {\n + \ \"A\": {\n \"type\": \"boolean\"\n },\n + \ \"B\": {\n \"type\": \"boolean\"\n },\n + \ \"C\": {\n \"type\": \"boolean\"\n }\n + \ },\n \"required\": [\n \"A\",\n \"B\",\n + \ \"C\"\n ],\n \"title\": \"Select Boxes\",\n + \ \"type\": \"object\"\n }\n },\n \"required\": [],\n + \ \"type\": \"object\"\n },\n \"values\": {\n \"selectBoxes\": + {\n \"A\": true,\n \"B\": false,\n \"C\": true\n }\n + \ }\n },\n \"message\": \"Data received\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '822' + Content-Type: + - application/json + Date: + - Mon, 20 Jan 2025 14:45:18 GMT + Server: + - Werkzeug/3.1.3 Python/3.12.8 + status: + code: 201 + message: CREATED +version: 1 diff --git a/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_select_boxes_schema_required_is_empty_when_no_data_is_submitted.yaml b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_select_boxes_schema_required_is_empty_when_no_data_is_submitted.yaml new file mode 100644 index 0000000000..1b465943ec --- /dev/null +++ b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_select_boxes_schema_required_is_empty_when_no_data_is_submitted.yaml @@ -0,0 +1,52 @@ +interactions: +- request: + body: '"{\"values\": {\"selectBoxes\": {}}, \"schema\": {\"$schema\": \"https://json-schema.org/draft/2020-12/schema\", + \"type\": \"object\", \"properties\": {\"selectBoxes\": {\"title\": \"Select + Boxes\", \"type\": \"object\", \"properties\": {\"a\": {\"type\": \"boolean\"}, + \"b\": {\"type\": \"boolean\"}, \"c\": {\"type\": \"boolean\"}}, \"required\": + [], \"additionalProperties\": false}}, \"required\": [], \"additionalProperties\": + false}}"' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIiLCJpYXQiOjE3MzczODQzMTgsImNsaWVudF9pZCI6IiIsInVzZXJfaWQiOiIiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiIn0.nphs3uH7g9ZebNyJz3HhM5_fMld0N4MgD_01_MTgL8k + Connection: + - keep-alive + Content-Length: + - '440' + Content-Type: + - application/json + User-Agent: + - python-requests/2.32.2 + method: POST + uri: http://localhost/json_plugin + response: + body: + string: "{\n \"data\": {\n \"schema\": {\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n + \ \"additionalProperties\": false,\n \"properties\": {\n \"selectBoxes\": + {\n \"additionalProperties\": false,\n \"properties\": {\n + \ \"a\": {\n \"type\": \"boolean\"\n },\n + \ \"b\": {\n \"type\": \"boolean\"\n },\n + \ \"c\": {\n \"type\": \"boolean\"\n }\n + \ },\n \"required\": [],\n \"title\": \"Select Boxes\",\n + \ \"type\": \"object\"\n }\n },\n \"required\": [],\n + \ \"type\": \"object\"\n },\n \"values\": {\n \"selectBoxes\": + {}\n }\n },\n \"message\": \"Data received\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '697' + Content-Type: + - application/json + Date: + - Mon, 20 Jan 2025 14:45:18 GMT + Server: + - Werkzeug/3.1.3 Python/3.12.8 + status: + code: 201 + message: CREATED +version: 1 diff --git a/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_select_component_with_form_variable_as_data_source.yaml b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_select_component_with_form_variable_as_data_source.yaml new file mode 100644 index 0000000000..45976e84bf --- /dev/null +++ b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_select_component_with_form_variable_as_data_source.yaml @@ -0,0 +1,49 @@ +interactions: +- request: + body: '"{\"values\": {\"select\": [\"A\", \"C\"]}, \"schema\": {\"$schema\": \"https://json-schema.org/draft/2020-12/schema\", + \"type\": \"object\", \"properties\": {\"select\": {\"type\": \"array\", \"items\": + {\"type\": \"string\", \"enum\": [\"A\", \"B\", \"C\", \"\"]}, \"title\": \"Select\"}}, + \"required\": [], \"additionalProperties\": false}}"' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Authorization: + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIiLCJpYXQiOjE3MzczODQzMTgsImNsaWVudF9pZCI6IiIsInVzZXJfaWQiOiIiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiIn0.nphs3uH7g9ZebNyJz3HhM5_fMld0N4MgD_01_MTgL8k + Connection: + - keep-alive + Content-Length: + - '344' + Content-Type: + - application/json + User-Agent: + - python-requests/2.32.2 + method: POST + uri: http://localhost/json_plugin + response: + body: + string: "{\n \"data\": {\n \"schema\": {\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n + \ \"additionalProperties\": false,\n \"properties\": {\n \"select\": + {\n \"items\": {\n \"enum\": [\n \"A\",\n + \ \"B\",\n \"C\",\n \"\"\n ],\n + \ \"type\": \"string\"\n },\n \"title\": \"Select\",\n + \ \"type\": \"array\"\n }\n },\n \"required\": [],\n + \ \"type\": \"object\"\n },\n \"values\": {\n \"select\": [\n + \ \"A\",\n \"C\"\n ]\n }\n },\n \"message\": \"Data + received\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '583' + Content-Type: + - application/json + Date: + - Mon, 20 Jan 2025 14:45:18 GMT + Server: + - Werkzeug/3.1.3 Python/3.12.8 + status: + code: 201 + message: CREATED +version: 1 diff --git a/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_submission_happy_flow.yaml b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_submission_happy_flow.yaml index 413021606b..9778ac9e74 100644 --- a/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_submission_happy_flow.yaml +++ b/src/openforms/registrations/contrib/json_dump/tests/files/vcr_cassettes/JSONDumpBackendTests/JSONDumpBackendTests.test_submission_happy_flow.yaml @@ -1,23 +1,27 @@ interactions: - request: - body: '{"values": {"auth_bsn": "123456789", "firstName": "We Are", "file": {"file_name": - "test_file.txt", "content": "VGhpcyBpcyBleGFtcGxlIGNvbnRlbnQu"}}, "schema": - {"$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", - "properties": {"static_var_1": {"type": "string", "pattern": "^cool_pattern$"}, - "form_var_1": {"type": "string"}, "form_var_2": {"type": "string"}, "attachment": - {"type": "string", "contentEncoding": "base64"}}, "required": ["static_var_1", - "form_var_1", "form_var_2"], "additionalProperties": false}}' + body: '"{\"values\": {\"auth_bsn\": \"123456789\", \"firstName\": \"We Are\", + \"file\": {\"file_name\": \"test_file.txt\", \"content\": \"VGhpcyBpcyBleGFtcGxlIGNvbnRlbnQu\"}}, + \"schema\": {\"$schema\": \"https://json-schema.org/draft/2020-12/schema\", + \"type\": \"object\", \"properties\": {\"auth_bsn\": {\"title\": \"BSN\", \"description\": + \"Uniquely identifies the authenticated person. This value follows the rules + for Dutch social security numbers.\", \"type\": \"string\", \"pattern\": \"^\\\\d{9}$\", + \"format\": \"nl-bsn\"}, \"firstName\": {\"title\": \"Firstname\", \"type\": + \"string\"}, \"file\": {\"title\": \"File\", \"type\": \"object\", \"properties\": + {\"file_name\": {\"type\": \"string\"}, \"content\": {\"type\": \"string\", + \"format\": \"base64\"}}, \"required\": [\"file_name\", \"content\"], \"additionalProperties\": + false}}, \"required\": [\"auth_bsn\"], \"additionalProperties\": false}}"' headers: Accept: - '*/*' Accept-Encoding: - gzip, deflate, br Authorization: - - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIiLCJpYXQiOjE3MzcwMzM3OTgsImNsaWVudF9pZCI6IiIsInVzZXJfaWQiOiIiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiIn0.auRLR2g7eX3HTcKYX6vM2j4WThn9rWImicoRL1rz0l4 + - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIiLCJpYXQiOjE3MzczODQzMTgsImNsaWVudF9pZCI6IiIsInVzZXJfaWQiOiIiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiIn0.nphs3uH7g9ZebNyJz3HhM5_fMld0N4MgD_01_MTgL8k Connection: - keep-alive Content-Length: - - '537' + - '907' Content-Type: - application/json User-Agent: @@ -27,13 +31,19 @@ interactions: response: body: string: "{\n \"data\": {\n \"schema\": {\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n - \ \"additionalProperties\": false,\n \"properties\": {\n \"attachment\": - {\n \"contentEncoding\": \"base64\",\n \"type\": \"string\"\n - \ },\n \"form_var_1\": {\n \"type\": \"string\"\n },\n - \ \"form_var_2\": {\n \"type\": \"string\"\n },\n \"static_var_1\": - {\n \"pattern\": \"^cool_pattern$\",\n \"type\": \"string\"\n - \ }\n },\n \"required\": [\n \"static_var_1\",\n \"form_var_1\",\n - \ \"form_var_2\"\n ],\n \"type\": \"object\"\n },\n \"values\": + \ \"additionalProperties\": false,\n \"properties\": {\n \"auth_bsn\": + {\n \"description\": \"Uniquely identifies the authenticated person. + This value follows the rules for Dutch social security numbers.\",\n \"format\": + \"nl-bsn\",\n \"pattern\": \"^\\\\d{9}$\",\n \"title\": + \"BSN\",\n \"type\": \"string\"\n },\n \"file\": {\n + \ \"additionalProperties\": false,\n \"properties\": {\n + \ \"content\": {\n \"format\": \"base64\",\n \"type\": + \"string\"\n },\n \"file_name\": {\n \"type\": + \"string\"\n }\n },\n \"required\": [\n \"file_name\",\n + \ \"content\"\n ],\n \"title\": \"File\",\n \"type\": + \"object\"\n },\n \"firstName\": {\n \"title\": \"Firstname\",\n + \ \"type\": \"string\"\n }\n },\n \"required\": [\n + \ \"auth_bsn\"\n ],\n \"type\": \"object\"\n },\n \"values\": {\n \"auth_bsn\": \"123456789\",\n \"file\": {\n \"content\": \"VGhpcyBpcyBleGFtcGxlIGNvbnRlbnQu\",\n \"file_name\": \"test_file.txt\"\n \ },\n \"firstName\": \"We Are\"\n }\n },\n \"message\": \"Data @@ -42,11 +52,11 @@ interactions: Connection: - close Content-Length: - - '850' + - '1278' Content-Type: - application/json Date: - - Thu, 16 Jan 2025 13:23:18 GMT + - Mon, 20 Jan 2025 14:45:18 GMT Server: - Werkzeug/3.1.3 Python/3.12.8 status: diff --git a/src/openforms/registrations/contrib/json_dump/tests/test_backend.py b/src/openforms/registrations/contrib/json_dump/tests/test_backend.py index 63c19bf9b1..ab68cf2b75 100644 --- a/src/openforms/registrations/contrib/json_dump/tests/test_backend.py +++ b/src/openforms/registrations/contrib/json_dump/tests/test_backend.py @@ -197,7 +197,6 @@ def test_multiple_file_uploads(self): set_submission_reference(submission) res = json_plugin.register_submission(submission, json_form_options) - res_json = res["api_response"] expected_data = { "values": { @@ -217,13 +216,17 @@ def test_multiple_file_uploads(self): "type": "object", "properties": { "file": { - "type": "object", - "properties": { - "file1.txt": {"type": "string", "format": "base64"}, - "file2.txt": {"type": "string", "format": "base64"}, + "title": "File", + "type": "array", + "items": { + "type": "object", + "properties": { + "file_name": {"type": "string"}, + "content": {"type": "string", "format": "base64"}, + }, + "required": ["file_name", "content"], + "additionalProperties": False, }, - "required": ["file1.txt", "file2.txt"], - "additionalProperties": False, } }, "additionalProperties": False, @@ -231,7 +234,7 @@ def test_multiple_file_uploads(self): }, } - self.assertEqual(res_json["data"], expected_data) + self.assertEqual(res["api_response"]["data"], expected_data) def test_no_file_upload(self): submission = SubmissionFactory.from_components( @@ -252,7 +255,29 @@ def test_no_file_upload(self): res = json_plugin.register_submission(submission, json_form_options) - self.assertEqual(glom(res, "api_response.data.values.file"), {}) + expected_data = { + "values": {"file": {}}, + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "file": { + "title": "File", + "type": "object", + "properties": { + "file_name": {"type": "string"}, + "content": {"type": "string", "format": "base64"}, + }, + "required": [], + "additionalProperties": False, + } + }, + "required": [], + "additionalProperties": False, + }, + } + + self.assertEqual(res["api_response"]["data"], expected_data) def test_path_traversal_attack(self): submission = SubmissionFactory.from_components( @@ -300,8 +325,8 @@ def test_required_in_schema_is_empty_if_select_boxes_component_unfilled(self): json_form_options = dict( service=(ServiceFactory(api_root="http://localhost:80/")), - relative_api_endpoint="json_plugin", - form_variables=["selectboxes"], + path="json_plugin", + variables=["selectboxes"], ) res = json_plugin.register_submission(submission, json_form_options) @@ -350,8 +375,8 @@ def test_select_component_with_form_variable_as_data_source(self): json_form_options = dict( service=(ServiceFactory(api_root="http://localhost:80/")), - relative_api_endpoint="json_plugin", - form_variables=["select"], + path="json_plugin", + variables=["select"], ) res = json_plugin.register_submission(submission, json_form_options) @@ -395,8 +420,8 @@ def test_select_boxes_component_with_form_variable_as_data_source(self): json_form_options = dict( service=(ServiceFactory(api_root="http://localhost:80/")), - relative_api_endpoint="json_plugin", - form_variables=["selectBoxes"], + path="json_plugin", + variables=["selectBoxes"], ) res = json_plugin.register_submission(submission, json_form_options) @@ -415,7 +440,7 @@ def test_select_boxes_component_with_form_variable_as_data_source(self): self.assertEqual( glom(res, "api_response.data.schema.properties.selectBoxes"), - expected_schema + expected_schema, ) def test_select_boxes_schema_required_is_empty_when_no_data_is_submitted(self): @@ -441,8 +466,8 @@ def test_select_boxes_schema_required_is_empty_when_no_data_is_submitted(self): json_form_options = dict( service=(ServiceFactory(api_root="http://localhost:80/")), - relative_api_endpoint="json_plugin", - form_variables=["selectBoxes"], + path="json_plugin", + variables=["selectBoxes"], ) res = json_plugin.register_submission(submission, json_form_options) @@ -485,8 +510,8 @@ def test_radio_component_with_form_variable_as_data_source(self): json_form_options = dict( service=(ServiceFactory(api_root="http://localhost:80/")), - relative_api_endpoint="json_plugin", - form_variables=["radio"], + path="json_plugin", + variables=["radio"], ) res = json_plugin.register_submission(submission, json_form_options)