vtest "cgit ESI diff fragments are shared across repositories" # Run with: varnishtest -D cgit_vcl=$PWD/cgit-esi.vcl cgit-esi.vtc server s1 { # Frame for the commit as seen through fork a.git rxreq expect req.url == "/a.git/commit/?id=abc" txresp -hdr {Surrogate-Control: content="ESI/1.0"} \ -body {A::Z} # The fragment, fetched exactly once rxreq expect req.url == "/a.git/esi-diff/?id=abc&id2=def&dt=0" expect req.http.Cookie == txresp -body {
DIFF
} # Frame for the same commit through fork b.git; no fragment fetch follows rxreq expect req.url == "/b.git/commit/?id=abc&h=next" txresp -hdr {Surrogate-Control: content="ESI/1.0"} \ -body {B::Z} # A different diff option is a different fragment rxreq expect req.url == "/b.git/commit/?id=abc&dt=1" txresp -hdr {Surrogate-Control: content="ESI/1.0"} \ -body {B::Z} rxreq expect req.url == "/b.git/esi-diff/?id=abc&id2=def&dt=1" txresp -body {SSDIFF
} } -start varnish v1 -vcl+backend { include "${cgit_vcl}"; } -start client c1 { txreq -url "/a.git/commit/?id=abc" -hdr "Cookie: session=1" rxresp expect resp.status == 200 expect resp.http.Surrogate-Control == expect resp.body == "A:
DIFF
:Z" txreq -url "/b.git/commit/?id=abc&h=next" rxresp expect resp.status == 200 expect resp.body == "B:
DIFF
:Z" txreq -url "/b.git/commit/?id=abc&dt=1" rxresp expect resp.status == 200 expect resp.body == "B:SSDIFF
:Z" # Fragments cannot be fetched from the outside txreq -url "/a.git/esi-diff/?id=abc&id2=def&dt=0" rxresp expect resp.status == 403 } -run # Two frames, two distinct fragments: four backend fetches in total, i.e. # the second fork did not re-render the diff. varnish v1 -expect n_object == 4 varnish v1 -expect cache_hit == 1