Files
cicdTest/consul-helm/test/unit/tls-init-cleanup-clusterrole.bats

68 lines
2.2 KiB
Bash

#!/usr/bin/env bats
load _helpers
@test "tlsInitCleanup/ClusterRole: disabled by default" {
cd `chart_dir`
local actual=$(helm template \
-x templates/tls-init-cleanup-clusterrole.yaml \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "false" ]
}
@test "tlsInitCleanup/ClusterRole: disabled with global.enabled=false" {
cd `chart_dir`
local actual=$(helm template \
-x templates/tls-init-cleanup-clusterrole.yaml \
--set 'global.tls.enabled=true' \
--set 'global.enabled=false' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "false" ]
}
@test "tlsInitCleanup/ClusterRole: disabled when server.enabled=false" {
cd `chart_dir`
local actual=$(helm template \
-x templates/tls-init-cleanup-clusterrole.yaml \
--set 'global.tls.enabled=true' \
--set 'server.enabled=false' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "false" ]
}
@test "tlsInitCleanup/ClusterRole: enabled when global.tls.enabled=true and server.enabled=true" {
cd `chart_dir`
local actual=$(helm template \
-x templates/tls-init-cleanup-clusterrole.yaml \
--set 'global.tls.enabled=true' \
--set 'server.enabled=true' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
@test "tlsInitCleanup/ClusterRole: enabled with global.tls.enabled" {
cd `chart_dir`
local actual=$(helm template \
-x templates/tls-init-cleanup-clusterrole.yaml \
--set 'global.tls.enabled=true' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
@test "tlsInitCleanup/ClusterRole: adds pod security polices with global.tls.enabled and global.enablePodSecurityPolicies" {
cd `chart_dir`
local actual=$(helm template \
-x templates/tls-init-cleanup-clusterrole.yaml \
--set 'global.tls.enabled=true' \
--set 'global.enablePodSecurityPolicies=true' \
. | tee /dev/stderr |
yq -r '.rules[] | select(.resources==["podsecuritypolicies"]) | .resourceNames[0]' | tee /dev/stderr)
[ "${actual}" = "release-name-consul-tls-init-cleanup" ]
}