From ccc4fb856bb34a5a3345c8caa55aca047af0ce28 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 14 Oct 2023 11:06:31 +0200 Subject: [PATCH] Fix testing --- .gitignore | 2 ++ Makefile | 16 ++++------------ docker-compose-latest.test.yml | 7 +++---- test.sh | 4 +--- 4 files changed, 10 insertions(+), 19 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a76642c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env* +!.env.dist diff --git a/Makefile b/Makefile index 3ec82ec..d1b1792 100644 --- a/Makefile +++ b/Makefile @@ -27,18 +27,10 @@ docker-test: test test: run-test cleanup-test run-test: - TEST_ADDR="${TEST_ADDR}" \ - IMAGE_TAG="${IMAGE_TAG}" \ - DMARC_SRG_UI_PASSWORD="public" \ - # Random port maybe free ? - DMARC_SRG_HTTP_ADDRESS="8912" \ - docker-compose -f docker-compose-latest.test.yml up --exit-code-from=sut --abort-on-container-exit + IMAGE_TAG="$(IMAGE_TAG)" \ + docker compose -f docker-compose-latest.test.yml up --exit-code-from=sut --abort-on-container-exit cleanup-test: @echo "Stopping and removing the container" - TEST_ADDR="${TEST_ADDR}" \ - IMAGE_TAG="${IMAGE_TAG}" \ - DMARC_SRG_UI_PASSWORD="public" \ - # Random port maybe free ? - DMARC_SRG_HTTP_ADDRESS="8912" \ - docker-compose -f docker-compose-latest.test.yml down + IMAGE_TAG="$(IMAGE_TAG)" \ + docker compose -f docker-compose-latest.test.yml down diff --git a/docker-compose-latest.test.yml b/docker-compose-latest.test.yml index 68fedc0..8ed6b88 100644 --- a/docker-compose-latest.test.yml +++ b/docker-compose-latest.test.yml @@ -5,7 +5,7 @@ services: container_name: test-bench image: ${IMAGE_TAG} environment: - TEST_ADDR: ${TEST_ADDR} + TEST_ADDR: dmarc-srg volumes: - ./test.sh:/test.sh:ro entrypoint: ["/test.sh"] @@ -16,6 +16,7 @@ services: dmarc-srg: image: ${IMAGE_TAG} container_name: dmarc-srg + user: application healthcheck: test: [ @@ -36,7 +37,5 @@ services: IMAP_HOST: $DMARC_SRG_IMAP_HOST IMAP_USER: $DMARC_SRG_IMAP_USER IMAP_PASSWORD: $DMARC_SRG_IMAP_PASSWORD - UI_PASSWORD: $DMARC_SRG_UI_PASSWORD - ports: - - ${DMARC_SRG_HTTP_ADDRESS:-8082}:80 + UI_PASSWORD: public restart: on-failure:2 diff --git a/test.sh b/test.sh index 591bf1d..6501a47 100755 --- a/test.sh +++ b/test.sh @@ -8,7 +8,6 @@ checkUrl() { set +e if [ "${2:-}" = "form" ]; then curl -# --cookie-jar /tmp/test.cookie-jar -b /tmp/test.cookie-jar --show-error --fail-with-body \ - -s \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ -L \ @@ -16,7 +15,6 @@ checkUrl() { "$1" else curl -# --cookie-jar /tmp/test.cookie-jar -b /tmp/test.cookie-jar --show-error --fail-with-body \ - -s \ ${2:-} \ -H 'Content-Type: application/json' \ "$1" @@ -40,7 +38,7 @@ checkUrl "http://${TEST_ADDR}/robots.txt" -I checkUrl "http://${TEST_ADDR}/css/main.css" -I | grep -F "Cache-Control: max-age=86400" checkUrl "http://${TEST_ADDR}/index.php" | grep -q -F "DMARC Reports" -checkUrl "http://${TEST_ADDR}/login.php" "form" "{"password":"public"}" | grep -q -F "Successfully logged into server." +checkUrl "http://${TEST_ADDR}/login.php" "form" '{"password":"public"}' | grep -q -F "Authentication succeeded" if [ $DID_FAIL -gt 0 ]; then echo "Some URLs failed"