varnishtest "restart in vcl_miss #965"

server s1 {
	rxreq
	txresp
} -start

varnish v1 -vcl+backend {
	sub vcl_recv {
		if (req.http.X-Banned == "check") {
			unset req.http.X-Banned;
		} elseif (req.restarts == 0) {
			set req.http.X-Banned = "check";
			if (req.http.x-pass) {
				return (pass);
			} else {
				return (hash);
			}
		}
	}

	sub vcl_hash {
		## Check if they have a ban in the cache, or if they are going to be banned in cache.
		if (req.http.X-Banned) {
			hash_data(client.ip);
			return (lookup);
		}
	}

	sub vcl_synth {
		if (resp.status == 988) { return (restart); }
	}

	sub vcl_miss {
		if (req.http.X-Banned == "check") {
			return (synth(988,"restarting"));
		}
	}

	sub vcl_pass {
		if (req.http.X-Banned == "check") {
			return (synth(988,"restarting"));
		}
	}
} -start

client c1 {
	txreq
	rxresp
	expect resp.status == 200
	txreq
	rxresp
	expect resp.status == 200
	txreq -hdr "X-Pass: 1"
	rxresp
	expect resp.status == 200
} -run
