Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix tests: unsigned cookie was actually getting signed

  • Loading branch information...
commit 73aa92d98888351b02c009e93a69bbaa2ed640cb 1 parent c328df4
@mtkopone mtkopone authored
Showing with 6 additions and 4 deletions.
  1. +3 −2 test/express.js
  2. +3 −2 test/http.js
View
5 test/express.js
@@ -13,7 +13,7 @@ app.use( cookies( keys ) )
app.get( "/set", function(req, res) {
res.cookies
// set a regular cookie
- .set( "unsigned", "foo", { httpOnly: false } )
+ .set( "unsigned", "foo", { signed:false, httpOnly: false } )
// set a signed cookie
.set( "signed", "bar", { signed: true } )
@@ -32,6 +32,7 @@ app.get("/", function(req, res) {
, tampered = req.cookies.get( "tampered", { signed: true } )
assert.equal( unsigned, "foo" )
+ assert.equal( req.cookies.get( "unsigned.sig", { signed:false } ), undefined)
assert.equal( signed, "bar" )
assert.notEqual( tampered, "baz" )
assert.equal( tampered, undefined )
@@ -57,7 +58,7 @@ http.get( options, function( res ) {
console.log( "\ncookies set:", header )
console.log( "\n============\n" )
- assert.equal(header.length, 6)
+ assert.equal(header.length, 5)
options.path = res.headers[ "Location" ]
options.headers = { "Cookie": header.join(";") }
View
5 test/http.js
@@ -14,7 +14,7 @@ server = http.createServer( function( req, res ) {
if ( req.url == "/set" ) {
cookies
// set a regular cookie
- .set( "unsigned", "foo", { httpOnly: false } )
+ .set( "unsigned", "foo", { signed:false, httpOnly: false } )
// set a signed cookie
.set( "signed", "bar", { signed: true } )
@@ -32,6 +32,7 @@ server = http.createServer( function( req, res ) {
tampered = cookies.get( "tampered", { signed: true } )
assert.equal( unsigned, "foo" )
+ assert.equal( cookies.get( "unsigned.sig", { signed:false } ), undefined)
assert.equal( signed, "bar" )
assert.notEqual( tampered, "baz" )
assert.equal( tampered, undefined )
@@ -56,7 +57,7 @@ http.get( options, function( res ) {
console.log( "\ncookies set:", cookies )
console.log( "\n============\n" )
- assert.equal(cookies.length, 6)
+ assert.equal(cookies.length, 5)
options.path = res.headers[ "location" ]
options.headers = { "Cookie": cookies.join(";") }
Please sign in to comment.
Something went wrong with that request. Please try again.