Skip to content

Commit

Permalink
add failing test for #40
Browse files Browse the repository at this point in the history
  • Loading branch information
natevw committed Feb 17, 2022
1 parent 6a9a1a0 commit 2e896ce
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ describe('.unsign(val, secret)', function(){
cookie.unsign(val, 'tobiiscool').should.equal('hello');
cookie.unsign(val, 'luna').should.be.false();
})
it('should reject malformed cookies', function(){
var pwd = 'actual sekrit password';
cookie.unsign('fake unsigned data', pwd).should.be.false();

var val = cookie.sign('real data', pwd);
cookie.unsign('garbage'+val, pwd).should.be.false();
cookie.unsign('garbage.'+val, pwd).should.be.false();
cookie.unsign(val+'.garbage', pwd).should.be.false();
cookie.unsign(val+'garbage', pwd).should.be.false();
})
})

0 comments on commit 2e896ce

Please sign in to comment.