Skip to content

Commit

Permalink
token env vars update (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeknovy authored Feb 6, 2021
1 parent 28fac1f commit 801299a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
- stage: Contract tests
env:
- ENVIRONMENT=CI
- JWT_TOKEN=123
- JWT_TOKEN_LOGIN=456
before_script:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker-compose --file docker-compose.testing.yaml rm -f
Expand All @@ -22,6 +24,8 @@ jobs:
- stage: Integration tests
env:
- ENVIRONMENT=CI
- JWT_TOKEN=123
- JWT_TOKEN_LOGIN=456
before_script:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker-compose --file docker-compose.testing.yaml rm -f
Expand Down
5 changes: 5 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Router } from './server/router';
import * as swaggerUi from 'swagger-ui-express';
import { MongoUtils } from './db/mongoUtil';
import * as http from 'http';
import { config } from './server/config';
const swaggerDocument = require('../openapi.json');

const PORT = 5000;
Expand Down Expand Up @@ -72,6 +73,10 @@ export class App {
}

public async listen() {
if (!config.jwtToken || !config.jwtTokenLogin) {
logger.error('Please provide JWT_TOKEN and JWT_TOKEN_LOGIN env vars');
process.exit(1);
}
await MongoUtils.connect();
return this.server = this.app.listen(PORT, () => {
logger.info('Express server listening on port ' + PORT);
Expand Down
4 changes: 2 additions & 2 deletions src/server/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const config = {
jwtToken: process.env.JWT_TOKEN || 'A71527A34D15F38E',
jwtTokenLogin: process.env.JWT_TOKEN_LOGIN || '3nHs5Px4pEtmsxPd'
jwtToken: process.env.JWT_TOKEN,
jwtTokenLogin: process.env.JWT_TOKEN_LOGIN
};
6 changes: 6 additions & 0 deletions src/tests/unit/auth-token-generator.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { config } from '../../server/config';
import { generateToken } from '../../server/controllers/auth/helper/token-generator';



describe('token generator', () => {
config.jwtToken = '123';
config.jwtTokenLogin = '456';

it('should return valid token', () => {
const ID = 'test-id';
const token = generateToken(ID);
Expand Down

0 comments on commit 801299a

Please sign in to comment.