You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1004 B

  1. #!/usr/bin/env bash
  2. CMD_ARGS=$1
  3. KEYCLOAK_DOCKER_IMAGE="quay.io/keycloak/keycloak:latest"
  4. function keycloak_stop() {
  5. docker stop unittest_keycloak &> /dev/null
  6. docker rm unittest_keycloak &> /dev/null
  7. }
  8. function keycloak_start() {
  9. echo "Starting keycloak docker container"
  10. docker run -d --name unittest_keycloak -e KEYCLOAK_ADMIN="${KEYCLOAK_ADMIN}" -e KEYCLOAK_ADMIN_PASSWORD="${KEYCLOAK_ADMIN_PASSWORD}" -e KC_FEATURES="token-exchange" -p "${KEYCLOAK_PORT}:8080" "${KEYCLOAK_DOCKER_IMAGE}" start-dev
  11. SECONDS=0
  12. until curl --silent --output /dev/null localhost:$KEYCLOAK_PORT; do
  13. sleep 5;
  14. if [ ${SECONDS} -gt 180 ]; then
  15. echo "Timeout exceeded";
  16. exit 1;
  17. fi
  18. done
  19. }
  20. # Ensuring that keycloak is stopped in case of CTRL-C
  21. trap keycloak_stop err exit
  22. keycloak_stop # In case it did not shut down correctly last time.
  23. keycloak_start
  24. eval ${CMD_ARGS}
  25. RETURN_VALUE=$?
  26. docker logs unittest_keycloak > keycloak_test_logs.txt
  27. exit ${RETURN_VALUE}