2019-12-19 15:57:51 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load _helpers
|
|
|
|
|
|
|
|
@test "injector/ClusterRoleBinding: enabled by default" {
|
|
|
|
cd `chart_dir`
|
|
|
|
local actual=$(helm template \
|
2020-02-06 16:44:38 +00:00
|
|
|
--show-only templates/injector-clusterrolebinding.yaml \
|
2019-12-19 15:57:51 +00:00
|
|
|
. | tee /dev/stderr |
|
|
|
|
yq 'length > 0' | tee /dev/stderr)
|
|
|
|
[ "${actual}" = "true" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "injector/ClusterRoleBinding: disable with global.enabled" {
|
|
|
|
cd `chart_dir`
|
2020-02-06 16:44:38 +00:00
|
|
|
local actual=$( (helm template \
|
|
|
|
--show-only templates/injector-clusterrolebinding.yaml \
|
2019-12-19 15:57:51 +00:00
|
|
|
--set 'global.enabled=false' \
|
2020-02-06 16:44:38 +00:00
|
|
|
. || echo "---") | tee /dev/stderr |
|
2019-12-19 15:57:51 +00:00
|
|
|
yq 'length > 0' | tee /dev/stderr)
|
|
|
|
[ "${actual}" = "false" ]
|
|
|
|
}
|
2023-07-04 13:30:35 +00:00
|
|
|
|
|
|
|
@test "injector/ClusterRoleBinding: service account namespace" {
|
|
|
|
cd `chart_dir`
|
|
|
|
local actual=$(helm template \
|
|
|
|
--show-only templates/injector-clusterrolebinding.yaml \
|
|
|
|
--set "injector.enabled=true" \
|
|
|
|
--namespace foo \
|
|
|
|
. | tee /dev/stderr |
|
|
|
|
yq -r '.subjects[0].namespace' | tee /dev/stderr)
|
|
|
|
[ "${actual}" = "foo" ]
|
|
|
|
local actual=$(helm template \
|
|
|
|
--show-only templates/injector-clusterrolebinding.yaml \
|
|
|
|
--set "injector.enabled=true" \
|
|
|
|
--set 'global.namespace=bar' \
|
|
|
|
--namespace foo \
|
|
|
|
. | tee /dev/stderr |
|
|
|
|
yq -r '.subjects[0].namespace' | tee /dev/stderr)
|
|
|
|
[ "${actual}" = "bar" ]
|
|
|
|
}
|