Skip to content

Commit

Permalink
fix bats tests
Browse files Browse the repository at this point in the history
  • Loading branch information
missylbytes committed Aug 7, 2023
1 parent 4722f9a commit c3bcb63
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
14 changes: 5 additions & 9 deletions charts/consul/test/unit/connect-inject-clusterrole.bats
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,17 @@ load _helpers
-s templates/connect-inject-clusterrole.yaml \
--set 'global.openshift.enabled=true' \
. | tee /dev/stderr |
yq -r '.rules[13]' | tee /dev/stderr | pbcopy)

local actual=$(echo $object | yq -r '.resourceNames[| index("restricted-v2")' | tee /dev/stderr)
[ "${actual}" != null ]
yq '.rules[13].resourceNames | index("restricted-v2")' | tee /dev/stderr)
[ "${object}" == 0 ]
}

@test "connectInject/ClusterRole: adds permission to securitycontextconstraints for Openshift with global.openshift.enabled=true and sets apiGateway Openshift SCC Name" {
cd `chart_dir`
local object=$(helm template \
-s templates/connect-inject-clusterrole.yaml \
--set 'global.openshift.enabled=true' \
--set '.Values.connectInject.apiGateway.openshiftSccName="fakescc"' \
--set 'connectInject.apiGateway.managedGatewayClass.openshiftSccName=fakescc' \
. | tee /dev/stderr |
yq -r '.rules[13]' | tee /dev/stderr | pbcopy)

local actual=$(echo $object | yq -r '.resourceNames[| index("fakescc")' | tee /dev/stderr)
[ "${actual}" != null ]
yq '.rules[13].resourceNames | index("fakescc")' | tee /dev/stderr)
[ "${object}" == 0 ]
}
7 changes: 7 additions & 0 deletions charts/consul/test/unit/gateway-resources-job.bats
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ target=templates/gateway-resources-job.yaml
--set 'connectInject.apiGateway.managedGatewayClass.tolerations=- key: bar' \
--set 'connectInject.apiGateway.managedGatewayClass.copyAnnotations.service.annotations=- bingo' \
--set 'connectInject.apiGateway.managedGatewayClass.serviceType=Foo' \
--set 'connectInject.apiGateway.managedGatewayClass.openshiftSccName=hello' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].args' | tee /dev/stderr)

Expand Down Expand Up @@ -121,6 +122,12 @@ target=templates/gateway-resources-job.yaml

local actual=$(echo "$spec" | jq '.[16]')
[ "${actual}" = "\"- bingo\"" ]

local actual=$(echo "$spec" | jq '.[17]')
[ "${actual}" = "\"-service-type=Foo\"" ]

local actual=$(echo "$spec" | jq '.[18]')
[ "${actual}" = "\"-openshift-scc-name=hello\"" ]
}


Expand Down

0 comments on commit c3bcb63

Please sign in to comment.