forked from ManuelaIacobovici/acebook-mern-water-team
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SLUG] Transferring changes from Slug as of 2023-01-18 10:03:48 +0000.
- Loading branch information
Showing
11 changed files
with
39 additions
and
123 deletions.
There are no files selected for viewing
Binary file not shown.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Binary file not shown.
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 |
---|---|---|
|
@@ -3,15 +3,23 @@ const request = require("supertest"); | |
require("../mongodb_helper"); | ||
const Post = require('../../models/post'); | ||
const User = require('../../models/user'); | ||
const TokenGenerator = require('../../models/token_generator'); | ||
const JWT = require("jsonwebtoken"); | ||
const secret = process.env.JWT_SECRET; | ||
|
||
let token; | ||
|
||
describe("/posts", () => { | ||
beforeAll( async () => { | ||
const user = new User({email: "[email protected]", password: "12345678"}); | ||
await user.save(); | ||
token = TokenGenerator.jsonwebtoken(user.id); | ||
|
||
token = JWT.sign({ | ||
user_id: user.id, | ||
// Backdate this token of 5 minutes | ||
iat: Math.floor(Date.now() / 1000) - (5 * 60), | ||
// Set the JWT token to expire in 10 minutes | ||
exp: Math.floor(Date.now() / 1000) + (10 * 60) | ||
}, secret); | ||
}); | ||
|
||
beforeEach( async () => { | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.