Skip to content
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.

Commit

Permalink
tests: add test for set-cookie header append logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Mar 24, 2019
1 parent 09baec8 commit 94f637e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/test.js
Expand Up @@ -202,6 +202,36 @@ describe('csurf', function () {
.expect(200, done)
})
})

it('should append cookie to existing Set-Cookie header', function (done) {
var app = connect()

app.use(cookieParser('keyboard cat'))
app.use(function (req, res, next) {
res.setHeader('Set-Cookie', 'foo=bar')
next()
})
app.use(csurf({ cookie: true }))
app.use(function (req, res) {
res.end(req.csrfToken() || 'none')
})

request(app)
.get('/')
.expect(200, function (err, res) {
if (err) return done(err)
var token = res.text

assert.ok(Boolean(cookie(res, '_csrf')))
assert.ok(Boolean(cookie(res, 'foo')))

request(app)
.post('/')
.set('Cookie', cookies(res))
.set('X-CSRF-Token', token)
.expect(200, done)
})
})
})

describe('when an object', function () {
Expand Down

0 comments on commit 94f637e

Please sign in to comment.