Skip to content

Commit

Permalink
test: add a test-case for duplicate cookie headers
Browse files Browse the repository at this point in the history
  • Loading branch information
jkhsjdhjs committed Oct 3, 2023
1 parent dd36b05 commit aeda6b7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/fetch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -271,5 +271,34 @@ export default Test => [
resolve(true);
});
});
}),
new Test("fetch(): no duplicate header on redirect", () => {
const app = express();
app.use(cookieParser());
app.put("/", (request, response) => {
response.cookie("foo", "bar");
response.redirect(302, "/redirect");
});
app.put("/redirect", (request, response) => {
response.cookie("foo2", "bar");
response.redirect(303, "/redirect2");
});
app.get("/redirect2", (request, response) => {
if (request.headers["cookie"].split("foo=bar").length > 2) {
response.status(400);
}
response.send();
});
return new Promise(resolve => {
const server = app.listen(0, async () => {
const cookieJar = new CookieJar();
const response = await fetch(cookieJar, `http://localhost:${server.address().port}/`, {

Check failure on line 295 in test/fetch.mjs

View workflow job for this annotation

GitHub Actions / lint

Replace `cookieJar,·`http://localhost:${server.address().port}/`,` with `⏎····················cookieJar,⏎····················`http://localhost:${server.address().port}/`,⏎···················`
method: "PUT"

Check failure on line 296 in test/fetch.mjs

View workflow job for this annotation

GitHub Actions / lint

Insert `····`
});

Check failure on line 297 in test/fetch.mjs

View workflow job for this annotation

GitHub Actions / lint

Replace `················}` with `····················}⏎················`
server.close();
resolve(response.ok);
});

Check failure on line 300 in test/fetch.mjs

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎`

});
})
];

0 comments on commit aeda6b7

Please sign in to comment.