From 13b4d1706a6f51c5efac601f6a06f5b2fc9c92a6 Mon Sep 17 00:00:00 2001 From: Fabrizio Sestito Date: Tue, 24 Oct 2023 07:52:00 +0200 Subject: [PATCH] test: add raw mutation policy (wasi) e2e test Signed-off-by: Fabrizio Sestito --- e2e-tests/07-raw-policies.yml | 16 ++++++++++++++++ e2e-tests/test_data/policies.yaml | 12 ++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/e2e-tests/07-raw-policies.yml b/e2e-tests/07-raw-policies.yml index 3773bc74..32b3a27c 100644 --- a/e2e-tests/07-raw-policies.yml +++ b/e2e-tests/07-raw-policies.yml @@ -97,3 +97,19 @@ testcases: - result.bodyjson.response.status.code ShouldNotEqual 500 - result.bodyjson.response ShouldNotContainKey patch - result.bodyjson.response ShouldNotContainKey patchType + + - name: Raw WASI mutation policy mutates the request + steps: + - name: Accept + type: http + method: POST + url: http://localhost:3000/validate_raw/raw-mutation-wasi + headers: + Content-Type: application/json + body: "{{ .fixtures.raw_mutation }}" + assertions: + - result.statuscode ShouldEqual 200 + - result.bodyjson.response.allowed ShouldEqual true + - result.bodyjson.response.status.code ShouldNotEqual 500 + - result.bodyjson.response ShouldContainKey patch + - result.bodyjson.response ShouldContainKey patchType diff --git a/e2e-tests/test_data/policies.yaml b/e2e-tests/test_data/policies.yaml index f79ceab4..5d385620 100644 --- a/e2e-tests/test_data/policies.yaml +++ b/e2e-tests/test_data/policies.yaml @@ -64,7 +64,11 @@ raw-validation-wasi: validResources: - "banana" - "hay" -# raw-mutation-wasi: -# url: ghcr.io/fabriziosestito/tests/raw-mutation-wasi-policy:latest -# allowedToMutate: true -# settings: {} + +raw-mutation-wasi: + url: ghcr.io/fabriziosestito/tests/raw-mutation-wasi-policy:latest + allowedToMutate: true + settings: + forbiddenResources: + - "banana" + - "carrot"