Skip to content

Commit 0a8532a

Browse files
committed
fixing vap tests
Signed-off-by: Jaydip Gabani <[email protected]>
1 parent 8a71fc6 commit 0a8532a

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
docker := docker #You can build with podman by doing: make docker=podman
22
KIND_VERSION ?= 0.23.0
33
# note: k8s version pinned since KIND image availability lags k8s releases
4-
KUBERNETES_VERSION ?= 1.32.0
4+
KUBERNETES_VERSION ?= 1.30.0
55
KUSTOMIZE_VERSION ?= 4.5.5
66
GATEKEEPER_VERSION ?= 3.18.1
77
BATS_VERSION ?= 1.8.2

test/bats/test.bats

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,26 +85,24 @@ setup() {
8585
if [ -d "$policy" ]; then
8686
local policy_group=$(basename "$(dirname "$policy")")
8787
local template_name=$(basename "$policy")
88-
vapb_exists=false
8988
deny_substr="denied the request"
9089
echo "running integration test against policy group: $policy_group, constraint template: $template_name"
9190
# apply template
9291
wait_for_process ${WAIT_TIME} ${SLEEP_TIME} "kubectl apply -k $policy"
92+
local kind=$(yq e .metadata.name "$policy"/template.yaml)
9393
if [ "$POLICY_ENGINE" == "vap" ] && grep -q "engine: K8sNativeValidation" "$policy"/template.yaml; then
94-
wait_for_process ${WAIT_TIME} ${SLEEP_TIME} "kubectl get ValidatingAdmissionPolicy gatekeeper-$template_name"
95-
vapb_exists=true
94+
wait_for_process ${WAIT_TIME} ${SLEEP_TIME} "kubectl get ValidatingAdmissionPolicy gatekeeper-$kind"
95+
deny_substr="ValidatingAdmissionPolicy"
9696
fi
97-
local kind=$(yq e .metadata.name "$policy"/template.yaml)
9897
for sample in "$policy"/samples/*; do
9998
echo "testing sample constraint: $(basename "$sample")"
10099
# apply constraint
101100
wait_for_process ${WAIT_TIME} ${SLEEP_TIME} "kubectl apply -f ${sample}/constraint.yaml"
102101
local name=$(yq e .metadata.name "$sample"/constraint.yaml)
103102
wait_for_process ${WAIT_TIME} ${SLEEP_TIME} "constraint_enforced $kind $name"
104103

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

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

0 commit comments

Comments
 (0)