Skip to content

Commit 9f09b49

Browse files
UlisesGasconmcollina
authored andcommitted
test: cover crash on mixed unqualified and qualified private cache directives
Ref: GHSA-4cwx-7wf7-3272 Signed-off-by: Matteo Collina <[email protected]>
1 parent 4fe5bc5 commit 9f09b49

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

‎test/interceptors/cache.js‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2992,6 +2992,33 @@ describe('Cache Interceptor', () => {
29922992
}
29932993
})
29942994

2995+
test('does not crash on mixed unqualified and qualified private directives', async () => {
2996+
let requestsToOrigin = 0
2997+
const server = createServer({ joinDuplicateHeaders: true }, (_, res) => {
2998+
requestsToOrigin++
2999+
res.setHeader('cache-control', 'public, max-age=60, private, private="hdr"')
3000+
res.end(`response ${requestsToOrigin}`)
3001+
}).listen(0)
3002+
3003+
await once(server, 'listening')
3004+
3005+
const client = new Client(`http://localhost:${server.address().port}`)
3006+
.compose(interceptors.cache())
3007+
3008+
try {
3009+
const res = await client.request({
3010+
origin: 'localhost',
3011+
method: 'GET',
3012+
path: '/'
3013+
})
3014+
equal(requestsToOrigin, 1)
3015+
strictEqual(await res.body.text(), 'response 1')
3016+
} finally {
3017+
await client.close()
3018+
await new Promise(resolve => server.close(resolve))
3019+
}
3020+
})
3021+
29953022
test('does not cache response when request has Authorization and response only has max-age', async () => {
29963023
let requestsToOrigin = 0
29973024
const server = createServer({ joinDuplicateHeaders: true }, (_, res) => {

0 commit comments

Comments
 (0)