diff --git a/test/default-host.bats b/test/default-host.bats index 0adf686..503bb9f 100644 --- a/test/default-host.bats +++ b/test/default-host.bats @@ -12,16 +12,7 @@ function setup { SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE}-1 # GIVEN a webserver with VIRTUAL_HOST set to web.bats - docker_clean bats-web - run docker run -d \ - --label bats-type="web" \ - --name bats-web \ - -e VIRTUAL_HOST=web.bats \ - --expose 80 \ - -w /var/www \ - python:3 \ - python -m http.server 80 - assert_success + prepare_web_container bats-web 80 -e VIRTUAL_HOST=web.bats # WHEN nginx-proxy runs with DEFAULT_HOST set to web.bats run nginxproxy $SUT_CONTAINER -v /var/run/docker.sock:/tmp/docker.sock:ro -e DEFAULT_HOST=web.bats diff --git a/test/docker.bats b/test/docker.bats index 13d84a2..44d31b9 100644 --- a/test/docker.bats +++ b/test/docker.bats @@ -62,7 +62,7 @@ load test_helpers -v /etc/nginx/certs/ \ nginx:latest assert_success - run retry 5 1s curl --silent --fail -A "before-docker-gen" --head http://$(docker_ip bats-nginx)/ + run retry 5 1s curl --silent --fail --head http://$(docker_ip bats-nginx)/ assert_output -l 0 $'HTTP/1.1 200 OK\r' # WHEN docker-gen runs on our docker host diff --git a/test/multiple-hosts.bats b/test/multiple-hosts.bats index 0380509..c5c5749 100644 --- a/test/multiple-hosts.bats +++ b/test/multiple-hosts.bats @@ -17,17 +17,7 @@ function setup { @test "[$TEST_FILE] nginx-proxy forwards requests for 2 hosts" { # WHEN a container runs a web server with VIRTUAL_HOST set for multiple hosts - docker_clean bats-multiple-hosts-1 - run docker run -d \ - --label bats-type="web" \ - --name bats-multiple-hosts-1 \ - -e VIRTUAL_HOST=multiple-hosts-1-A.bats,multiple-hosts-1-B.bats \ - --expose 80 \ - -w /data \ - python:3 python -m http.server 80 - assert_success - run retry 5 1s curl_container bats-multiple-hosts-1 / --head - assert_output -l 0 $'HTTP/1.0 200 OK\r' + prepare_web_container bats-multiple-hosts-1 80 -e VIRTUAL_HOST=multiple-hosts-1-A.bats,multiple-hosts-1-B.bats # THEN querying the proxy without Host header → 503 run curl_container $SUT_CONTAINER / --head @@ -38,10 +28,10 @@ function setup { assert_output -l 0 $'HTTP/1.1 503 Service Temporarily Unavailable\r' # THEN - run curl_container $SUT_CONTAINER / --head --header 'Host: multiple-hosts-1-A.bats' - assert_output -l 0 $'HTTP/1.1 200 OK\r' || (echo $output; echo $status; false) + run curl_container $SUT_CONTAINER /data --header 'Host: multiple-hosts-1-A.bats' + assert_output "answer from port 80" # THEN - run curl_container $SUT_CONTAINER / --head --header 'Host: multiple-hosts-1-B.bats' - assert_output -l 0 $'HTTP/1.1 200 OK\r' + run curl_container $SUT_CONTAINER /data --header 'Host: multiple-hosts-1-B.bats' + assert_output "answer from port 80" }