Skip to content

Commit

Permalink
feat(k8s-test): Try login and obtain API token
Browse files Browse the repository at this point in the history
  • Loading branch information
kiblik committed Aug 9, 2024
1 parent 0b105db commit d0ad114
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/k8s-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,35 @@ jobs:
break
fi
done
ADMIN_PASS=$(kubectl get secret/defectdojo -o json | jq -r '.data.DD_ADMIN_PASSWORD' | base64 -d)
echo "Simple Login check"
OUT=$(kubectl run curl --quiet=true --image=curlimages/curl:7.73.0 \
--overrides='{ "apiVersion": "v1" }' \
--restart=Never -i --rm -- -s -m 20 -I --header "Host: $DD_HOSTNAME" http://`kubectl get service defectdojo-django -o json \
| jq -r '.spec.clusterIP'`/login?next=/ --data-raw "username=admin&password=$ADMIN_PASS")
echo $OUT
CR=`echo $OUT | egrep "^HTTP" | cut -d' ' -f2`
echo $CR
if [[ $CR -ne 200 ]]; then
echo "ERROR: login is not possible; got HTTP code $CR"
exit 1
else
echo "Result received"
fi
echo "Simple API check"
OUT=$(kubectl run curl --quiet=true --image=curlimages/curl:7.73.0 \
--overrides='{ "apiVersion": "v1" }' \
--restart=Never -i --rm -- -s -m 20 -I --header "Host: $DD_HOSTNAME" http://`kubectl get service defectdojo-django -o json \
| jq -r '.spec.clusterIP'`/api/v2/api-token-auth/ --data-raw "username=admin&password=$ADMIN_PASS")
echo $OUT
CR=`echo $OUT | egrep "^HTTP" | cut -d' ' -f2`
echo $CR
if [[ $CR -ne 200 ]]; then
echo "ERROR: login is not possible; got HTTP code $CR"
exit 1
else
echo "Result received"
fi
echo "Final Check of components"
errors=`kubectl get pods | grep Error | awk '{print $1}'`
if [[ ! -z $errors ]]; then
Expand Down

0 comments on commit d0ad114

Please sign in to comment.