Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Glass committed Jul 27, 2023
1 parent f9e5b38 commit 7b95dd1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion charts/consul/test/unit/server-statefulset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -846,9 +846,11 @@ load _helpers
#--------------------------------------------------------------------
# global.openshift.enabled

@test "server/StatefulSet: restricted container securityContexts are set when global.openshift.enabled=true" {
@test "server/StatefulSet: restricted container securityContexts are set when global.openshift.enabled=true on OpenShift >= 4.11" {
cd `chart_dir`
# OpenShift 4.11 == Kube 1.24
local manifest=$(helm template \
--kube-version '1.24' \
-s templates/server-statefulset.yaml \
--set 'global.openshift.enabled=true' \
. | tee /dev/stderr)
Expand All @@ -870,6 +872,20 @@ load _helpers
[ "$equal" == "true" ]
}

@test "server/StatefulSet: restricted container securityContexts are not set when global.openshift.enabled=true on OpenShift < 4.11" {
cd `chart_dir`
# OpenShift 4.11 == Kube 1.24
local manifest=$(helm template \
--kube-version '1.23' \
-s templates/server-statefulset.yaml \
--set 'global.openshift.enabled=true' \
. | tee /dev/stderr)

# Check consul container
local actual=$(echo "$manifest" | yq -r '.spec.template.spec.containers | map(select(.name == "consul")) | .[0].securityContext')
[ "$actual" == "null" ]
}

#--------------------------------------------------------------------
# global.openshift.enabled = false

Expand Down

0 comments on commit 7b95dd1

Please sign in to comment.