Skip to content

Commit

Permalink
fixing vap tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jaydip Gabani <[email protected]>
  • Loading branch information
JaydipGabani committed Dec 28, 2024
1 parent 8a71fc6 commit 0a8532a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
docker := docker #You can build with podman by doing: make docker=podman
KIND_VERSION ?= 0.23.0
# note: k8s version pinned since KIND image availability lags k8s releases
KUBERNETES_VERSION ?= 1.32.0
KUBERNETES_VERSION ?= 1.30.0
KUSTOMIZE_VERSION ?= 4.5.5
GATEKEEPER_VERSION ?= 3.18.1
BATS_VERSION ?= 1.8.2
Expand Down
10 changes: 4 additions & 6 deletions test/bats/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,24 @@ setup() {
if [ -d "$policy" ]; then
local policy_group=$(basename "$(dirname "$policy")")
local template_name=$(basename "$policy")
vapb_exists=false
deny_substr="denied the request"
echo "running integration test against policy group: $policy_group, constraint template: $template_name"
# apply template
wait_for_process ${WAIT_TIME} ${SLEEP_TIME} "kubectl apply -k $policy"
local kind=$(yq e .metadata.name "$policy"/template.yaml)
if [ "$POLICY_ENGINE" == "vap" ] && grep -q "engine: K8sNativeValidation" "$policy"/template.yaml; then
wait_for_process ${WAIT_TIME} ${SLEEP_TIME} "kubectl get ValidatingAdmissionPolicy gatekeeper-$template_name"
vapb_exists=true
wait_for_process ${WAIT_TIME} ${SLEEP_TIME} "kubectl get ValidatingAdmissionPolicy gatekeeper-$kind"
deny_substr="ValidatingAdmissionPolicy"
fi
local kind=$(yq e .metadata.name "$policy"/template.yaml)
for sample in "$policy"/samples/*; do
echo "testing sample constraint: $(basename "$sample")"
# apply constraint
wait_for_process ${WAIT_TIME} ${SLEEP_TIME} "kubectl apply -f ${sample}/constraint.yaml"
local name=$(yq e .metadata.name "$sample"/constraint.yaml)
wait_for_process ${WAIT_TIME} ${SLEEP_TIME} "constraint_enforced $kind $name"

if [ vapb_exists == true ]; then
if [ "$POLICY_ENGINE" == "vap" ] && grep -q "engine: K8sNativeValidation" "$policy"/template.yaml; then
wait_for_process ${WAIT_TIME} ${SLEEP_TIME} "kubectl get ValidatingAdmissionPolicyBinding gatekeeper-$name"
deny_substr="ValidatingAdmissionPolicy"
fi

for inventory in "$sample"/example_inventory*.yaml; do
Expand Down

0 comments on commit 0a8532a

Please sign in to comment.