зеркало из https://github.com/Azure/ms-rest-js.git
Allow password-less proxySettings
It turns out that in some enterprise customer the proxy auth settings include a username, but not a password: microsoft/AzureStorageExplorer#4430 This change allows password-less auth settings to be passed to the underlying agent. It's unclear whether it's a real scenario when a proxy auth has a password, but not username so this PR doesn't consider this scenario.
This commit is contained in:
Родитель
062829a397
Коммит
ce25202b91
|
@ -1,4 +1,8 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2.5.2 - (2021-06-15)
|
||||||
|
- Fixed an issue where `proxySettings` does not work when there is username but no password (PR [453](https://github.com/Azure/ms-rest-js/pull/453))
|
||||||
|
|
||||||
## 2.5.1 - (2021-06-07)
|
## 2.5.1 - (2021-06-07)
|
||||||
- [BugFix] Array flattening in deserializer loses previously de-serialized attributes (PR [#451](https://github.com/Azure/ms-rest-js/pull/451))
|
- [BugFix] Array flattening in deserializer loses previously de-serialized attributes (PR [#451](https://github.com/Azure/ms-rest-js/pull/451))
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ export function createProxyAgent(
|
||||||
|
|
||||||
if (proxySettings.username && proxySettings.password) {
|
if (proxySettings.username && proxySettings.password) {
|
||||||
tunnelOptions.proxy!.proxyAuth = `${proxySettings.username}:${proxySettings.password}`;
|
tunnelOptions.proxy!.proxyAuth = `${proxySettings.username}:${proxySettings.password}`;
|
||||||
|
} else if (proxySettings.username) {
|
||||||
|
tunnelOptions.proxy!.proxyAuth = `${proxySettings.username}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const requestScheme = URLBuilder.parse(requestUrl).getScheme() || "";
|
const requestScheme = URLBuilder.parse(requestUrl).getScheme() || "";
|
||||||
|
|
|
@ -8,6 +8,7 @@ import https from "https";
|
||||||
|
|
||||||
import { HttpHeaders } from "../lib/msRest";
|
import { HttpHeaders } from "../lib/msRest";
|
||||||
import { createProxyAgent, createTunnel } from "../lib/proxyAgent";
|
import { createProxyAgent, createTunnel } from "../lib/proxyAgent";
|
||||||
|
import { ProxySettings } from "../lib/serviceClient";
|
||||||
|
|
||||||
describe("proxyAgent", () => {
|
describe("proxyAgent", () => {
|
||||||
describe("createProxyAgent", () => {
|
describe("createProxyAgent", () => {
|
||||||
|
@ -62,6 +63,37 @@ describe("proxyAgent", () => {
|
||||||
agent.proxyOptions.headers!.should.contain({ "user-agent": "Node.js" });
|
agent.proxyOptions.headers!.should.contain({ "user-agent": "Node.js" });
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should set agent proxyAuth correctly", function (done) {
|
||||||
|
const proxySettings: ProxySettings = {
|
||||||
|
host: "http://proxy.microsoft.com",
|
||||||
|
port: 8080,
|
||||||
|
username: "username",
|
||||||
|
password: "pass123",
|
||||||
|
};
|
||||||
|
|
||||||
|
const proxyAgent = createProxyAgent("http://example.com", proxySettings);
|
||||||
|
|
||||||
|
const agent = proxyAgent.agent as HttpsAgent;
|
||||||
|
should().exist(agent.options.proxy.proxyAuth);
|
||||||
|
agent.options.proxy.proxyAuth!.should.equal("username:pass123");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should set agent proxyAuth correctly when password is not specified", function (done) {
|
||||||
|
const proxySettings: ProxySettings = {
|
||||||
|
host: "http://proxy.microsoft.com",
|
||||||
|
port: 8080,
|
||||||
|
username: "username",
|
||||||
|
};
|
||||||
|
|
||||||
|
const proxyAgent = createProxyAgent("http://example.com", proxySettings);
|
||||||
|
|
||||||
|
const agent = proxyAgent.agent as HttpsAgent;
|
||||||
|
should().exist(agent.options.proxy.proxyAuth);
|
||||||
|
agent.options.proxy.proxyAuth!.should.equal("username");
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("createTunnel", () => {
|
describe("createTunnel", () => {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче