Переглянути джерело

Swap to "tcp" so we can test "https" too and use "--connect-to" to MITM _all_ curl destinations

Tianon Gravi 7 роки тому
батько
коміт
97cf3fd9f6

+ 7 - 4
test/tests/haproxy-basics/haproxy.cfg

@@ -1,10 +1,13 @@
 defaults
-	mode http
+	mode tcp
 	timeout connect 5000ms
 	timeout client 50000ms
 	timeout server 50000ms
 frontend http-in
 	bind *:80
-	default_backend google
-backend google
-	server google0 www.google.com
+	default_backend example
+frontend https-in
+	bind *:443
+	default_backend example
+backend example
+	server example0 example.com

+ 7 - 3
test/tests/haproxy-basics/run.sh

@@ -23,6 +23,9 @@ _request() {
 	local method="$1"
 	shift
 
+	local proto="$1"
+	shift
+
 	local url="${1#/}"
 	shift
 
@@ -33,10 +36,11 @@ _request() {
 	fi
 
 	docker run --rm --link "$cid":haproxy "$clientImage" \
-		curl -fsSL -X"$method" --resolve www.google.com:80:$(docker inspect -f '{{.NetworkSettings.IPAddress}}' $cid) "$@" "http://www.google.com/$url"
+		curl -fsSL -X"$method" --connect-to '::haproxy:' "$@" "$proto://example.com/$url"
 }
 
 . "$dir/../../retry.sh" '[ "$(_request GET / --output /dev/null || echo $?)" != 7 ]'
 
-# Check that we can request / (which is proxying google.com)
-[[ "$(_request GET '/')" == *Google* ]]
+# Check that we can request / (which is proxying example.com)
+_request GET http '/' | grep -q '<h1>Example Domain</h1>'
+_request GET https '/' | grep -q '<h1>Example Domain</h1>'