Skip to content

Commit 4f25a94

Browse files
tests with credentials in url
1 parent 95f96f2 commit 4f25a94

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

test/proxy.test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,35 @@ describe('RdHandler', function () {
177177
});
178178

179179
it('Requests on behalf of the client via external proxy and returns the response', function (done) {
180+
this.timeout = 5000;
181+
testHelper.nockGetRequest(constants.HUB_STATUS_URL, 'https', null, 200);
182+
testHelper.initializeDummyProxy();
183+
testHelper.nockProxyUrl(RdGlobalConfig.proxy, 'https', 'hub', null, 200);
184+
var reqOptions = {
185+
method: 'GET',
186+
host: 'localhost',
187+
port: RdGlobalConfig.RD_HANDLER_PROXY_PORT,
188+
headers: {},
189+
path: constants.HUB_STATUS_URL
190+
};
191+
192+
var responseData = [];
193+
var request = http.request(reqOptions, function (response) {
194+
195+
response.on('data', function (chunk) {
196+
responseData.push(chunk);
197+
});
198+
199+
response.on('end', function () {
200+
assert(Buffer.concat(responseData).toString() === '{"data":"value"}');
201+
done();
202+
testHelper.deleteProxy();
203+
});
204+
});
205+
request.end();
206+
});
207+
208+
it('Requests on behalf of the client with username and password in url via external proxy and returns the response', function (done) {
180209
this.timeout = 5000;
181210
testHelper.nockGetRequest(constants.HUB_STATUS_URL, 'https', null, 200);
182211
testHelper.initializeDummyProxy();

test/reverseProxy.test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,35 @@ describe('RdHandler', function () {
175175
});
176176

177177
it('Requests on behalf of the client via external proxy and returns the response', function (done) {
178+
this.timeout = 5000;
179+
testHelper.nockGetRequest(constants.HUB_STATUS_URL, 'https', null, 200);
180+
testHelper.initializeDummyProxy();
181+
testHelper.nockProxyUrl(RdGlobalConfig.proxy, 'https', 'hub', null, 200);
182+
var reqOptions = {
183+
method: 'GET',
184+
host: 'localhost',
185+
port: RdGlobalConfig.RD_HANDLER_REVERSE_PROXY_PORT,
186+
headers: {},
187+
path: constants.HUB_STATUS_PATH
188+
};
189+
190+
var responseData = [];
191+
var request = http.request(reqOptions, function (response) {
192+
193+
response.on('data', function (chunk) {
194+
responseData.push(chunk);
195+
});
196+
197+
response.on('end', function () {
198+
assert(Buffer.concat(responseData).toString() === '{"data":"value"}');
199+
done();
200+
testHelper.deleteProxy();
201+
});
202+
});
203+
request.end();
204+
});
205+
206+
it('Requests on behalf of the client with username and password in url via external proxy and returns the response', function (done) {
178207
this.timeout = 5000;
179208
testHelper.nockGetRequest(constants.HUB_STATUS_URL, 'https', null, 200);
180209
testHelper.initializeDummyProxy();

0 commit comments

Comments
 (0)