Skip to content

Commit fcd4d76

Browse files
committed
tests: cover signed cookie without secret
1 parent f3d99a4 commit fcd4d76

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/res.cookie.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,28 @@ describe('res', function(){
150150
})
151151
})
152152

153+
describe('signed without secret', function(){
154+
it('should throw an error', function(done){
155+
var app = express();
156+
157+
app.use(cookieParser());
158+
159+
app.use(function(req, res){
160+
try {
161+
res.cookie('name', 'tobi', { signed: true });
162+
} catch (err) {
163+
return res.json({ status: 'OK' });
164+
}
165+
166+
res.json({ status: 'FAIL' });
167+
});
168+
169+
request(app)
170+
.get('/')
171+
.expect({ status: 'OK' }, done);
172+
})
173+
})
174+
153175
describe('.signedCookie(name, string)', function(){
154176
it('should set a signed cookie', function(done){
155177
var app = express();

0 commit comments

Comments
 (0)