Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config_sample.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"public_port" : 3000,
"private_port" : 3001,
"private_server": "localhost",
"accessToken" : {
"cipherKey" : "unsecureKey1",
"signKey" : "unsecureKey2",
Expand Down
1 change: 1 addition & 0 deletions config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"type": "object",
"properties": {
"public_port": { "type": "integer", "required": true },
"private_host": { "type": "string", "required": true },
"private_port": { "type": "integer", "required": true },
"accessToken": {
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/client_pass_through_pin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var myStepDefinitionsWrapper = function () {
};
options.headers[config.version.header] = "test/1";

nock('http://localhost:' + config.private_port)
nock('http://' + config.private_host + ':' + config.private_port)
.post(config.passThroughEndpoint.path)
.reply(201, {id: "a1b2c3d4e5f6"});

Expand Down
7 changes: 5 additions & 2 deletions src/middlewares/prepareOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ var fs = require('fs');

function prepareOptions (req, res, next){
var options = {
url: 'http://localhost:' + config.private_port + req.url,
url: 'http://'+ config.private_server + ':' + config.private_port + req.url,
headers: {
'Content-Type': req.header('Content-Type'),
'x-user-id': req.tokenInfo.userId
'x-user-id': req.tokenInfo.userId,
'Host': req.headers.host,
'X-Real-IP': req.connection.remoteAddress,
'X-Forwarded-For': req.header('X-Forwarded-For') || req.connection.remoteAddress
},
method: req.method,
followRedirect: false
Expand Down
7 changes: 5 additions & 2 deletions src/routes/userCreation.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ var config = require('../../config.json');

function createUser(req, body, res, next, user) {
var options = {
url: 'http://localhost:' + config.private_port + req.url,
url: 'http://' + config.private_host + ':' + config.private_port + req.url,
headers: {
'Content-Type': 'application/json; charset=utf-8'
'Content-Type': 'application/json; charset=utf-8',
'Host': req.headers.host,
'X-Real-IP': req.connection.remoteAddress,
'X-Forwarded-For': req.header('X-Forwarded-For') || req.connection.remoteAddress
},
method: req.method,
body: JSON.stringify(body)
Expand Down
8 changes: 4 additions & 4 deletions tests/proxy/protectedCallsPassThrough.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
var expectedPrivateResponse = clone(expectedPublicRequest);
delete(expectedPrivateResponse[config.passThroughEndpoint.password]);

nock('http://localhost:' + config.private_port)
nock('http://' + config.private_host + ':' + config.private_port)
.post(config.passThroughEndpoint.path, expectedPrivateResponse)
.reply(201, {id: expectedUserId});

Expand All @@ -39,7 +39,7 @@ module.exports = {
redisMng.insertKeyValue(redisKey + '.attempts', config.userPIN.attempts , config.redisKeys.user_phone_verify.expireInSec, function(err){
assert.equal(err, null);

nock('http://localhost:' + config.private_port)
nock('http://' + config.private_host + ':' + config.private_port)
.post(config.passThroughEndpoint.path, expectedPrivateResponse)
.reply(201, {id: expectedUserId});

Expand Down Expand Up @@ -106,7 +106,7 @@ module.exports = {
var expectedPrivateResponse = clone(expectedPublicRequest);
delete(expectedPrivateResponse[config.passThroughEndpoint.password]);

nock('http://localhost:' + config.private_port)
nock('http://' + config.private_host + ':' + config.private_port)
.post(config.passThroughEndpoint.path, expectedPrivateResponse)
.reply(203, {id: expectedUserId});

Expand Down Expand Up @@ -181,7 +181,7 @@ module.exports = {
var expectedPrivateResponse = clone(expectedPublicRequest);
delete(expectedPrivateResponse[config.passThroughEndpoint.password]);

nock('http://localhost:' + config.private_port)
nock('http://' + config.private_host + ':' + config.private_port)
.post(config.passThroughEndpoint.path, expectedPrivateResponse)
.reply(201, {id: expectedUserId});

Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/protectedCallsStandard-platformSF.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ module.exports = {
};

function nockProtectedStandartCall(id, expectedSfData, expectedBody) {
nock('http://localhost:' + config.private_port, {
nock('http://' + config.private_host + ':' + config.private_port, {
reqheaders: {
'x-user-id': id,
'x-sf-data': JSON.stringify(expectedSfData),
Expand Down
4 changes: 2 additions & 2 deletions tests/proxy/protectedCallsStandard.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = {
ciphertoken.createToken(accessTokenSettings, createdUser._id, null, {}, function (err, loginToken) {
var expectedBody = {field1: 'value1', field2: 'value2'};

nock('http://localhost:' + config.private_port, {
nock('http://' + config.private_host + ':' + config.private_port, {
reqheaders: {
'x-user-id': createdUser._id,
'content-type': 'application/json; charset=utf-8'
Expand Down Expand Up @@ -88,7 +88,7 @@ module.exports = {
ciphertoken.createToken(accessTokenSettings, createdUser._id, null, {}, function (err, loginToken) {
var expectedBody = {field1: 'value1', field2: 'value2'};

nock('http://localhost:' + config.private_port, {
nock('http://' + config.private_host + ':' + config.private_port, {
reqheaders: {
'x-user-id': createdUser._id,
'content-type': 'application/json; charset=utf-8'
Expand Down
2 changes: 1 addition & 1 deletion tests/redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('Redirect', function(){
};
options.headers[config.version.header] = "test/1";

nock('http://localhost:' + config.private_port)
nock('http://' + config.private_host + ':' + config.private_port)
.post('/whatever')
.reply(302, 'Redirecting', {
'Location': redirectURL
Expand Down
6 changes: 3 additions & 3 deletions tests/verify-phone.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ describe('/api/profile (verify phone)', function(){

var expectedUserId = 'a1b2c3d4e5f6';

nock('http://localhost:' + config.private_port)
nock('http://' + config.private_host + ':' + config.private_port)
.post(config.passThroughEndpoint.path)
.reply(201, {id: expectedUserId});

Expand Down Expand Up @@ -289,7 +289,7 @@ describe('/api/profile (verify phone)', function(){

var expectedUserId = 'a1b2c3d4e5f6';

nock('http://localhost:' + config.private_port)
nock('http://' + config.private_host + ':' + config.private_port)
.post(config.passThroughEndpoint.path)
.reply(201, {id: expectedUserId});

Expand Down Expand Up @@ -350,7 +350,7 @@ describe('/api/profile (verify phone)', function(){

var expectedUserId = 'a1b2c3d4e5f6';

nock('http://localhost:' + config.private_port)
nock('http://' + config.private_host + ':' + config.private_port)
.post(config.passThroughEndpoint.path)
.reply(201, {id: expectedUserId});

Expand Down