diff --git a/src/openforms/registrations/contrib/json/admin.py b/src/openforms/registrations/contrib/json/admin.py deleted file mode 100644 index 9f4c2857a4..0000000000 --- a/src/openforms/registrations/contrib/json/admin.py +++ /dev/null @@ -1,10 +0,0 @@ -from django.contrib import admin - -from solo.admin import SingletonModelAdmin - -from .models import JSONConfig - - -@admin.register(JSONConfig) -class JSONConfigAdmin(SingletonModelAdmin): - pass diff --git a/src/openforms/registrations/contrib/json/migrations/0001_initial.py b/src/openforms/registrations/contrib/json/migrations/0001_initial.py deleted file mode 100644 index dfd97b0092..0000000000 --- a/src/openforms/registrations/contrib/json/migrations/0001_initial.py +++ /dev/null @@ -1,44 +0,0 @@ -# Generated by Django 4.2.17 on 2024-12-30 12:49 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ("zgw_consumers", "0022_set_default_service_slug"), - ] - - operations = [ - migrations.CreateModel( - name="JSONConfig", - fields=[ - ( - "id", - models.AutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), - ( - "service", - models.OneToOneField( - help_text="Service for JSON registration plugin", - limit_choices_to={"api_type": "orc"}, - null=True, - on_delete=django.db.models.deletion.PROTECT, - to="zgw_consumers.service", - verbose_name="Service", - ), - ), - ], - options={ - "verbose_name": "JSON registration configuration", - }, - ), - ] diff --git a/src/openforms/registrations/contrib/json/models.py b/src/openforms/registrations/contrib/json/models.py deleted file mode 100644 index f2ee73d7a3..0000000000 --- a/src/openforms/registrations/contrib/json/models.py +++ /dev/null @@ -1,30 +0,0 @@ -from django.db import models -from django.utils.translation import gettext_lazy as _ - -from solo.models import SingletonModel -from zgw_consumers.constants import APITypes - - -class JSONConfigManager(models.Manager): - def get_queryset(self): - return super().get_queryset().select_related("service") - - -class JSONConfig(SingletonModel): - """ - Global configuration and defaults - """ - - service = models.OneToOneField( - "zgw_consumers.Service", - verbose_name=_("Service"), - on_delete=models.PROTECT, - limit_choices_to={"api_type": APITypes.orc}, - null=True, - help_text=_("Service for JSON registration plugin"), - ) - - objects = JSONConfigManager() - - class Meta: - verbose_name = _("JSON registration configuration") diff --git a/src/openforms/registrations/contrib/json/plugin.py b/src/openforms/registrations/contrib/json/plugin.py index 0b395acedd..bdb5993773 100644 --- a/src/openforms/registrations/contrib/json/plugin.py +++ b/src/openforms/registrations/contrib/json/plugin.py @@ -1,19 +1,15 @@ import base64 -from django.urls import reverse from django.utils.translation import gettext_lazy as _ -from requests import RequestException from zgw_consumers.client import build_client -from openforms.plugins.exceptions import InvalidPluginConfiguration from openforms.submissions.models import Submission from openforms.variables.service import get_static_variables from ...base import BasePlugin # openforms.registrations.base from ...registry import register # openforms.registrations.registry from .config import JSONOptions, JSONOptionsSerializer -from .models import JSONConfig @register("json") @@ -78,26 +74,5 @@ def register_submission(self, submission: Submission, options: JSONOptions) -> d return result def check_config(self) -> None: - # Get service - config = JSONConfig.get_solo() - if (service := config.service) is None: - raise InvalidPluginConfiguration(_("Please configure a service")) - - # Check connection to service - with build_client(service) as client: - try: - res = client.get(service.api_connection_check_path) - res.raise_for_status() - except RequestException as exc: - raise InvalidPluginConfiguration(_(f"Invalid response: {exc}")) from exc - - def get_config_actions(self) -> list[tuple[str, str]]: - return [ - ( - _("Configuration"), - reverse( - "admin:registrations_json_jsonconfig_change", - args=(JSONConfig.singleton_instance_id,), - ), - ) - ] + # Config checks are not really relevant for this plugin right now + pass diff --git a/src/openforms/registrations/contrib/json/tests/files/vcr_cassettes/ConfigCheckTests/ConfigCheckTests.test_config_check_happy_flow.yaml b/src/openforms/registrations/contrib/json/tests/files/vcr_cassettes/ConfigCheckTests/ConfigCheckTests.test_config_check_happy_flow.yaml deleted file mode 100644 index bd37aa9fed..0000000000 --- a/src/openforms/registrations/contrib/json/tests/files/vcr_cassettes/ConfigCheckTests/ConfigCheckTests.test_config_check_happy_flow.yaml +++ /dev/null @@ -1,34 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate, br - Authorization: - - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIiLCJpYXQiOjE3MzU4MTE1NTAsImNsaWVudF9pZCI6IiIsInVzZXJfaWQiOiIiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiIn0.9NfTz6nrkM3ysWrsMYIV1kxDGvtXXF3uugyVpuUFqD0 - Connection: - - keep-alive - User-Agent: - - python-requests/2.32.2 - method: GET - uri: http://localhost/test_connection - response: - body: - string: "{\n \"message\": \"OK\"\n}\n" - headers: - Connection: - - close - Content-Length: - - '22' - Content-Type: - - application/json - Date: - - Thu, 02 Jan 2025 09:52:30 GMT - Server: - - Werkzeug/3.1.3 Python/3.12.8 - status: - code: 200 - message: OK -version: 1 diff --git a/src/openforms/registrations/contrib/json/tests/files/vcr_cassettes/ConfigCheckTests/ConfigCheckTests.test_invalid_response_from_api_test_connection_endpoint.yaml b/src/openforms/registrations/contrib/json/tests/files/vcr_cassettes/ConfigCheckTests/ConfigCheckTests.test_invalid_response_from_api_test_connection_endpoint.yaml deleted file mode 100644 index e5b93eee57..0000000000 --- a/src/openforms/registrations/contrib/json/tests/files/vcr_cassettes/ConfigCheckTests/ConfigCheckTests.test_invalid_response_from_api_test_connection_endpoint.yaml +++ /dev/null @@ -1,45 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate, br - Authorization: - - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIiLCJpYXQiOjE3MzU4MTE1NTAsImNsaWVudF9pZCI6IiIsInVzZXJfaWQiOiIiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiIn0.9NfTz6nrkM3ysWrsMYIV1kxDGvtXXF3uugyVpuUFqD0 - Connection: - - keep-alive - User-Agent: - - python-requests/2.32.2 - method: GET - uri: http://localhost/fake_endpoint - response: - body: - string: ' - - - - 404 Not Found - -

