Skip to content

Commit c46df18

Browse files
committed
github: Add a test of http-only serving.
1 parent 13cee53 commit c46df18

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

ci/http-only/compose.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
services:
3+
zulip:
4+
environment:
5+
DISABLE_HTTPS: True
6+
networks: [zulip-backend]
7+
8+
database:
9+
networks: [zulip-backend]
10+
memcached:
11+
networks: [zulip-backend]
12+
rabbitmq:
13+
networks: [zulip-backend]
14+
redis:
15+
networks: [zulip-backend]
16+
17+
networks:
18+
zulip-backend:
19+
driver: bridge
20+
ipam:
21+
driver: default
22+
config:
23+
- subnet: 172.28.0.0/16
24+
ip_range: 172.28.5.0/24
25+
gateway: 172.28.5.254

ci/http-only/env

Whitespace-only changes.

ci/http-only/test.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
services:
3+
zulip:
4+
environment:
5+
# This is the network's gateway address, set in compose.yaml, and the
6+
# Docker Desktop IP VM's address (for local testing).
7+
LOADBALANCER_IPS: 172.28.5.254,192.168.65.1

0 commit comments

Comments
 (0)