openbao-helm/test/unit/injector-psp.bats
Yong Wen Chua adf5bf65a9
Support PodSecurityPolicy (#177)
* Add PSP for server

* Add PSP for Injector

* Allow annotations to be templated

Co-authored-by: Theron Voran <tvoran@users.noreply.github.com>
2020-06-25 23:42:52 -07:00

70 lines
2.3 KiB
Bash

#!/usr/bin/env bats
load _helpers
@test "injector/PodSecurityPolicy: PodSecurityPolicy not enabled by default" {
cd `chart_dir`
local actual=$( (helm template \
--show-only templates/injector-psp.yaml \
. || echo "---") | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "false" ]
}
@test "injector/PodSecurityPolicy: enable with injector.enabled and global.psp.enable" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/injector-psp.yaml \
--set 'injector.enabled=true' \
--set 'global.psp.enable=true' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
@test "injector/PodSecurityPolicy: disable with global.enabled" {
cd `chart_dir`
local actual=$( (helm template \
--show-only templates/injector-psp.yaml \
--set 'global.enabled=false' \
--set 'injector.enabled=true' \
--set 'global.psp.enable=true' \
. || echo "---") | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "false" ]
}
@test "injector/PodSecurityPolicy: annotations are templated correctly by default" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/injector-psp.yaml \
--set 'injector.enabled=true' \
--set 'global.psp.enable=true' \
. | tee /dev/stderr |
yq '.metadata.annotations | length == 4' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
@test "injector/PodSecurityPolicy: annotations are added - string" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/injector-psp.yaml \
--set 'injector.enabled=true' \
--set 'global.psp.enable=true' \
--set 'global.psp.annotations=vault-is: amazing' \
. | tee /dev/stderr |
yq -r '.metadata.annotations["vault-is"]' | tee /dev/stderr)
[ "${actual}" = "amazing" ]
}
@test "injector/PodSecurityPolicy: annotations are added - object" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/injector-psp.yaml \
--set 'injector.enabled=true' \
--set 'global.psp.enable=true' \
--set 'global.psp.annotations.vault-is=amazing' \
. | tee /dev/stderr |
yq -r '.metadata.annotations["vault-is"]' | tee /dev/stderr)
[ "${actual}" = "amazing" ]
}