Skip to content

#17 Check if Set-Cookie headers are removed for cacheable content #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions tests/varnish/set_cookie_remove.vtc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
varnishtest "Check if Set-Cookie headers are removed for cacheable content"

server s1 {
# first request will be the probe, handle it and be on our way
rxreq
expect req.url == "/health_check.php"
txresp

# the probe expects the connection to close
close
accept

rxreq
expect req.url == "/"
expect req.method == "GET"
txresp -hdr "Cache-Control: public, max-age=86400" \
-hdr "Set-Cookie: testcookie=1; path=/; HttpOnly"
} -start

# Generate the VCL file based on included variables and write it to output.vcl
shell {
export s1_addr="${s1_addr}"
export s1_port="${s1_port}"
${testdir}/helpers/parse_vcl.pl "${testdir}/../../etc/varnish6.vcl" "${tmpdir}/output.vcl"
}

varnish v1 -arg "-f" -arg "${tmpdir}/output.vcl" -arg "-p" -arg "vsl_mask=+Hash" -start

# make sure the probe request fired
delay 1

logexpect l1 -v v1 -g request -i BerespUnset -q "ReqUrl eq '/'" {
expect 0 1002 BerespUnset "Set-Cookie: testcookie=1; path=/; HttpOnly"
} -start

client c1 {
txreq -method "GET" -url "/"
rxresp
expect resp.http.X-Magento-Cache-Debug == "MISS"
expect resp.http.Set-Cookie == <undef>

txreq -method "GET" -url "/"
rxresp
expect resp.http.X-Magento-Cache-Debug == "HIT"
expect resp.http.Set-Cookie == <undef>

txreq -method "HEAD" -url "/"
rxresp
expect resp.http.X-Magento-Cache-Debug == "HIT"
expect resp.http.Set-Cookie == <undef>
} -run

logexpect l1 -wait