2019-12-19 15:57:51 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load _helpers
|
|
|
|
|
|
|
|
@test "injector/Service: service enabled by default" {
|
|
|
|
cd `chart_dir`
|
|
|
|
local actual=$(helm template \
|
2020-02-06 16:44:38 +00:00
|
|
|
--show-only templates/injector-service.yaml \
|
2019-12-19 15:57:51 +00:00
|
|
|
. | tee /dev/stderr |
|
|
|
|
yq 'length > 0' | tee /dev/stderr)
|
|
|
|
[ "${actual}" = "true" ]
|
|
|
|
|
|
|
|
local actual=$(helm template \
|
2020-02-06 16:44:38 +00:00
|
|
|
--show-only templates/injector-service.yaml \
|
2019-12-19 15:57:51 +00:00
|
|
|
--set 'injector.enabled=true' \
|
|
|
|
. | tee /dev/stderr |
|
|
|
|
yq 'length > 0' | tee /dev/stderr)
|
|
|
|
[ "${actual}" = "true" ]
|
|
|
|
}
|
|
|
|
|
2021-04-12 20:59:38 +00:00
|
|
|
@test "injector/Service: service with default port" {
|
|
|
|
cd `chart_dir`
|
|
|
|
local actual=$(helm template \
|
|
|
|
--show-only templates/injector-service.yaml \
|
|
|
|
. | tee /dev/stderr |
|
|
|
|
yq -r '.spec.ports[0].targetPort' | tee /dev/stderr)
|
|
|
|
[ "${actual}" = "8080" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "injector/Service: service with custom port" {
|
|
|
|
cd `chart_dir`
|
|
|
|
local actual=$(helm template \
|
|
|
|
--show-only templates/injector-service.yaml \
|
|
|
|
--set 'injector.port=8443' \
|
|
|
|
. | tee /dev/stderr |
|
|
|
|
yq -r '.spec.ports[0].targetPort' | tee /dev/stderr)
|
|
|
|
[ "${actual}" = "8443" ]
|
|
|
|
}
|
|
|
|
|
2019-12-19 15:57:51 +00:00
|
|
|
@test "injector/Service: disable with global.enabled false" {
|
|
|
|
cd `chart_dir`
|
2020-02-06 16:44:38 +00:00
|
|
|
local actual=$( (helm template \
|
|
|
|
--show-only templates/injector-service.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" ]
|
|
|
|
|
2020-02-06 16:44:38 +00:00
|
|
|
local actual=$( (helm template \
|
|
|
|
--show-only templates/injector-service.yaml \
|
2019-12-19 15:57:51 +00:00
|
|
|
--set 'global.enabled=false' \
|
|
|
|
--set 'injector.enabled=true' \
|
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)
|
2022-03-21 16:50:23 +00:00
|
|
|
[ "${actual}" = "true" ]
|
2019-12-19 15:57:51 +00:00
|
|
|
}
|
2020-12-07 15:31:54 +00:00
|
|
|
|
|
|
|
@test "injector/Service: generic annotations" {
|
|
|
|
cd `chart_dir`
|
|
|
|
local actual=$(helm template \
|
|
|
|
--show-only templates/injector-service.yaml \
|
|
|
|
--set 'injector.service.annotations=vaultIsAwesome: true' \
|
|
|
|
. | tee /dev/stderr |
|
|
|
|
yq -r '.metadata.annotations["vaultIsAwesome"]' | tee /dev/stderr)
|
|
|
|
[ "${actual}" = "true" ]
|
|
|
|
}
|