Skip to content

Commit

Permalink
Merge pull request #486 from alphagov/PP-4213-set-proxied-to-http
Browse files Browse the repository at this point in the history
PP-4213: Set proxied protocol to http
  • Loading branch information
oswaldquek authored Sep 28, 2018
2 parents 9e469b7 + 82cb2b2 commit 797145f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pipeline {
}
}
steps {
runCardPaymentsE2E("frontend", null, "PP-4213")
runCardPaymentsE2E("frontend")
}
}
stage('ZAP Tests') {
Expand All @@ -57,7 +57,7 @@ pipeline {
}
}
steps {
runZap("frontend", null, "PP-4213")
runZap("frontend")
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/utils/add_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module.exports.addProxy = function addProxy (url) {

if (FORWARD_PROXY_URL) {
const parsedProxyUrl = urlParse(FORWARD_PROXY_URL)
return _.merge(parsedUrl, _.pick(parsedProxyUrl, ['hostname', 'port']))
parsedUrl.protocol = parsedProxyUrl.protocol
return _.merge(parsedUrl, _.pick(parsedProxyUrl, ['hostname', 'port', 'protocol']))
}
return parsedUrl
}
3 changes: 2 additions & 1 deletion app/utils/base_client2.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ const _request = function request (methodName, url, args, callback, subSegment)
const namespace = getNamespace(clsXrayConfig.nameSpaceName)
const clsSegment = namespace ? namespace.get(clsXrayConfig.segmentKeyName) : null

const proxiedUrl = addProxy(url)
const requestOptions = {
uri: addProxy(url),
uri: proxiedUrl.protocol + '//' + proxiedUrl.hostname + ':' + proxiedUrl.port + proxiedUrl.pathname,
method: methodName,
agent: httpAgent,
headers: getHeaders(args, {clsSegment: clsSegment, subSegment: subSegment}, url)
Expand Down
1 change: 1 addition & 0 deletions test/utils/add_proxy_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('add proxy test', () => {
const proxiedUrl = addProxy.addProxy(urlParse('http://localhost:8080'))
expect(proxiedUrl.hostname).to.equal(forwardProxy.hostname)
expect(proxiedUrl.port).to.equal(forwardProxy.port)
expect(proxiedUrl.protocol).to.equal(forwardProxy.protocol)
})
})

Expand Down

0 comments on commit 797145f

Please sign in to comment.