diff --git a/BtmsGateway/BtmsGateway.csproj b/BtmsGateway/BtmsGateway.csproj
index 4ca7cb19..09d27c18 100644
--- a/BtmsGateway/BtmsGateway.csproj
+++ b/BtmsGateway/BtmsGateway.csproj
@@ -24,29 +24,29 @@
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
diff --git a/BtmsGateway/Utils/Http/Proxy.cs b/BtmsGateway/Utils/Http/Proxy.cs
index 5ebc83fd..3733d754 100644
--- a/BtmsGateway/Utils/Http/Proxy.cs
+++ b/BtmsGateway/Utils/Http/Proxy.cs
@@ -76,7 +76,7 @@ int httpClientRetryCount
[ExcludeFromCodeCoverage]
private static HttpClientHandler ConfigurePrimaryHttpMessageHandler()
{
- var proxyUri = Environment.GetEnvironmentVariable("CDP_HTTPS_PROXY");
+ var proxyUri = Environment.GetEnvironmentVariable("HTTPS_PROXY");
return CreateHttpClientHandler(proxyUri);
}
@@ -91,33 +91,8 @@ public static WebProxy CreateProxy(string? proxyUri)
var proxy = new WebProxy { BypassProxyOnLocal = true };
if (proxyUri != null)
{
- ConfigureProxy(proxy, proxyUri);
+ proxy.Address = new UriBuilder(proxyUri).Uri;
}
return proxy;
}
-
- public static void ConfigureProxy(WebProxy proxy, string proxyUri)
- {
- var uri = new UriBuilder(proxyUri);
-
- var credentials = GetCredentialsFromUri(uri);
- if (credentials != null)
- {
- proxy.Credentials = credentials;
- }
-
- // Remove credentials from URI to so they don't get logged.
- uri.UserName = "";
- uri.Password = "";
- proxy.Address = uri.Uri;
- }
-
- private static NetworkCredential? GetCredentialsFromUri(UriBuilder uri)
- {
- var username = uri.UserName;
- var password = uri.Password;
- if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
- return null;
- return new NetworkCredential(username, password);
- }
}
diff --git a/tests/BtmsGateway.Test/Http/ProxyTest.cs b/tests/BtmsGateway.Test/Http/ProxyTest.cs
index 23b2e3d9..cdbcc8b1 100644
--- a/tests/BtmsGateway.Test/Http/ProxyTest.cs
+++ b/tests/BtmsGateway.Test/Http/ProxyTest.cs
@@ -9,45 +9,10 @@ public class ProxyTest
private const string LocalProxy = "http://localhost:8080/";
private const string Localhost = "http://localhost/";
- [Fact]
- public void ExtractProxyCredentials()
- {
- var proxy = new System.Net.WebProxy { BypassProxyOnLocal = true };
-
- Proxy.ConfigureProxy(proxy, ProxyUri);
-
- var credentials = proxy.Credentials?.GetCredential(new Uri(ProxyUri), "Basic");
-
- credentials?.UserName.Should().Be("user");
- credentials?.Password.Should().Be("password");
- }
-
- [Fact]
- public void ExtractProxyEmptyCredentials()
- {
- var noPasswordUri = "http://user@localhost:8080";
-
- var proxy = new System.Net.WebProxy { BypassProxyOnLocal = true };
-
- Proxy.ConfigureProxy(proxy, noPasswordUri);
-
- proxy.Credentials.Should().BeNull();
- }
-
- [Fact]
- public void ExtractProxyUri()
- {
- var proxy = new System.Net.WebProxy { BypassProxyOnLocal = true };
-
- Proxy.ConfigureProxy(proxy, ProxyUri);
- proxy.Address.Should().NotBeNull();
- proxy.Address?.AbsoluteUri.Should().Be(LocalProxy);
- }
-
[Fact]
public void CreateProxyFromUri()
{
- var proxy = Proxy.CreateProxy(ProxyUri);
+ var proxy = Proxy.CreateProxy(LocalProxy);
proxy.Address.Should().NotBeNull();
proxy.Address?.AbsoluteUri.Should().Be(LocalProxy);
@@ -74,11 +39,11 @@ public void ProxyShouldBypassLocal()
[Fact]
public void HandlerShouldHaveProxy()
{
- var handler = Proxy.CreateHttpClientHandler(ProxyUri);
+ var handler = Proxy.CreateHttpClientHandler(LocalProxy);
handler.Proxy.Should().NotBeNull();
handler.UseProxy.Should().BeTrue();
- handler.Proxy?.Credentials.Should().NotBeNull();
+ handler.Proxy?.Credentials.Should().BeNull();
handler.Proxy?.GetProxy(new Uri(Localhost)).Should().NotBeNull();
handler.Proxy?.GetProxy(new Uri("http://google.com")).Should().NotBeNull();
handler.Proxy?.GetProxy(new Uri(Localhost))?.AbsoluteUri.Should().Be(Localhost);