@@ -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