Add Proxy Support for self-hosted runner. (#206)

This commit is contained in:
Tingluo Huang
2019-12-09 15:15:54 -05:00
committed by GitHub
parent 56e18f3606
commit d81a7656a4
24 changed files with 743 additions and 682 deletions

View File

@@ -107,6 +107,35 @@ namespace GitHub.Runner.Common.Tests
}
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void SecretMaskerForProxy()
{
try
{
Environment.SetEnvironmentVariable("http_proxy", "http://user:password123@127.0.0.1:8888");
// Arrange.
Setup();
// Assert.
var logFile = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), $"trace_{nameof(HostContextL0)}_{nameof(SecretMaskerForProxy)}.log");
var tempFile = Path.GetTempFileName();
File.Delete(tempFile);
File.Copy(logFile, tempFile);
var content = File.ReadAllText(tempFile);
Assert.DoesNotContain("password123", content);
Assert.Contains("http://user:***@127.0.0.1:8888", content);
}
finally
{
Environment.SetEnvironmentVariable("http_proxy", null);
// Cleanup.
Teardown();
}
}
private void Setup([CallerMemberName] string testName = "")
{
_tokenSource = new CancellationTokenSource();

View File

@@ -26,8 +26,6 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
private Mock<IPromptManager> _promptManager;
private Mock<IConfigurationStore> _store;
private Mock<IExtensionManager> _extnMgr;
// private Mock<IDeploymentGroupServer> _machineGroupServer;
private Mock<IRunnerWebProxy> _runnerWebProxy;
private Mock<IRunnerCertificateManager> _cert;
#if OS_WINDOWS
@@ -59,8 +57,6 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
_store = new Mock<IConfigurationStore>();
_extnMgr = new Mock<IExtensionManager>();
_rsaKeyManager = new Mock<IRSAKeyManager>();
// _machineGroupServer = new Mock<IDeploymentGroupServer>();
_runnerWebProxy = new Mock<IRunnerWebProxy>();
_cert = new Mock<IRunnerCertificateManager>();
#if OS_WINDOWS
@@ -134,7 +130,6 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
tc.SetSingleton<IExtensionManager>(_extnMgr.Object);
tc.SetSingleton<IRunnerServer>(_agentServer.Object);
tc.SetSingleton<ILocationServer>(_locationServer.Object);
tc.SetSingleton<IRunnerWebProxy>(_runnerWebProxy.Object);
tc.SetSingleton<IRunnerCertificateManager>(_cert.Object);
#if OS_WINDOWS

View File

@@ -1,116 +0,0 @@
using GitHub.Runner.Common.Util;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Xunit;
using System;
using GitHub.Runner.Sdk;
namespace GitHub.Runner.Common.Tests
{
public sealed class ProxyConfigL0
{
private static readonly Regex NewHttpClientHandlerRegex = new Regex("New\\s+HttpClientHandler\\s*\\(", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex NewHttpClientRegex = new Regex("New\\s+HttpClient\\s*\\(\\s*\\)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly List<string> SkippedFiles = new List<string>()
{
"Runner.Common\\HostContext.cs",
"Runner.Common/HostContext.cs"
};
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void IsNotUseRawHttpClientHandler()
{
List<string> sourceFiles = Directory.GetFiles(
TestUtil.GetProjectPath("Runner.Common"),
"*.cs",
SearchOption.AllDirectories).ToList();
sourceFiles.AddRange(Directory.GetFiles(
TestUtil.GetProjectPath("Runner.Listener"),
"*.cs",
SearchOption.AllDirectories));
sourceFiles.AddRange(Directory.GetFiles(
TestUtil.GetProjectPath("Runner.Worker"),
"*.cs",
SearchOption.AllDirectories));
List<string> badCode = new List<string>();
foreach (string sourceFile in sourceFiles)
{
// Skip skipped files.
if (SkippedFiles.Any(s => sourceFile.Contains(s)))
{
continue;
}
// Skip files in the obj directory.
if (sourceFile.Contains(StringUtil.Format("{0}obj{0}", Path.DirectorySeparatorChar)))
{
continue;
}
int lineCount = 0;
foreach (string line in File.ReadAllLines(sourceFile))
{
lineCount++;
if (NewHttpClientHandlerRegex.IsMatch(line))
{
badCode.Add($"{sourceFile} (line {lineCount})");
}
}
}
Assert.True(badCode.Count == 0, $"The following code is using Raw HttpClientHandler() which will not follow the proxy setting agent have. Please use HostContext.CreateHttpClientHandler() instead.\n {string.Join("\n", badCode)}");
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void IsNotUseRawHttpClient()
{
List<string> sourceFiles = Directory.GetFiles(
TestUtil.GetProjectPath("Runner.Common"),
"*.cs",
SearchOption.AllDirectories).ToList();
sourceFiles.AddRange(Directory.GetFiles(
TestUtil.GetProjectPath("Runner.Listener"),
"*.cs",
SearchOption.AllDirectories));
sourceFiles.AddRange(Directory.GetFiles(
TestUtil.GetProjectPath("Runner.Worker"),
"*.cs",
SearchOption.AllDirectories));
List<string> badCode = new List<string>();
foreach (string sourceFile in sourceFiles)
{
// Skip skipped files.
if (SkippedFiles.Any(s => sourceFile.Contains(s)))
{
continue;
}
// Skip files in the obj directory.
if (sourceFile.Contains(StringUtil.Format("{0}obj{0}", Path.DirectorySeparatorChar)))
{
continue;
}
int lineCount = 0;
foreach (string line in File.ReadAllLines(sourceFile))
{
lineCount++;
if (NewHttpClientRegex.IsMatch(line))
{
badCode.Add($"{sourceFile} (line {lineCount})");
}
}
}
Assert.True(badCode.Count == 0, $"The following code is using Raw HttpClient() which will not follow the proxy setting agent have. Please use New HttpClient(HostContext.CreateHttpClientHandler()) instead.\n {string.Join("\n", badCode)}");
}
}
}

View File

@@ -0,0 +1,416 @@
using GitHub.Runner.Common.Util;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Xunit;
using System;
using GitHub.Runner.Sdk;
namespace GitHub.Runner.Common.Tests
{
public sealed class RunnerWebProxyL0
{
private static readonly Regex NewHttpClientHandlerRegex = new Regex("New\\s+HttpClientHandler\\s*\\(", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex NewHttpClientRegex = new Regex("New\\s+HttpClient\\s*\\(\\s*\\)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly List<string> SkippedFiles = new List<string>()
{
"Runner.Common\\HostContext.cs",
"Runner.Common/HostContext.cs"
};
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void IsNotUseRawHttpClientHandler()
{
List<string> sourceFiles = Directory.GetFiles(
TestUtil.GetProjectPath("Runner.Common"),
"*.cs",
SearchOption.AllDirectories).ToList();
sourceFiles.AddRange(Directory.GetFiles(
TestUtil.GetProjectPath("Runner.Listener"),
"*.cs",
SearchOption.AllDirectories));
sourceFiles.AddRange(Directory.GetFiles(
TestUtil.GetProjectPath("Runner.Worker"),
"*.cs",
SearchOption.AllDirectories));
List<string> badCode = new List<string>();
foreach (string sourceFile in sourceFiles)
{
// Skip skipped files.
if (SkippedFiles.Any(s => sourceFile.Contains(s)))
{
continue;
}
// Skip files in the obj directory.
if (sourceFile.Contains(StringUtil.Format("{0}obj{0}", Path.DirectorySeparatorChar)))
{
continue;
}
int lineCount = 0;
foreach (string line in File.ReadAllLines(sourceFile))
{
lineCount++;
if (NewHttpClientHandlerRegex.IsMatch(line))
{
badCode.Add($"{sourceFile} (line {lineCount})");
}
}
}
Assert.True(badCode.Count == 0, $"The following code is using Raw HttpClientHandler() which will not follow the proxy setting agent have. Please use HostContext.CreateHttpClientHandler() instead.\n {string.Join("\n", badCode)}");
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void IsNotUseRawHttpClient()
{
List<string> sourceFiles = Directory.GetFiles(
TestUtil.GetProjectPath("Runner.Common"),
"*.cs",
SearchOption.AllDirectories).ToList();
sourceFiles.AddRange(Directory.GetFiles(
TestUtil.GetProjectPath("Runner.Listener"),
"*.cs",
SearchOption.AllDirectories));
sourceFiles.AddRange(Directory.GetFiles(
TestUtil.GetProjectPath("Runner.Worker"),
"*.cs",
SearchOption.AllDirectories));
List<string> badCode = new List<string>();
foreach (string sourceFile in sourceFiles)
{
// Skip skipped files.
if (SkippedFiles.Any(s => sourceFile.Contains(s)))
{
continue;
}
// Skip files in the obj directory.
if (sourceFile.Contains(StringUtil.Format("{0}obj{0}", Path.DirectorySeparatorChar)))
{
continue;
}
int lineCount = 0;
foreach (string line in File.ReadAllLines(sourceFile))
{
lineCount++;
if (NewHttpClientRegex.IsMatch(line))
{
badCode.Add($"{sourceFile} (line {lineCount})");
}
}
}
Assert.True(badCode.Count == 0, $"The following code is using Raw HttpClient() which will not follow the proxy setting agent have. Please use New HttpClient(HostContext.CreateHttpClientHandler()) instead.\n {string.Join("\n", badCode)}");
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void WebProxyFromEnvironmentVariables()
{
try
{
Environment.SetEnvironmentVariable("http_proxy", "http://127.0.0.1:8888");
Environment.SetEnvironmentVariable("https_proxy", "http://user:pass@127.0.0.1:9999");
Environment.SetEnvironmentVariable("no_proxy", "github.com, google.com,");
var proxy = new RunnerWebProxy();
Assert.Equal("http://127.0.0.1:8888/", proxy.HttpProxyAddress);
Assert.Null(proxy.HttpProxyUsername);
Assert.Null(proxy.HttpProxyPassword);
Assert.Equal("http://user:pass@127.0.0.1:9999/", proxy.HttpsProxyAddress);
Assert.Equal("user", proxy.HttpsProxyUsername);
Assert.Equal("pass", proxy.HttpsProxyPassword);
Assert.Equal(2, proxy.NoProxyList.Count);
Assert.Equal("github.com", proxy.NoProxyList[0].Host);
Assert.Equal("google.com", proxy.NoProxyList[1].Host);
}
finally
{
CleanProxyEnv();
}
}
#if !OS_WINDOWS
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void WebProxyFromEnvironmentVariablesPreferLowerCase()
{
try
{
Environment.SetEnvironmentVariable("http_proxy", "http://127.0.0.1:7777");
Environment.SetEnvironmentVariable("HTTP_PROXY", "http://127.0.0.1:8888");
Environment.SetEnvironmentVariable("https_proxy", "http://user:pass@127.0.0.1:8888");
Environment.SetEnvironmentVariable("HTTPS_PROXY", "http://user:pass@127.0.0.1:9999");
Environment.SetEnvironmentVariable("no_proxy", "github.com, github.com ");
Environment.SetEnvironmentVariable("NO_PROXY", "github.com, google.com,");
var proxy = new RunnerWebProxy();
Assert.Equal("http://127.0.0.1:7777/", proxy.HttpProxyAddress);
Assert.Null(proxy.HttpProxyUsername);
Assert.Null(proxy.HttpProxyPassword);
Assert.Equal("http://user:pass@127.0.0.1:8888/", proxy.HttpsProxyAddress);
Assert.Equal("user", proxy.HttpsProxyUsername);
Assert.Equal("pass", proxy.HttpsProxyPassword);
Assert.Equal(1, proxy.NoProxyList.Count);
Assert.Equal("github.com", proxy.NoProxyList[0].Host);
}
finally
{
CleanProxyEnv();
}
}
#endif
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void WebProxyFromEnvironmentVariablesInvalidString()
{
try
{
Environment.SetEnvironmentVariable("http_proxy", "127.0.0.1:7777");
Environment.SetEnvironmentVariable("https_proxy", "127.0.0.1");
var proxy = new RunnerWebProxy();
Assert.Null(proxy.HttpProxyAddress);
Assert.Null(proxy.HttpProxyUsername);
Assert.Null(proxy.HttpProxyPassword);
Assert.Null(proxy.HttpsProxyAddress);
Assert.Null(proxy.HttpsProxyUsername);
Assert.Null(proxy.HttpsProxyPassword);
Assert.Equal(0, proxy.NoProxyList.Count);
}
finally
{
CleanProxyEnv();
}
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void WebProxyFromEnvironmentVariablesProxyCredentials()
{
try
{
Environment.SetEnvironmentVariable("http_proxy", "http://user1@127.0.0.1:8888");
Environment.SetEnvironmentVariable("https_proxy", "http://user2:pass@127.0.0.1:9999");
Environment.SetEnvironmentVariable("no_proxy", "github.com, google.com,");
var proxy = new RunnerWebProxy();
Assert.Equal("http://user1@127.0.0.1:8888/", proxy.HttpProxyAddress);
Assert.Equal("user1", proxy.HttpProxyUsername);
Assert.Null(proxy.HttpProxyPassword);
var cred = proxy.Credentials.GetCredential(new Uri("http://user1@127.0.0.1:8888/"), "Basic");
Assert.Equal("user1", cred.UserName);
Assert.Equal(string.Empty, cred.Password);
Assert.Equal("http://user2:pass@127.0.0.1:9999/", proxy.HttpsProxyAddress);
Assert.Equal("user2", proxy.HttpsProxyUsername);
Assert.Equal("pass", proxy.HttpsProxyPassword);
cred = proxy.Credentials.GetCredential(new Uri("http://user2:pass@127.0.0.1:9999/"), "Basic");
Assert.Equal("user2", cred.UserName);
Assert.Equal("pass", cred.Password);
Assert.Equal(2, proxy.NoProxyList.Count);
Assert.Equal("github.com", proxy.NoProxyList[0].Host);
Assert.Equal("google.com", proxy.NoProxyList[1].Host);
}
finally
{
CleanProxyEnv();
}
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void WebProxyFromEnvironmentVariablesProxyCredentialsEncoding()
{
try
{
Environment.SetEnvironmentVariable("http_proxy", "http://user1:pass1%40@127.0.0.1:8888");
Environment.SetEnvironmentVariable("https_proxy", "http://user2:pass2%40@127.0.0.1:9999");
Environment.SetEnvironmentVariable("no_proxy", "github.com, google.com,");
var proxy = new RunnerWebProxy();
Assert.Equal("http://user1:pass1%40@127.0.0.1:8888/", proxy.HttpProxyAddress);
Assert.Equal("user1", proxy.HttpProxyUsername);
Assert.Equal("pass1@", proxy.HttpProxyPassword);
var cred = proxy.Credentials.GetCredential(new Uri("http://user1:pass1%40@127.0.0.1:8888/"), "Basic");
Assert.Equal("user1", cred.UserName);
Assert.Equal("pass1@", cred.Password);
Assert.Equal("http://user2:pass2%40@127.0.0.1:9999/", proxy.HttpsProxyAddress);
Assert.Equal("user2", proxy.HttpsProxyUsername);
Assert.Equal("pass2@", proxy.HttpsProxyPassword);
cred = proxy.Credentials.GetCredential(new Uri("http://user2:pass2%40@127.0.0.1:9999/"), "Basic");
Assert.Equal("user2", cred.UserName);
Assert.Equal("pass2@", cred.Password);
Assert.Equal(2, proxy.NoProxyList.Count);
Assert.Equal("github.com", proxy.NoProxyList[0].Host);
Assert.Equal("google.com", proxy.NoProxyList[1].Host);
}
finally
{
CleanProxyEnv();
}
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void WebProxyFromEnvironmentVariablesByPassEmptyProxy()
{
var proxy = new RunnerWebProxy();
Assert.True(proxy.IsBypassed(new Uri("https://github.com")));
Assert.True(proxy.IsBypassed(new Uri("https://github.com")));
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void WebProxyFromEnvironmentVariablesGetProxyEmptyHttpProxy()
{
try
{
Environment.SetEnvironmentVariable("https_proxy", "http://user2:pass2%40@127.0.0.1:9999");
var proxy = new RunnerWebProxy();
Assert.Null(proxy.GetProxy(new Uri("http://github.com")));
Assert.Null(proxy.GetProxy(new Uri("http://example.com:444")));
Assert.Equal("http://user2:pass2%40@127.0.0.1:9999/", proxy.GetProxy(new Uri("https://something.com")).AbsoluteUri);
Assert.Equal("http://user2:pass2%40@127.0.0.1:9999/", proxy.GetProxy(new Uri("https://www.something2.com")).AbsoluteUri);
}
finally
{
CleanProxyEnv();
}
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void WebProxyFromEnvironmentVariablesGetProxyEmptyHttpsProxy()
{
try
{
Environment.SetEnvironmentVariable("http_proxy", "http://user1:pass1%40@127.0.0.1:8888");
var proxy = new RunnerWebProxy();
Assert.Null(proxy.GetProxy(new Uri("https://github.com/owner/repo")));
Assert.Null(proxy.GetProxy(new Uri("https://mails.google.com")));
Assert.Equal("http://user1:pass1%40@127.0.0.1:8888/", proxy.GetProxy(new Uri("http://something.com")).AbsoluteUri);
Assert.Equal("http://user1:pass1%40@127.0.0.1:8888/", proxy.GetProxy(new Uri("http://www.something2.com")).AbsoluteUri);
}
finally
{
CleanProxyEnv();
}
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void WebProxyFromEnvironmentVariablesNoProxy()
{
try
{
Environment.SetEnvironmentVariable("http_proxy", "http://user1:pass1%40@127.0.0.1:8888");
Environment.SetEnvironmentVariable("https_proxy", "http://user2:pass2%40@127.0.0.1:9999");
Environment.SetEnvironmentVariable("no_proxy", "github.com, .google.com, example.com:444, 192.168.0.123:123, 192.168.1.123");
var proxy = new RunnerWebProxy();
Assert.False(proxy.IsBypassed(new Uri("https://actions.com")));
Assert.False(proxy.IsBypassed(new Uri("https://ggithub.com")));
Assert.False(proxy.IsBypassed(new Uri("https://github.comm")));
Assert.False(proxy.IsBypassed(new Uri("https://google.com")));
Assert.False(proxy.IsBypassed(new Uri("https://example.com")));
Assert.False(proxy.IsBypassed(new Uri("http://example.com:333")));
Assert.False(proxy.IsBypassed(new Uri("http://192.168.0.123:123")));
Assert.False(proxy.IsBypassed(new Uri("http://192.168.1.123/home")));
Assert.True(proxy.IsBypassed(new Uri("https://github.com")));
Assert.True(proxy.IsBypassed(new Uri("https://GITHUB.COM")));
Assert.True(proxy.IsBypassed(new Uri("https://github.com/owner/repo")));
Assert.True(proxy.IsBypassed(new Uri("https://actions.github.com")));
Assert.True(proxy.IsBypassed(new Uri("https://mails.google.com")));
Assert.True(proxy.IsBypassed(new Uri("https://MAILS.GOOGLE.com")));
Assert.True(proxy.IsBypassed(new Uri("https://mails.v2.google.com")));
Assert.True(proxy.IsBypassed(new Uri("http://mails.v2.v3.google.com/inbox")));
Assert.True(proxy.IsBypassed(new Uri("https://example.com:444")));
Assert.True(proxy.IsBypassed(new Uri("http://example.com:444")));
Assert.True(proxy.IsBypassed(new Uri("http://example.COM:444")));
}
finally
{
CleanProxyEnv();
}
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void WebProxyFromEnvironmentVariablesGetProxy()
{
try
{
Environment.SetEnvironmentVariable("http_proxy", "http://user1:pass1%40@127.0.0.1:8888");
Environment.SetEnvironmentVariable("https_proxy", "http://user2:pass2%40@127.0.0.1:9999");
Environment.SetEnvironmentVariable("no_proxy", "github.com, .google.com, example.com:444");
var proxy = new RunnerWebProxy();
Assert.Null(proxy.GetProxy(new Uri("http://github.com")));
Assert.Null(proxy.GetProxy(new Uri("https://github.com/owner/repo")));
Assert.Null(proxy.GetProxy(new Uri("https://mails.google.com")));
Assert.Null(proxy.GetProxy(new Uri("http://example.com:444")));
Assert.Equal("http://user1:pass1%40@127.0.0.1:8888/", proxy.GetProxy(new Uri("http://something.com")).AbsoluteUri);
Assert.Equal("http://user1:pass1%40@127.0.0.1:8888/", proxy.GetProxy(new Uri("http://www.something2.com")).AbsoluteUri);
Assert.Equal("http://user2:pass2%40@127.0.0.1:9999/", proxy.GetProxy(new Uri("https://something.com")).AbsoluteUri);
Assert.Equal("http://user2:pass2%40@127.0.0.1:9999/", proxy.GetProxy(new Uri("https://www.something2.com")).AbsoluteUri);
}
finally
{
CleanProxyEnv();
}
}
private void CleanProxyEnv()
{
Environment.SetEnvironmentVariable("http_proxy", null);
Environment.SetEnvironmentVariable("https_proxy", null);
Environment.SetEnvironmentVariable("HTTP_PROXY", null);
Environment.SetEnvironmentVariable("HTTPS_PROXY", null);
Environment.SetEnvironmentVariable("no_proxy", null);
Environment.SetEnvironmentVariable("NO_PROXY", null);
}
}
}

View File

@@ -90,6 +90,8 @@ namespace GitHub.Runner.Common.Tests
public ProductInfoHeaderValue UserAgent => new ProductInfoHeaderValue("L0Test", "0.0");
public RunnerWebProxy WebProxy => new RunnerWebProxy();
public async Task Delay(TimeSpan delay, CancellationToken token)
{
await Task.Delay(TimeSpan.Zero);
@@ -274,24 +276,6 @@ namespace GitHub.Runner.Common.Tests
".certificates");
break;
case WellKnownConfigFile.Proxy:
path = Path.Combine(
GetDirectory(WellKnownDirectory.Root),
".proxy");
break;
case WellKnownConfigFile.ProxyCredentials:
path = Path.Combine(
GetDirectory(WellKnownDirectory.Root),
".proxycredentials");
break;
case WellKnownConfigFile.ProxyBypass:
path = Path.Combine(
GetDirectory(WellKnownDirectory.Root),
".proxybypass");
break;
case WellKnownConfigFile.Options:
path = Path.Combine(
GetDirectory(WellKnownDirectory.Root),

View File

@@ -1688,10 +1688,6 @@ runs:
_hc.SetSingleton<IRunnerPluginManager>(_pluginManager.Object);
_hc.SetSingleton<IActionManifestManager>(actionManifest);
var proxy = new RunnerWebProxy();
proxy.Initialize(_hc);
_hc.SetSingleton<IRunnerWebProxy>(proxy);
_configurationStore = new Mock<IConfigurationStore>();
_configurationStore
.Setup(x => x.GetSettings())

View File

@@ -256,10 +256,6 @@ namespace GitHub.Runner.Common.Tests.Worker
configurationStore.Setup(x => x.GetSettings()).Returns(new RunnerSettings());
hc.SetSingleton(configurationStore.Object);
// Arrange: Setup the proxy configation.
var proxy = new Mock<IRunnerWebProxy>();
hc.SetSingleton(proxy.Object);
// Arrange: Setup the cert configation.
var cert = new Mock<IRunnerCertificateManager>();
hc.SetSingleton(cert.Object);

View File

@@ -22,7 +22,6 @@ namespace GitHub.Runner.Common.Tests.Worker
private CancellationTokenSource _tokenSource;
private Mock<IJobServer> _jobServer;
private Mock<IJobServerQueue> _jobServerQueue;
private Mock<IRunnerWebProxy> _proxyConfig;
private Mock<IRunnerCertificateManager> _cert;
private Mock<IConfigurationStore> _config;
private Mock<IExtensionManager> _extensions;
@@ -43,7 +42,6 @@ namespace GitHub.Runner.Common.Tests.Worker
_jobExtension = new Mock<IJobExtension>();
_jobServer = new Mock<IJobServer>();
_jobServerQueue = new Mock<IJobServerQueue>();
_proxyConfig = new Mock<IRunnerWebProxy>();
_cert = new Mock<IRunnerCertificateManager>();
_stepRunner = new Mock<IStepsRunner>();
_logger = new Mock<IPagingLogger>();
@@ -95,9 +93,6 @@ namespace GitHub.Runner.Common.Tests.Worker
_jobExtension.Setup(x => x.InitializeJob(It.IsAny<IExecutionContext>(), It.IsAny<Pipelines.AgentJobRequestMessage>())).
Returns(Task.FromResult(_initResult));
_proxyConfig.Setup(x => x.ProxyAddress)
.Returns(string.Empty);
var settings = new RunnerSettings
{
AgentId = 1,
@@ -114,7 +109,6 @@ namespace GitHub.Runner.Common.Tests.Worker
hc.SetSingleton(_config.Object);
hc.SetSingleton(_jobServer.Object);
hc.SetSingleton(_jobServerQueue.Object);
hc.SetSingleton(_proxyConfig.Object);
hc.SetSingleton(_cert.Object);
hc.SetSingleton(_stepRunner.Object);
hc.SetSingleton(_extensions.Object);

View File

@@ -16,14 +16,12 @@ namespace GitHub.Runner.Common.Tests.Worker
{
private Mock<IProcessChannel> _processChannel;
private Mock<IJobRunner> _jobRunner;
private Mock<IRunnerWebProxy> _proxy;
private Mock<IRunnerCertificateManager> _cert;
public WorkerL0()
{
_processChannel = new Mock<IProcessChannel>();
_jobRunner = new Mock<IJobRunner>();
_proxy = new Mock<IRunnerWebProxy>();
_cert = new Mock<IRunnerCertificateManager>();
}
@@ -92,7 +90,6 @@ namespace GitHub.Runner.Common.Tests.Worker
var worker = new GitHub.Runner.Worker.Worker();
hc.EnqueueInstance<IProcessChannel>(_processChannel.Object);
hc.EnqueueInstance<IJobRunner>(_jobRunner.Object);
hc.SetSingleton<IRunnerWebProxy>(_proxy.Object);
hc.SetSingleton<IRunnerCertificateManager>(_cert.Object);
worker.Initialize(hc);
var jobMessage = CreateJobRequestMessage("job1");
@@ -145,7 +142,6 @@ namespace GitHub.Runner.Common.Tests.Worker
var worker = new GitHub.Runner.Worker.Worker();
hc.EnqueueInstance<IProcessChannel>(_processChannel.Object);
hc.EnqueueInstance<IJobRunner>(_jobRunner.Object);
hc.SetSingleton<IRunnerWebProxy>(_proxy.Object);
hc.SetSingleton<IRunnerCertificateManager>(_cert.Object);
worker.Initialize(hc);
var jobMessage = CreateJobRequestMessage("job1");