|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -eux |
| 4 | +set -o pipefail |
| 5 | + |
| 6 | +url="http://${hostname:?}" |
| 7 | + |
| 8 | +# This is a server error, which describes the need to set LOADBALANCER_IPS |
| 9 | +error_page=$(curl -sSi "$url") |
| 10 | +echo "$error_page" | grep -Ei "HTTP/\S+ 500" |
| 11 | +echo "$error_page" | grep "You have not configured any reverse proxies" |
| 12 | +echo "$error_page" | grep "LOADBALANCER_IPS" |
| 13 | + |
| 14 | +# This is a server error, which notes the reverse proxy exists |
| 15 | +error_page=$(curl -H "X-Forwarded-For: 1.2.3.4" -sSi "$url") |
| 16 | +echo "$error_page" | grep -Ei "HTTP/\S+ 500" |
| 17 | +echo "$error_page" | grep "You have not configured any reverse proxies" |
| 18 | +echo "$error_page" | grep "reverse proxy headers were detected" |
| 19 | +echo "$error_page" | grep "LOADBALANCER_IPS" |
| 20 | + |
| 21 | +# Restart with LOADBALANCER_IPS set |
| 22 | +"${docker[@]:?}" -f ci/http-only/with-loadbalancer-ips.yaml up -d --no-build --force-recreate zulip |
| 23 | + |
| 24 | +# Wait for it to come back up |
| 25 | +instance=$("${docker[@]}" ps -q zulip) |
| 26 | +timeout 300 bash -c \ |
| 27 | + "until docker inspect --format '{{.State.Health.Status}}' '$instance' | grep -q healthy; do sleep 5; done" |
| 28 | + |
| 29 | +# This is a server error, which notes the lack of X-Forwarded-Proto |
| 30 | +error_page=$(curl -H "X-Forwarded-For: 1.2.3.4" -sSi "$url") |
| 31 | +echo "$error_page" | grep -Ei "HTTP/\S+ 500" |
| 32 | +echo "$error_page" | grep "You have configured reverse proxies" |
| 33 | +echo "$error_page" | grep "X-Forwarded-Proto" |
| 34 | + |
| 35 | +# This is a 404 due to no realm existing |
| 36 | +error_page=$(curl -H "X-Forwarded-For: 1.2.3.4" -H "X-Forwarded-Proto: https" -sSi "$url") |
| 37 | +echo "$error_page" | grep -Ei "HTTP/\S+ 404" |
| 38 | + |
| 39 | +"${manage[@]:?}" create_realm 'Testing Realm' [email protected] 'Test Admin' --password very-secret |
| 40 | + |
| 41 | +success=$(curl -H "X-Forwarded-For: 1.2.3.4" -H "X-Forwarded-Proto: https" -sfLSi "$url") |
| 42 | +echo "$success" | grep "Testing Realm" |
| 43 | + |
| 44 | +exit 0 |
0 commit comments