-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding initial email verification test
- Loading branch information
Ian Walter
committed
Jan 14, 2020
1 parent
ff58008
commit 0d9ee4c
Showing
9 changed files
with
121 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const bcrypt = require('bcrypt') | ||
const addDays = require('date-fns/addDays') | ||
const { accounts } = require('./01_accounts') | ||
|
||
const token = 'iJustC4n7!gnore' | ||
const salt = bcrypt.genSaltSync(12) | ||
const encryptedToken = bcrypt.hashSync(token, salt) | ||
const unverifiedUser = accounts.find(a => a.firstName === 'Unverified User') | ||
const tokens = [ | ||
{ | ||
value: encryptedToken, | ||
type: 'email', | ||
accountId: 4, | ||
email: unverifiedUser.email, | ||
expiresAt: addDays(new Date(), 1).toISOString() | ||
} | ||
] | ||
|
||
module.exports = { | ||
token, | ||
tokens, | ||
seed: async knex => { | ||
await knex.raw('TRUNCATE TABLE tokens RESTART IDENTITY CASCADE') | ||
return knex('tokens').insert(tokens) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const { test } = require('@ianwalter/bff') | ||
const app = require('../examples/accounts') | ||
const { accounts } = require('../examples/accounts/seeds/01_accounts') | ||
const { token } = require('../examples/accounts/seeds/02_tokens') | ||
|
||
const unverifiedUser = accounts.find(a => a.firstName === 'Unverified User') | ||
|
||
test('Email Verification success', async ({ expect }) => { | ||
const payload = { email: unverifiedUser.email, token } | ||
const response = await app.test('/verify-email').post(payload) | ||
expect(response.status).toBe(201) | ||
expect(response.body).toMatchSnapshot() | ||
}) | ||
|
||
test.skip('Email Verification from email', async ({ expect }) => { | ||
}) | ||
|
||
test.skip('Email Verification from resent email', async ({ expect }) => { | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Email Verification success 1`] = ` | ||
Object { | ||
"email": "unverified_user_test@example.com", | ||
"emailVerified": true, | ||
"firstName": "Unverified User", | ||
"id": 4, | ||
"lastName": "Test", | ||
} | ||
`; |