Skip to content

Commit

Permalink
added new test for expired token
Browse files Browse the repository at this point in the history
  • Loading branch information
davidep87 committed Aug 16, 2017
1 parent f661a3c commit 9b4670b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "secure-jws-session",
"version": "0.1.6",
"version": "0.1.7",
"description": "Secure json web signature sessions with Redis",
"main": "index.js",
"scripts": {
Expand Down
16 changes: 16 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const auth = new Session({
})

let token = ''
const expiredToken = 'eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cubWRzbGFiLm9yZyIsImV4cCI6IjIwMTctMDgtMTZUMDc6MjY6MTEuMzgyWiIsImlkIjoxLCJ0eXBlIjoidXNlciJ9.dVtZJYpPYuzdusGyI_-EwF1zpnSiJyFI7bbmOcJZLgA'

describe('createToken', function() {
it('should return new token', async () => {
Expand Down Expand Up @@ -56,6 +57,21 @@ describe('check', function() {
});
});

describe('check', function() {
it('should return object with not valid token message', async () => {
const session = {
user: 1,
token: expiredToken,
exp: new Date().getTime() + 1,
type: 'user'
}
await auth.insert(session)
let result = await auth.check(expiredToken)
console.log(result)
assert.equal(result.isLogged, false)
});
});

describe('deleteToken', function() {
it('should remove a token', async () => {
await auth.deleteToken(token)
Expand Down

0 comments on commit 9b4670b

Please sign in to comment.