Skip to content

Commit

Permalink
auth tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kacper-RF committed Oct 11, 2023
1 parent 6ade751 commit 8276fef
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/common/src/auth.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { encodeSecret, generateSecret, verifyToken } from './auth'

describe('Auth', () => {
it('correctly create secret, encode and decode', () => {
const secret = generateSecret()
const token = encodeSecret(secret)
const decodedSecret = verifyToken(secret, token)

expect(decodedSecret).toBeTruthy()
})

it('create token with wrong secret', () => {
const secret = generateSecret()
const token = encodeSecret('test')
const decodedSecret = verifyToken(secret, token)

expect(decodedSecret).toBeFalsy()
})
})

0 comments on commit 8276fef

Please sign in to comment.