Skip to content

Commit 466e99d

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 <hello@matteocollina.com>
1 parent 9f10f1e commit 466e99d

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
@@ -2308,6 +2308,33 @@ describe('Cache Interceptor', () => {
23082308
}
23092309
})
23102310

2311+
test('does not crash on mixed unqualified and qualified private directives', async () => {
2312+
let requestsToOrigin = 0
2313+
const server = createServer({ joinDuplicateHeaders: true }, (_, res) => {
2314+
requestsToOrigin++
2315+
res.setHeader('cache-control', 'public, max-age=60, private, private="hdr"')
2316+
res.end(`response ${requestsToOrigin}`)
2317+
}).listen(0)
2318+
2319+
await once(server, 'listening')
2320+
2321+
const client = new Client(`http://localhost:${server.address().port}`)
2322+
.compose(interceptors.cache())
2323+
2324+
try {
2325+
const res = await client.request({
2326+
origin: 'localhost',
2327+
method: 'GET',
2328+
path: '/'
2329+
})
2330+
equal(requestsToOrigin, 1)
2331+
strictEqual(await res.body.text(), 'response 1')
2332+
} finally {
2333+
await client.close()
2334+
await new Promise(resolve => server.close(resolve))
2335+
}
2336+
})
2337+
23112338
test('does not cache response when request has Authorization and response only has max-age', async () => {
23122339
let requestsToOrigin = 0
23132340
const server = createServer({ joinDuplicateHeaders: true }, (_, res) => {

0 commit comments

Comments
 (0)