Not Found

- -

The requested URL was not found on the server. If you entered the URL manually - please check your spelling and try again.

- - ' - headers: - Connection: - - close - Content-Length: - - '207' - Content-Type: - - text/html; charset=utf-8 - Date: - - Thu, 02 Jan 2025 09:52:30 GMT - Server: - - Werkzeug/3.1.3 Python/3.12.8 - status: - code: 404 - message: NOT FOUND -version: 1 diff --git a/src/openforms/registrations/contrib/json/tests/test_config_checks.py b/src/openforms/registrations/contrib/json/tests/test_config_checks.py deleted file mode 100644 index a81fb30c36..0000000000 --- a/src/openforms/registrations/contrib/json/tests/test_config_checks.py +++ /dev/null @@ -1,61 +0,0 @@ -from pathlib import Path -from unittest.mock import patch - -from django.test import TestCase - -from zgw_consumers.test.factories import ServiceFactory - -from openforms.plugins.exceptions import InvalidPluginConfiguration -from openforms.utils.tests.vcr import OFVCRMixin - -from ..models import JSONConfig -from ..plugin import JSONRegistration - -VCR_TEST_FILES = Path(__file__).parent / "files" - - -class ConfigCheckTests(OFVCRMixin, TestCase): - - VCR_TEST_FILES = VCR_TEST_FILES - - def test_config_check_happy_flow(self): - json_plugin = JSONRegistration("json_registration_plugin") - - config = JSONConfig( - service=ServiceFactory( - api_root="http://localhost:80/", - api_connection_check_path="test_connection", - ) - ) - - with patch( - "openforms.registrations.contrib.json.plugin.JSONConfig.get_solo", - return_value=config, - ): - json_plugin.check_config() - - def test_no_service_configured(self): - config = JSONConfig(service=None) - json_plugin = JSONRegistration("json_registration_plugin") - - with patch( - "openforms.registrations.contrib.json.plugin.JSONConfig.get_solo", - return_value=config, - ): - self.assertRaises(InvalidPluginConfiguration, json_plugin.check_config) - - def test_invalid_response_from_api_test_connection_endpoint(self): - json_plugin = JSONRegistration("json_registration_plugin") - - config = JSONConfig( - service=ServiceFactory( - api_root="http://localhost:80/", - api_connection_check_path="fake_endpoint", - ) - ) - - with patch( - "openforms.registrations.contrib.json.plugin.JSONConfig.get_solo", - return_value=config, - ): - self.assertRaises(InvalidPluginConfiguration, json_plugin.check_config)