Skip to content

Commit 24e02f3

Browse files
wallrjmaelvls
andauthored
Update E2E test to check for certificate in the API (#629)
Signed-off-by: Richard Wall <[email protected]> Co-authored-by: Maël Valais <[email protected]>
1 parent a9cdc3f commit 24e02f3

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

hack/e2e/test.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,40 @@ kubectl -n team-1 wait certificate app-0 --for=condition=Ready
195195
# Parse logs as JSON using jq to ensure logs are all JSON formatted.
196196
# Disable pipefail to prevent SIGPIPE (141) errors from tee
197197
# See https://unix.stackexchange.com/questions/274120/pipe-fail-141-when-piping-output-into-tee-why
198+
set +o pipefail
198199
kubectl logs deployments/venafi-kubernetes-agent \
199200
--follow \
200201
--namespace venafi \
201202
| timeout 60 jq 'if .msg | test("Data sent successfully") then . | halt_error(0) end'
203+
set -o pipefail
204+
205+
# Create a unique TLS Secret and wait for it to appear in the Venafi certificate
206+
# inventory API. The case conversion is due to macOS' version of uuidgen which
207+
# prints UUIDs in upper case, but DNS labels need lower case characters.
208+
commonname="venafi-kubernetes-agent-e2e.$(uuidgen | tr '[:upper:]' '[:lower:]')"
209+
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /tmp/tls.key -out /tmp/tls.crt -subj "/CN=$commonname"
210+
kubectl create secret tls "$commonname" --cert=/tmp/tls.crt --key=/tmp/tls.key -o yaml --dry-run=client | kubectl apply -f -
211+
212+
getCertificate() {
213+
jq -n '{
214+
"expression": {
215+
"field": "subjectCN",
216+
"operator": "MATCH",
217+
"value": $commonname
218+
},
219+
"ordering": {
220+
"orders": [
221+
{ "direction": "DESC", "field": "certificatInstanceModificationDate" }
222+
]
223+
},
224+
"paging": { "pageNumber": 0, "pageSize": 10 }
225+
}' --arg commonname "${commonname}" \
226+
| curl "https://${VEN_API_HOST}/outagedetection/v1/certificatesearch?excludeSupersededInstances=true&ownershipTree=true" \
227+
-fsSL \
228+
-H "tppl-api-key: $VEN_API_KEY" \
229+
--json @- \
230+
| jq 'if .count == 0 then . | halt_error(1) end'
231+
}
232+
233+
# Wait 5 minutes for the certificate to appear.
234+
for ((i=0;;i++)); do if getCertificate; then exit 0; fi; sleep 30; done | timeout -v -- 5m cat

0 commit comments

Comments
 (0)