Skip to content

Commit

Permalink
Fixing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmurret committed Feb 17, 2022
1 parent df1d4f7 commit 57eeab2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 31 deletions.
16 changes: 6 additions & 10 deletions charts/consul/test/unit/client-daemonset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1859,26 +1859,22 @@ rollingUpdate:
[ "${actual}" = "${expected}" ]
}

@test "client/DaemonSet: vault no CONSUL_LICENSE_PATH env variable and command defines CONSUL_LICENSE_PATH" {
@test "client/DaemonSet: vault CONSUL_LICENSE_PATH is set to /vault/secrets/enterpriselicense.txt" {
cd `chart_dir`
local object=$(helm template \
local env=$(helm template \
-s templates/client-daemonset.yaml \
--set 'global.secretsBackend.vault.enabled=true' \
--set 'global.secretsBackend.vault.consulClientRole=foo' \
--set 'global.secretsBackend.vault.consulServerRole=test' \
--set 'global.enterpriseLicense.secretName=a/b/c/d' \
--set 'global.enterpriseLicense.secretKey=enterpriselicense' \
. | tee /dev/stderr |
yq -r '.spec.template.spec' | tee /dev/stderr)
yq -r '.spec.template.spec.containers[0].env[]' | tee /dev/stderr)

local actual=$(echo $object |
yq -r '.containers[] | select(.name=="consul") | .env[] | select(.name == "CONSUL_LICENSE_PATH")' | tee /dev/stderr)
[ "${actual}" = "" ]
local actual

local actual=$(echo $object |
yq -r '.containers[] | select(.name=="consul") | .command | any(contains("CONSUL_LICENSE_PATH="))' \
| tee /dev/stderr)
[ "${actual}" = "true" ]
local actual=$(echo $env | jq -r '. | select(.name == "CONSUL_LICENSE_PATH") | .value' | tee /dev/stderr)
[ "${actual}" = "/vault/secrets/enterpriselicense.txt" ]
}

@test "client/DaemonSet: vault does not add volume for license secret" {
Expand Down
16 changes: 6 additions & 10 deletions charts/consul/test/unit/client-snapshot-agent-deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,9 @@ exec /bin/consul snapshot agent \'
[ "${actual}" = "${expected}" ]
}

@test "client/SnapshotAgentDeployment: vault no CONSUL_LICENSE_PATH env variable and command defines CONSUL_LICENSE_PATH" {
@test "client/SnapshotAgentDeployment: vault CONSUL_LICENSE_PATH is set to /vault/secrets/enterpriselicense.txt" {
cd `chart_dir`
local object=$(helm template \
local env=$(helm template \
-s templates/client-snapshot-agent-deployment.yaml \
--set 'client.snapshotAgent.enabled=true' \
--set 'global.secretsBackend.vault.enabled=true' \
Expand All @@ -618,16 +618,12 @@ exec /bin/consul snapshot agent \'
--set 'global.enterpriseLicense.secretName=a/b/c/d' \
--set 'global.enterpriseLicense.secretKey=enterpriselicense' \
. | tee /dev/stderr |
yq -r '.spec.template.spec' | tee /dev/stderr)
yq -r '.spec.template.spec.containers[0].env[]' | tee /dev/stderr)

local actual=$(echo $object |
yq -r '.containers[] | select(.name=="consul-snapshot-agent") | .env[] | select(.name == "CONSUL_LICENSE_PATH")' | tee /dev/stderr)
[ "${actual}" = "" ]
local actual

local actual=$(echo $object |
yq -r '.containers[] | select(.name=="consul-snapshot-agent") | .command | any(contains("CONSUL_LICENSE_PATH="))' \
| tee /dev/stderr)
[ "${actual}" = "true" ]
local actual=$(echo $env | jq -r '. | select(.name == "CONSUL_LICENSE_PATH") | .value' | tee /dev/stderr)
[ "${actual}" = "/vault/secrets/enterpriselicense.txt" ]
}

@test "client/SnapshotAgentDeployment: vault does not add volume for license secret" {
Expand Down
18 changes: 7 additions & 11 deletions charts/consul/test/unit/server-statefulset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1888,26 +1888,22 @@ load _helpers
[ "${actual}" = "${expected}" ]
}

@test "server/StatefulSet: vault no CONSUL_LICENSE_PATH env variable and command defines CONSUL_LICENSE_PATH" {
@test "server/StatefulSet: vault CONSUL_LICENSE_PATH is set to /vault/secrets/enterpriselicense.txt" {
cd `chart_dir`
local object=$(helm template \
-s templates/server-statefulset.yaml \
local env=$(helm template \
-s templates/server-statefulset.yaml \
--set 'global.secretsBackend.vault.enabled=true' \
--set 'global.secretsBackend.vault.consulClientRole=foo' \
--set 'global.secretsBackend.vault.consulServerRole=test' \
--set 'global.enterpriseLicense.secretName=a/b/c/d' \
--set 'global.enterpriseLicense.secretKey=enterpriselicense' \
. | tee /dev/stderr |
yq -r '.spec.template.spec' | tee /dev/stderr)
yq -r '.spec.template.spec.containers[0].env[]' | tee /dev/stderr)

local actual=$(echo $object |
yq -r '.containers[] | select(.name=="consul") | .env[] | select(.name == "CONSUL_LICENSE_PATH")' | tee /dev/stderr)
[ "${actual}" = "" ]
local actual

local actual=$(echo $object |
yq -r '.containers[] | select(.name=="consul") | .command | any(contains("CONSUL_LICENSE_PATH="))' \
| tee /dev/stderr)
[ "${actual}" = "true" ]
local actual=$(echo $env | jq -r '. | select(.name == "CONSUL_LICENSE_PATH") | .value' | tee /dev/stderr)
[ "${actual}" = "/vault/secrets/enterpriselicense.txt" ]
}

@test "server/StatefulSet: vault does not add volume for license secret" {
Expand Down

0 comments on commit 57eeab2

Please sign in to comment.