mirror of
https://github.com/actions/runner.git
synced 2026-01-01 23:23:58 +08:00
Add 'http://' to http(s)_proxy if there is no protocol (#2663)
* Add 'http://' to http(s)_proxy if there is no protocol Before this commit, these URIs used to be ignored (nullproxy). The new behaviour aligns with go style http(s)_proxy * Update src/Runner.Sdk/RunnerWebProxy.cs Co-authored-by: Nikola Jokic <jokicnikola07@gmail.com> * Assert that original protocol is preserved * Use startsWith for testing protocol * Only modify proxy if useful --------- Co-authored-by: Nikola Jokic <jokicnikola07@gmail.com>
This commit is contained in:
@@ -186,8 +186,8 @@ namespace GitHub.Runner.Common.Tests
|
||||
{
|
||||
try
|
||||
{
|
||||
Environment.SetEnvironmentVariable("http_proxy", "127.0.0.1:7777");
|
||||
Environment.SetEnvironmentVariable("https_proxy", "127.0.0.1");
|
||||
Environment.SetEnvironmentVariable("http_proxy", "#fragment");
|
||||
Environment.SetEnvironmentVariable("https_proxy", "#fragment");
|
||||
var proxy = new RunnerWebProxy();
|
||||
|
||||
Assert.Null(proxy.HttpProxyAddress);
|
||||
@@ -206,6 +206,68 @@ namespace GitHub.Runner.Common.Tests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Level", "L0")]
|
||||
[Trait("Category", "Common")]
|
||||
public void WebProxyPrependsHTTPforHTTP_PROXY_IfNoProtocol()
|
||||
{
|
||||
try
|
||||
{
|
||||
Environment.SetEnvironmentVariable("http_proxy", "127.0.0.1:7777");
|
||||
var proxy = new RunnerWebProxy();
|
||||
|
||||
Assert.Equal("http://127.0.0.1:7777", proxy.HttpProxyAddress);
|
||||
Assert.Null(proxy.HttpProxyUsername);
|
||||
Assert.Null(proxy.HttpProxyPassword);
|
||||
|
||||
Assert.Equal(0, proxy.NoProxyList.Count);
|
||||
|
||||
Environment.SetEnvironmentVariable("http_proxy", "http://127.0.0.1:7777");
|
||||
proxy = new RunnerWebProxy();
|
||||
|
||||
Assert.Equal("http://127.0.0.1:7777", proxy.HttpProxyAddress);
|
||||
Assert.Null(proxy.HttpProxyUsername);
|
||||
Assert.Null(proxy.HttpProxyPassword);
|
||||
|
||||
Assert.Equal(0, proxy.NoProxyList.Count);
|
||||
}
|
||||
finally
|
||||
{
|
||||
CleanProxyEnv();
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Level", "L0")]
|
||||
[Trait("Category", "Common")]
|
||||
public void WebProxyPrependsHTTPforHTTPS_PROXY_IfNoProtocol()
|
||||
{
|
||||
try
|
||||
{
|
||||
Environment.SetEnvironmentVariable("https_proxy", "127.0.0.1:7777");
|
||||
var proxy = new RunnerWebProxy();
|
||||
|
||||
Assert.Equal("http://127.0.0.1:7777", proxy.HttpsProxyAddress);
|
||||
Assert.Null(proxy.HttpProxyUsername);
|
||||
Assert.Null(proxy.HttpProxyPassword);
|
||||
|
||||
Assert.Equal(0, proxy.NoProxyList.Count);
|
||||
|
||||
Environment.SetEnvironmentVariable("https_proxy", "https://127.0.0.1:7777");
|
||||
proxy = new RunnerWebProxy();
|
||||
|
||||
Assert.Equal("https://127.0.0.1:7777", proxy.HttpsProxyAddress); // existing protocol 'https' is not removed
|
||||
Assert.Null(proxy.HttpProxyUsername);
|
||||
Assert.Null(proxy.HttpProxyPassword);
|
||||
|
||||
Assert.Equal(0, proxy.NoProxyList.Count);
|
||||
}
|
||||
finally
|
||||
{
|
||||
CleanProxyEnv();
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Level", "L0")]
|
||||
[Trait("Category", "Common")]
|
||||
|
||||
Reference in New Issue
Block a user