iam trying to get response from REST api behind proxy.
When testing manually with browser (chrome, IE), i can get the results from GET request when proxy is configured in the browser.
But when iam tryin to do the same in nodejs with npm package request-promise (inside protractor + jasmine test) iam getting error: Error: tunneling socket could not be established: statusCode407
here is my code for the test (tried two approaches):
'use strict';
describe('test suite', function() {
it('REST test 1', function(){
var request = require('request-promise');
var url = 'https://environment/getId';
var fullProxy = 'http://myProxy:8080';
var proxiedRequest = request.defaults({'proxy': fullProxy});
proxiedRequest.get(url).then(function(response){
console.log('Response: ' + response);
}).catch(function(error){
throw new Error(error);
});
});
it('REST test 2', function(){
var request = require('request-promise');
var url = 'https://environment/getId';
var fullProxy = 'http://myProxy:8080';
var options = {
uri: url,
proxy: fullProxy
};
request(options)
.then(function(response){
console.log('Response: ' + response);
})
.catch(function(err){
throw new Error(err);
});
});
});
Thank you for your time and effort!
import rp from 'request-promise';
const url = `https://environment/getId`;
const proxiedRequest = rp.defaults({ proxy: 'http://USER:PASSWORD@myProxy:8080' });
this.response = await proxiedRequest.get(url);