Skip to content
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

@GH-215 -- Tests that document localhost behavior when set as domain. #221

Merged
merged 1 commit into from Oct 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 43 additions & 0 deletions test/regression_test.js
Expand Up @@ -188,4 +188,47 @@ vows
}
}
})
.addBatch({
"setCookie with localhost (GH-215)": {
topic: function() {
const cookieJar = new CookieJar();
return cookieJar.setCookieSync("a=b; Domain=localhost", "http://localhost") // when domain set to 'localhost', will throw 'Error: Cookie has domain set to a public suffix'
},
works: function(err, c) {
// localhost as domain throws an error, cookie should not be defined
assert.instanceOf(err, Error)
assert.isUndefined(c)
}
}},
{
"setCookie with localhost (GH-215) (null domain)": {
topic: function() {
const cookieJar = new CookieJar();
return cookieJar.setCookieSync("a=b; Domain=", "http://localhost") // when domain set to 'localhost', will throw 'Error: Cookie has domain set to a public suffix'
},
works: function(c) {
assert.instanceOf(c, Cookie)
}
}},
{
"setCookie with localhost (localhost.local domain) (GH-215)": {
topic: function() {
const cookieJar = new CookieJar();
return cookieJar.setCookieSync("a=b; Domain=localhost.local", "http://localhost")
},
works: function(c) {
assert.instanceOf(c, Cookie)
}
}},
{
"setCookie with localhost (.localhost domain), (GH-215)": {
topic: function() {
const cookieJar = new CookieJar();
return cookieJar.setCookieSync("a=b; Domain=.localhost", "http://localhost")
},
works: function(c) {
assert.instanceOf(c, Cookie)
}
}
})
.export(module);