Skip to content

Commit

Permalink
test: add raw validation policy (waPC) e2e test
Browse files Browse the repository at this point in the history
Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
  • Loading branch information
fabriziosestito committed Oct 23, 2023
1 parent 59c9296 commit 231cf82
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
28 changes: 28 additions & 0 deletions e2e-tests/07-raw-policies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Raw policies execution

testcases:
- name: fixtures
steps:
- type: readfile
path: ./test_data/raw.json
assertions:
- result.err ShouldBeEmpty
vars:
raw_valid:
from: result.content

- name: Raw waPC policy validation works as expected
steps:
- name: Accept
type: http
method: POST
url: http://localhost:3000/validate_raw/raw-validation
headers:
Content-Type: application/json
body: "{{ .fixtures.raw_valid }}"
assertions:
- result.statuscode ShouldEqual 200
- result.bodyjson.response.allowed ShouldEqual true
- result.bodyjson.response.status.code ShouldNotEqual 500
- result.bodyjson.response ShouldNotContainKey patch
- result.bodyjson.response ShouldNotContainKey patchType
13 changes: 13 additions & 0 deletions e2e-tests/test_data/policies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,16 @@ flux:
settings:
requiredAnnotations:
"fluxcd.io/cat": "felix"

raw-validation:
url: ghcr.io/fabriziosestito/tests/raw-validation-policy:latest
settings:
validUsers:
- "tonio"
- "wanda"
validActions:
- "eats"
- "likes"
validResources:
- "banana"
- "hay"
3 changes: 3 additions & 0 deletions e2e-tests/test_data/raw.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"request": { "user": "tonio", "action": "likes", "resource": "hay" }
}

0 comments on commit 231cf82

Please sign in to comment.