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 Jul 2, 2024
1 parent 6fc4bae commit 42a7617
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 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 All @@ -187,3 +216,27 @@ jobs:
else
echo "DD K8S successfully deployed"
fi
curl 'http://localhost:8080/login?next=/' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8' \
-H 'Accept-Language: en-GB,en' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Cookie: firefly_session=eyJpdiI6IlNrTjZoTThFQWwvVlgrQjN0ZUd1dVE9PSIsInZhbHVlIjoiZk55Mm85VTFhU0ZpZndjM3F0d3d1T3FNUWMxRmNVT0krS0JremsxTDBLdWJlbFNsdDhYdHhHeFBiaU5mZmNuSlNCRWsvaEVuUG45ZzVQTEwzQUkyMWtFR08vU0JRaU80aVJ4NWMrNFI5cVN4ZHRTTllZVFhEVU1VTlBDVHdVQXciLCJtYWMiOiI3OTY5M2M2YzliZDNlNDc2NDllMjUyMDliNzU0NjBlYWFmNzM5MjczYjg1MWNiYWZkOTIwZDNhM2JjYmFiYmRlIiwidGFnIjoiIn0%3D; connect.sid=s%3Aa6qlcBd8drYUT9T0OmLxWxtpYOzs9o6V.ZS5pTqajXzIUkpA07owtWtVngJ%2BZQP71gMglhPQgUI4; access_token=eyJpdiI6IjBUU21kL01ra3E4MHZ3djF1dlJqUkE9PSIsInZhbHVlIjoiUHFFV3NQSmhiTWFtRWtLRHFkTWNGRXBHancyYTJuYWgvQWdxSDh3ODhwOUhPdHdXcDNGN2t6Uy9Oa0lrM1IveUEzbitLYnQrZE5xWVplS3htVmxHclhSaE9zZ0xlMVhadW0yNnppa2dZK1YxMHAxeEx0UlF2R09oYjd6aUpZaUpReHMzeS9QazhZbWVhblFWand4emNjbng4emtjR3pEQmszYktqNU1zb2xXVCtsYzhYUElLeGVRL0JaeU9GM0pjek9vTUNYVlFMS1BhSGs1RzZPejVZT3piaEdyY0VnVlM5RGhlZ0FVcmxPK2pWOWZXUzgwN1ZCa2FmKzFvMlA5SkwvZ2FGbzNRakk1SHptSXV2OXJDTTBMYnJOVEUxRnpVMFpzRFhjYklsd2doK245Umw2NTRscWpXMk5TTkJMTk5LNVFvS211UmdvNWlaTEMxU3VTaUlXTThYcFFnRVQvM2xtL3Yv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I6IiJ9; refresh_token=eyJpdiI6IksxVGJMZ2VVVnMza0RRUFNvMzN5L2c9PSIsInZhbHVlIjoidmpNN2g2Nkg2ZlVQQnlRWG8wMUlPUGdNWVIyUG1pVjlzd1l2Uzg4anloRHplVmF5TXdhR09TUFZPNVNiM21ZTSIsIm1hYyI6ImY1NTExNjI1NWY2MGZkNzA4ZWQ0ZDFiZGVhNDFjYjRlYTI3YzAwYTg2N2NjODMwNWI1M2YyMDJiZGY1M2VkMzciLCJ0YWciOiIifQ%3D%3D; flow=eyJpdiI6IkN5OTdJYWI1REFrWThQQnFGTVA1L3c9PSIsInZhbHVlIjoibnNNbExHa2JoNXphWldESkJaQ2dnR1R3SS9TazY2R0tncmFlYkJ0OC9LYzc1Ym93OXRzcFFtTjkrUTZ4aGxMWCIsIm1hYyI6ImFhMzUwOTY2OGZhOWRhYjQ5YWEwYjNmYWMzOTU5OGVmYTE4NzkyZjNjNzJiN2RlZDMyYjcwOTAwYjUyMjViMWMiLCJ0YWciOiIifQ%3D%3D; csrftoken=HGbxIy9Yy0PMTPBXePHxsM6x6ZaWl832' \
-H 'Origin: http://localhost:8080' \
-H 'Pragma: no-cache' \
-H 'Referer: http://localhost:8080/login?next=/' \
-H 'Sec-Fetch-Dest: document' \
-H 'Sec-Fetch-Mode: navigate' \
-H 'Sec-Fetch-Site: same-origin' \
-H 'Sec-Fetch-User: ?1' \
-H 'Sec-GPC: 1' \
-H 'Upgrade-Insecure-Requests: 1' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36' \
-H 'sec-ch-ua: "Not/A)Brand";v="8", "Chromium";v="126", "Brave";v="126"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw 'csrfmiddlewaretoken=uMiPBTX9Ue7LmofKGBjWruu3seKEheQC1ijc9hWXi4Mn53GxKgQjJ6qqo3KqscJu&username=admin&password=admin'

0 comments on commit 42a7617

Please sign in to comment.