Permalink
Browse files

fix(server): Update server implementations to be more docker-friendly

  • Loading branch information...
zakhenry committed Aug 1, 2016
1 parent fafc747 commit cae672af0d9331103892d9065b44880eefff5400
@@ -63,7 +63,7 @@ describe('Server', () => {
.toHaveBeenCalledWith(3001);
expect(server.getHost())
.toEqual('http://localhost:3000');
.toEqual('http://(localhost):3000');
}));
@@ -47,9 +47,8 @@ export abstract class Server {
this.logger = loggerBase.source('server');
//@todo pull this config from process.env via .env variables
this.host = 'localhost';
this.port = 3000;
this.host = process.env.APP_HOST || null; //usually should be null to default binding to localhost
this.port = process.env.APP_PORT || 3000;
this.initialize();
@@ -101,7 +100,7 @@ export abstract class Server {
* @returns {string}
*/
public getHost(): string {
return `http://${this.host}:${this.port}`;
return `http://${this.host || '(localhost)'}:${this.port}`;
}
/**
@@ -15,6 +15,8 @@ describe('JWT Authentication Strategy', () => {
};
authService.verify.and.returnValue(Promise.resolve(payload));
process.env.PATH_ROOT = '/tmp'; //tmp for testing
const context: RemoteCliContext = {
logger: loggerMock,
authService: authService,
@@ -49,10 +51,10 @@ describe('JWT Authentication Strategy', () => {
authenticator({client: {jwt, publicKeyPath, columns: 100}}, (message:string, isSuccess:boolean) => {
expect(authService.verify).toHaveBeenCalledWith(jwt, publicKeyPath);
expect(authService.verify).toHaveBeenCalledWith(jwt, '/tmp/path/to/key');
expect(vantageScope.log)
.toHaveBeenCalledWith(chalk.grey(`You were authenticated with a JSON Web token verified against the public key at ${publicKeyPath}`));
.toHaveBeenCalledWith(chalk.grey(`You were authenticated with a JSON Web token verified against the public key at /tmp/path/to/key`));
expect(isSuccess).toBe(true);
expect(message).toBe(null);
@@ -4,6 +4,7 @@
/** End Typedoc Module Declaration */
import { bannerBg } from '../../common/util/banner';
import * as chalk from 'chalk';
import * as path from 'path';
import {
AuthenticationStrategy,
RemoteCliContext,
@@ -19,12 +20,16 @@ export const jwtAuthStrategyFactory:AuthenticationStrategyFactory = (remoteCliCo
remoteCliContext.logger.silly.debug('Passed client arguments: ', args);
const token: string = args.client.jwt;
const keyPath: string = args.client.publicKeyPath;
let keyPath: string = args.client.publicKeyPath;
if (!token) {
return cb("JWT was not passed in connection request", false);
}
if (process.env.PATH_ROOT){
keyPath = path.resolve(process.env.PATH_ROOT, keyPath);
}
remoteCliContext.logger.info(`Authenticating JSON web token against public key [${keyPath}]`);
remoteCliContext.authService.verify(token, keyPath)

0 comments on commit cae672a

Please sign in to comment.