Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
DOTNET-202: Fix .NET Core proxy support
  • Loading branch information
homiedopie committed Sep 15, 2025
commit 3d9146b5d11f1c8ede675e374d73fbcd3cfc2a76
2 changes: 0 additions & 2 deletions Src/StackifyLib/Utils/HttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ public bool IsClientError()

static HttpClient()
{
#if NETFULL
LoadWebProxyConfig();
#endif
}

public HttpClient(string apiKey, string apiUrl)
Expand Down
55 changes: 55 additions & 0 deletions test/StackifyLib.UnitTests/Utils/HttpClient_Loading_Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) 2024-2025 BMC Software, Inc.
// Copyright (c) 2021-2024 Netreo
// Copyright (c) 2019 Stackify
using Moq;
using StackifyLib.Models;
using StackifyLib.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Reflection;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using Xunit;

namespace StackifyLib.UnitTests.Utils
{
public class HttpClient_Loading_Tests : IDisposable
{
private readonly HttpClient _httpClient;

public HttpClient_Loading_Tests()
{
// Store original values to restore after tests
Config.ProxyServer = "http://testuser:[email protected]:8881";
_httpClient = new HttpClient("test-api-key", "https://test.api.com/");
HttpClient.IsUnitTest = true;
}

public void Dispose()
{
HttpClient.IsUnitTest = false;
}

[Fact(Skip = "This test should be run explicitly (due to static loading nature of HttpClient)")]
public void LoadWebProxyConfig_DefaultBehavior()
{
// Arrange - Mock the Config.Get method to return true for UseDefaultCredentials
try
{
var customProxy = HttpClient.CustomWebProxy as WebProxy;
Assert.NotNull(customProxy);

// Note: We can't easily test UseDefaultCredentials without mocking Config.Get
// This test verifies the method runs without error when proxy is configured
Assert.Equal("docker-hyperv.local", customProxy.Address.Host);
Assert.Equal(8881, customProxy.Address.Port);
}
finally
{
}
}
}
}
Loading