diff --git a/boefjes/boefjes/sql/plugin_storage.py b/boefjes/boefjes/sql/plugin_storage.py index 7883ab32fd2..72bb444dd2e 100644 --- a/boefjes/boefjes/sql/plugin_storage.py +++ b/boefjes/boefjes/sql/plugin_storage.py @@ -49,8 +49,9 @@ def update_boefje(self, boefje_id: str, data: dict) -> None: if instance.static: raise NotAllowed(f"Plugin with id '{boefje_id}' is static, so updating it is not allowed") + field_mapping = {"boefje_schema": "schema"} # since Boefje.boefje_schema is the same as BoefjeInDB.schema for key, value in data.items(): - setattr(instance, key, value) + setattr(instance, field_mapping.get(key, key), value) self.session.add(instance) diff --git a/boefjes/tests/integration/test_api.py b/boefjes/tests/integration/test_api.py index 2fc179caca2..9cb36dae370 100644 --- a/boefjes/tests/integration/test_api.py +++ b/boefjes/tests/integration/test_api.py @@ -137,7 +137,9 @@ def test_update_boefje_schema(test_client, organisation): boefje = Boefje(id="test_plugin", name="My test boefje", description="123") test_client.post(f"/v1/organisations/{organisation.id}/plugins", content=boefje.model_dump_json()) - r = test_client.patch(f"/v1/organisations/{organisation.id}/boefjes/{boefje.id}", json={"boefje_schema": {"$schema": 3}}) + r = test_client.patch( + f"/v1/organisations/{organisation.id}/boefjes/{boefje.id}", json={"boefje_schema": {"$schema": 3}} + ) assert r.status_code == 400 valid_schema = { @@ -151,7 +153,9 @@ def test_update_boefje_schema(test_client, organisation): }, "required": [], } - r = test_client.patch(f"/v1/organisations/{organisation.id}/boefjes/{boefje.id}", json={"boefje_schema": valid_schema}) + r = test_client.patch( + f"/v1/organisations/{organisation.id}/boefjes/{boefje.id}", json={"boefje_schema": valid_schema} + ) assert r.status_code == 204 schema = test_client.get(f"/v1/organisations/{organisation.id}/plugins/{boefje.id}/schema.json").json() @@ -160,7 +164,9 @@ def test_update_boefje_schema(test_client, organisation): api_boefje = test_client.get(f"/v1/organisations/{organisation.id}/plugins/{boefje.id}").json() assert api_boefje["boefje_schema"] == valid_schema - r = test_client.patch(f"/v1/organisations/{organisation.id}/boefjes/dns-records", json={"boefje_schema": valid_schema}) + r = test_client.patch( + f"/v1/organisations/{organisation.id}/boefjes/dns-records", json={"boefje_schema": valid_schema} + ) assert r.status_code == 404