Skip to content

Commit

Permalink
chore: refactor tests.
Browse files Browse the repository at this point in the history
Refactor the policy unit tests to use rstest reducing the number of test
functions and similar code. Furthermore, added two more e2e tests to validate
the new feature to skip init and ephemeral containers.

Signed-off-by: José Guilherme Vanz <[email protected]>
  • Loading branch information
jvanz committed Dec 19, 2023
1 parent e39451f commit 7fc38ec
Show file tree
Hide file tree
Showing 7 changed files with 734 additions and 491 deletions.
217 changes: 217 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ lazy_static = "1.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
slog = "2.7"
rstest = "0.18.2"
16 changes: 15 additions & 1 deletion e2e.bats
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,18 @@
[ "$status" -eq 0 ]
[ $(expr "$output" : '.*allowed.*false') -ne 0 ]
[ $(expr "$output" : '.*Privileged container is not allowed*') -ne 0 ]
}
}

@test "accept privileged init container when required" {
run kwctl run annotated-policy.wasm -r test_data/privileged_init_container.json --settings-path test_data/settings_skip_init_and_ephemeral_containers.json
# request accepted
[ "$status" -eq 0 ]
[ $(expr "$output" : '.*allowed.*true') -ne 0 ]
}

@test "accept privileged ephemeral container when required" {
run kwctl run annotated-policy.wasm -r test_data/privileged_ephemeral_container.json --settings-path test_data/settings_skip_init_and_ephemeral_containers.json
# request accepted
[ "$status" -eq 0 ]
[ $(expr "$output" : '.*allowed.*true') -ne 0 ]
}
Loading

0 comments on commit 7fc38ec

Please sign in to comment.