Commit f6684104 authored by Geoff Simmons's avatar Geoff Simmons

Automate un-/deployment of the Basic/Proxy Auth examples.

parent ea7c9b99
# looks like -*- vcl -*-
varnishtest "cafe example, proxy authentication"
client c1 -connect "${localhost} ${localport}" {
txreq -url /coffee -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 401
expect resp.reason == "Unauthorized"
expect resp.http.WWW-Authenticate == {Basic realm="cafe"}
txreq -url /coffee -hdr "Host: cafe.example.com" \
-hdr "X-Real-IP: 127.0.0.1"
rxresp
expect resp.status == 401
expect resp.reason == "Unauthorized"
expect resp.http.WWW-Authenticate == {Basic realm="cafe"}
txreq -url /coffee -hdr "Host: cafe.example.com" \
-hdr "X-Real-IP: 192.0.2.1"
rxresp
expect resp.status == 200
# credentials foo:bar
txreq -url /coffee -hdr "Host: cafe.example.com" \
-hdr "Authorization: Basic Zm9vOmJhcg=="
rxresp
expect resp.status == 200
txreq -url /coffee -hdr "Host: cafe.example.com" \
-hdr "Authorization: Basic Zm9vOmJhcg==" \
-hdr "X-Real-IP: 127.0.0.1"
rxresp
expect resp.status == 200
} -run
# looks like -*- vcl -*-
varnishtest "cafe example, basic authentication"
client c1 -connect "${localhost} ${localport}" {
txreq -url /coffee -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 401
expect resp.reason == "Unauthorized"
expect resp.http.WWW-Authenticate == {Basic realm="coffee", charset="UTF-8"}
txreq -url /tea -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 401
expect resp.reason == "Unauthorized"
expect resp.http.WWW-Authenticate == {Basic realm="tea"}
# credentials foo:bar
txreq -url /coffee -hdr "Host: cafe.example.com" \
-hdr "Authorization: Basic Zm9vOmJhcg=="
rxresp
expect resp.status == 200
# credentials tea-admin:awesomeness
txreq -url /tea -hdr "Host: cafe.example.com" \
-hdr "Authorization: Basic dGVhLWFkbWluOmF3ZXNvbWVuZXNz"
rxresp
expect resp.status == 200
txreq -url /milk -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 404
} -run
# looks like -*- vcl -*-
varnishtest "cafe example, proxy authentication"
client c1 -connect "${localhost} ${localport}" {
txreq -url /coffee -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 407
expect resp.reason == "Proxy Authentication Required"
expect resp.http.Proxy-Authenticate == {Basic realm="ingress"}
# credentials proxy-admin:studly
txreq -url /coffee -hdr "Host: cafe.example.com" \
-hdr "Proxy-Authorization: Basic cHJveHktYWRtaW46c3R1ZGx5"
rxresp
expect resp.status == 200
} -run
#! /bin/bash -ex
kubectl apply -f ../hello/cafe.yaml
kubectl apply -f ../hello/cafe-ingress.yaml
kubectl apply -f basic-secrets.yaml
kubectl apply -f acl-or-auth.yaml
#! /bin/bash -ex
kubectl apply -f ../hello/cafe.yaml
kubectl apply -f ../hello/cafe-ingress.yaml
kubectl apply -f basic-secrets.yaml
kubectl apply -f basic-auth.yaml
#! /bin/bash -ex
kubectl apply -f ../hello/cafe.yaml
kubectl apply -f ../hello/cafe-ingress.yaml
kubectl apply -f proxy-auth-secrets.yaml
kubectl apply -f proxy-auth.yaml
#! /bin/bash -ex
kubectl delete -f acl-or-auth.yaml
kubectl delete -f basic-secrets.yaml
kubectl delete -f ../hello/cafe-ingress.yaml
kubectl delete -f ../hello/cafe.yaml
echo "Waiting until varnish-ingress Pods are not ready"
N=0
until [ $N -ge 120 ]
do
if kubectl get pods -l app=varnish-ingress | grep -q ' 1/1'; then
sleep 10
N=$(( N + 10 ))
continue
fi
exit 0
done
echo "Giving up"
exit 1
#! /bin/bash -ex
kubectl delete -f basic-auth.yaml
kubectl delete -f basic-secrets.yaml
kubectl delete -f ../hello/cafe-ingress.yaml
kubectl delete -f ../hello/cafe.yaml
echo "Waiting until varnish-ingress Pods are not ready"
N=0
until [ $N -ge 120 ]
do
if kubectl get pods -l app=varnish-ingress | grep -q ' 1/1'; then
sleep 10
N=$(( N + 10 ))
continue
fi
exit 0
done
echo "Giving up"
exit 1
#! /bin/bash -ex
kubectl delete -f proxy-auth.yaml
kubectl delete -f proxy-auth-secrets.yaml
kubectl delete -f ../hello/cafe-ingress.yaml
kubectl delete -f ../hello/cafe.yaml
echo "Waiting until varnish-ingress Pods are not ready"
N=0
until [ $N -ge 120 ]
do
if kubectl get pods -l app=varnish-ingress | grep -q ' 1/1'; then
sleep 10
N=$(( N + 10 ))
continue
fi
exit 0
done
echo "Giving up"
exit 1
#! /bin/bash -ex
function killforward {
kill $KUBEPID
}
LOCALPORT=${LOCALPORT:-8888}
kubectl wait --timeout=2m pod -l app=varnish-ingress --for=condition=Ready
kubectl port-forward svc/varnish-ingress ${LOCALPORT}:80 >/dev/null &
KUBEPID=$!
trap killforward EXIT
sleep 1
varnishtest ${TESTOPTS} -Dlocalport=${LOCALPORT} cafe_acl_or_auth.vtc
#! /bin/bash -ex
function killforward {
kill $KUBEPID
}
LOCALPORT=${LOCALPORT:-8888}
kubectl wait --timeout=2m pod -l app=varnish-ingress --for=condition=Ready
kubectl port-forward svc/varnish-ingress ${LOCALPORT}:80 >/dev/null &
KUBEPID=$!
trap killforward EXIT
sleep 1
varnishtest ${TESTOPTS} -Dlocalport=${LOCALPORT} cafe_basic_auth.vtc
#! /bin/bash -ex
function killforward {
kill $KUBEPID
}
LOCALPORT=${LOCALPORT:-8888}
kubectl wait --timeout=2m pod -l app=varnish-ingress --for=condition=Ready
kubectl port-forward svc/varnish-ingress ${LOCALPORT}:80 >/dev/null &
KUBEPID=$!
trap killforward EXIT
sleep 1
varnishtest ${TESTOPTS} -Dlocalport=${LOCALPORT} cafe_proxy_auth.vtc
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment