varnishtest "client.identity is 0.0.0.0 if unset & client addr is UDS"
# varnishtest "vtc remote.ip, remote.port and remote.path" (a00020)

server s1 {
	rxreq
	expect remote.ip == "${localhost}"
	expect remote.port > 0
	expect remote.path == <undef>
	txresp
} -start

varnish v1 -vcl+backend {} -start

client c1 {
	txreq
	rxresp
	expect remote.ip == "${v1_addr}"
	expect remote.port == "${v1_port}"
	expect remote.path == <undef>
} -run

varnish v1 -stop

server s1 -wait
server s1 -start

varnish v2 -arg "-a ${tmpdir}/v2.sock" -vcl+backend {} -start

client c1 -connect "${tmpdir}/v2.sock" {
	txreq
	rxresp
	expect remote.ip == "0.0.0.0"
	expect remote.port == 0
	expect remote.path == "${tmpdir}/v2.sock"
} -run

varnish v3 -arg "-a ${tmpdir}/v3.sock" -vcl {
	backend b None;

	sub vcl_recv {
		if (req.url == "/nobody") {
			set client.identity = "Samuel B. Nobody";
		}
		set req.http.id = client.identity;
		return(synth(200));
	}

	sub vcl_synth {
		set resp.http.id = req.http.id;
	}
} -start

client c2 -connect "${tmpdir}/v3.sock" {
	txreq -url "/nobody"
	rxresp
	expect resp.status == 200
	expect resp.http.id == "Samuel B. Nobody"
	txreq
	rxresp
	expect resp.status == 200
	expect resp.http.id == "0.0.0.0"
} -run
