Skip to content

Commit f7b4a05

Browse files
committed
e2e/test.sh: removed the need for VEN_OWNING_TEAM
I spent 3 hours realizing that the reason the script was silently failing was because I was using an ID rather than a name as VEN_OWNING_TEAM. Since the team doesn't really matter in this test, I propose to just pick the first team that is returned by /v1/teams. That should avoid having to find out the name or ID of a team to run this script.
1 parent 161eee9 commit f7b4a05

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

hack/e2e/test.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ set -o xtrace
3838
# doesn't allow you to create registry service accounts.
3939
: ${VEN_API_KEY_PULL?}
4040

41-
# The Venafi Cloud team which will be the owner of the generated Venafi service
42-
# accounts.
43-
: ${VEN_OWNING_TEAM?}
44-
4541
# The Venafi Cloud zone (application/issuing_template) which will be used by the
4642
# issuer an policy.
4743
: ${VEN_ZONE?}
@@ -87,12 +83,16 @@ if ! gcloud container clusters get-credentials "${CLUSTER_NAME}"; then
8783
fi
8884
kubectl create ns venafi || true
8985

86+
# Let's pick the first team as the owning team as it doesn't matter for this
87+
# test.
88+
owningTeamID=$(curl --fail-with-body -sS https://api.venafi.cloud/v1/teams -H "tppl-api-key: $VEN_API_KEY" | jq '.teams[0].id' -r)
89+
9090
# Pull secret for Venafi OCI registry
9191
if ! kubectl get secret venafi-image-pull-secret -n venafi; then
9292
venctl iam service-accounts registry create \
9393
--api-key "${VEN_API_KEY_PULL}" \
9494
--no-prompts \
95-
--owning-team "${VEN_OWNING_TEAM}" \
95+
--owning-team "${owningTeamID}" \
9696
--name "venafi-kubernetes-agent-e2e-registry-${RANDOM}" \
9797
--scopes enterprise-cert-manager,enterprise-venafi-issuer,enterprise-approver-policy \
9898
| jq '{
@@ -129,12 +129,14 @@ venctl components kubernetes apply \
129129

130130
kubectl apply -n venafi -f venafi-components.yaml
131131

132+
132133
subject="system:serviceaccount:venafi:venafi-components"
133134
audience="https://${VEN_API_HOST}"
134135
issuerURL="$(kubectl create token -n venafi venafi-components | step crypto jwt inspect --insecure | jq -r '.payload.iss')"
135136
openidDiscoveryURL="${issuerURL}/.well-known/openid-configuration"
136137
jwksURI=$(curl --fail-with-body -sSL ${openidDiscoveryURL} | jq -r '.jwks_uri')
137138

139+
138140
# Create the Venafi agent service account if one does not already exist
139141
while true; do
140142
tenantID=$(curl --fail-with-body -sSL -H "tppl-api-key: $VEN_API_KEY" https://${VEN_API_HOST}/v1/serviceaccounts \
@@ -155,15 +157,14 @@ while true; do
155157
"issuerURL": $issuerURL,
156158
"jwksURI": $jwksURI,
157159
"applications": [$applications.applications[].id],
158-
"owner": $teams.teams[] | select(.name==$teamName) | .id
160+
"owner": $owningTeamID
159161
}' \
160162
--arg random "${RANDOM}" \
161-
--arg teamName "${VEN_OWNING_TEAM}" \
162163
--arg subject "${subject}" \
163164
--arg audience "${audience}" \
164165
--arg issuerURL "${issuerURL}" \
165166
--arg jwksURI "${jwksURI}" \
166-
--argjson teams "$(curl https://${VEN_API_HOST}/v1/teams --fail-with-body -sSL -H tppl-api-key:\ ${VEN_API_KEY})" \
167+
--arg owningTeamID "{$owningTeamID}" \
167168
--argjson applications "$(curl https://${VEN_API_HOST}/outagedetection/v1/applications --fail-with-body -sSL -H tppl-api-key:\ ${VEN_API_KEY})" \
168169
| curl https://${VEN_API_HOST}/v1/serviceaccounts \
169170
-H "tppl-api-key: $VEN_API_KEY" \

0 commit comments

Comments
 (0)