github.com/hellofresh/janus@v0.0.0-20230925145208-ce8de8183c67/build/mocks.sh (about) 1 #!/usr/bin/env bash 2 3 NO_COLOR='\033[0m' 4 OK_COLOR='\033[32;01m' 5 ERROR_COLOR='\033[31;01m' 6 WARN_COLOR='\033[33;01m' 7 8 AUTH_MOCK_PORT="9088" 9 if [[ -n "${DYNAMIC_AUTH_PORT}" ]]; then 10 AUTH_MOCK_PORT=${DYNAMIC_AUTH_PORT} 11 fi 12 13 UPSTREAMS_MOCK_PORT="9089" 14 if [[ -n "${DYNAMIC_UPSTREAMS_PORT}" ]]; then 15 UPSTREAMS_MOCK_PORT=${DYNAMIC_UPSTREAMS_PORT} 16 fi 17 18 echo "${OK_COLOR}Uploading auth mock fixture:${NO_COLOR}" 19 curl -X DELETE --silent --show-error --fail --output /dev/null "http://localhost:${AUTH_MOCK_PORT}/__admin/mappings" 20 for fixture in assets/stubs/auth-service/*; do 21 curl --silent --show-error --fail --output /dev/null "http://localhost:${AUTH_MOCK_PORT}/__admin/mappings" -d "@${fixture}" --header "Content-Type: application/json" 22 echo "Added fixture: ${fixture}" 23 done 24 25 echo "${OK_COLOR}Uploading upstreams mock fixture:${NO_COLOR}" 26 curl -X DELETE --silent --show-error --fail --output /dev/null "http://localhost:${UPSTREAMS_MOCK_PORT}/__admin/mappings" 27 for fixture in assets/stubs/upstreams/*; do 28 curl --silent --show-error --fail --output /dev/null "http://localhost:${UPSTREAMS_MOCK_PORT}/__admin/mappings" -d "@${fixture}" --header "Content-Type: application/json" 29 echo "Added fixture: ${fixture}" 30 done