Skip to content
This repository was archived by the owner on Oct 21, 2020. It is now read-only.

Commit f5b85af

Browse files
ojongeriusBouncey
authored andcommitted
feat: add script to generate test tokens, update README (#87)
1 parent 4d25b9a commit f5b85af

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,26 @@ Serverless: GET /api
7676
Serverless: Offline listening on http://localhost:4000
7777
```
7878

79+
### Testing
80+
81+
### Integration tests
82+
83+
Integration tests live in test. We just Jest for integration tests.
84+
85+
#### Unit tests
86+
87+
Unit tests live close to the code they tests, in the same directory and file name, ie: `foo.test.js` tests `foo.js`.
88+
89+
#### Test tokens
90+
You will have to set authentication headers for particular queries. Generate valid headers, by running `node scripts/generateHeaders.js`. You can use the output in scripts or the graphQL IDE (typically at <http://localhost:4000/api>). This scripts expects the environment variable `JWT_CERT` to be set, which will be used by the server to validate tokens.
91+
92+
```sh
93+
▶ node scripts/generateHeader.js
94+
{"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTIzLCJuYW1lIjoiQ2hhcmxpZSIsImlhdCI6MTUyNTA0NzkxM30.F-Rqh1Bk6sFBZwAz4cfPyCZrnkl_VJq0jLi_WRcKbMg"}
95+
```
96+
7997
### Deployment
98+
8099
Deployment is normally done by CI.
81100

82101
### Manual Deployment

scripts/generateHeader.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const jwt = require('jsonwebtoken');
2+
const { JWT_CERT } = process.env;
3+
4+
const token = jwt.sign({ id: 123, name: 'Charlie' }, JWT_CERT);
5+
const headers = '{"Authorization": "Bearer ' + token + '"}';
6+
7+
console.log(headers);

0 commit comments

Comments
 (0)