bin/test_integration
#!/bin/bash -ex cleanup() { echo "Cleaning up..." echo "Cleaning up... logs in cleanup.log" docker compose rm --stop --force} DEBUG="false"SDK_REPO_PATH=""function get_parameters() { while [[ $# -gt 0 ]]; do case $1 in -d | --debug) DEBUG="true" shift # past argument ;; -s | --sdk-repo-path) SDK_REPO_PATH="$2" shift # past argument shift # past value ;; *) echo "Unknown option $1" exit 1 ;; esac done}get_parameters $@ trap 'echo "ERROR: Test script encountered an error!"; docker compose logs &> cleanup.log; cleanup' ERRtrap 'cleanup' EXITcleanup echo "Building API container..."docker compose build test echo "Generating certificate..."docker compose up openssl echo "Starting Conjur..."docker compose up -d conjurdocker compose exec -T conjur conjurctl wait echo "Configuring Conjur..."admin_api_key=$(docker compose exec -T conjur conjurctl role retrieve-key dev:user:admin | tr -d '\r')export CONJUR_AUTHN_API_KEY=$admin_api_keyexport DEBUG=$DEBUGconjur_host_port=$(docker compose port conjur 80)conjur_port="${conjur_host_port##*:}"export TEST_HOSTNAME=conjur-https # Docker-compose will pick this file up when starting containers# so we will have these variables in the containercat <<ENV >.envCONJUR_AUTHN_API_KEY=$admin_api_keyDEBUG=$DEBUGENV echo "Starting test env..."docker compose up -d test "$TEST_HOSTNAME" --no-deps rm -rf $CURRENT_DIR/output/* if [[ -n "$SDK_REPO_PATH" ]]; then docker compose cp "$SDK_REPO_PATH" test:/ docker compose exec test /bin/sh -c " pip install /$SDK_REPO_PATH"fi # Hint: '--privileged' is added here otherwise we will get operation# not permitted when attempting to do anything related to dbusif [[ "$DEBUG" == "true" ]]; then docker compose exec --privileged test /bin/sh -c " /tests_executor.sh" $@ exitfiif [[ -n "$SDK_REPO_PATH" ]]; then docker compose exec \ test \ /bin/sh -c " /tests_executor.sh" $@ exitfidocker compose run \ --rm \ --no-deps \ test \ /bin/sh -c " /tests_executor.sh" $@