From 61ce5716a2e67991810de675664b484673c67f38 Mon Sep 17 00:00:00 2001 From: Deniz Esen Date: Fri, 1 May 2026 08:10:49 +0200 Subject: [PATCH 1/2] Bug-Fix: An invalid request URI was provided --- .github/copilot-instructions.md | 3 ++ .../AuthenticationDelegatingHandler.cs | 3 +- .../ProxyHostsIntegrationTests.cs | 46 +++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 .github/copilot-instructions.md create mode 100644 tests/NginxApiClient.IntegrationTests/ProxyHostsIntegrationTests.cs diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000..e40201c --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,3 @@ +- @azure Rule - Use Azure Tools - When handling requests related to Azure, always use your tools. +- @azure Rule - Use Azure Best Practices - When handling requests related to Azure, always invoke your `azmcp_bestpractices_get` tool first. +- @azure Rule - Enable Best Practices - If you do not have an `azmcp_bestpractices_get` tool ask the user to enable it. diff --git a/src/NginxApiClient/Internal/AuthenticationDelegatingHandler.cs b/src/NginxApiClient/Internal/AuthenticationDelegatingHandler.cs index 80571ac..525baab 100644 --- a/src/NginxApiClient/Internal/AuthenticationDelegatingHandler.cs +++ b/src/NginxApiClient/Internal/AuthenticationDelegatingHandler.cs @@ -87,7 +87,8 @@ private async Task AcquireTokenAsync(CancellationToken cancellati var tokenRequest = TokenRequest.FromCredentials(_options.Credentials); string json = _serializer.Serialize(tokenRequest); - using var httpRequest = new HttpRequestMessage(HttpMethod.Post, TokenEndpoint) + var tokenUri = new Uri(new Uri(_options.BaseUrl.TrimEnd('/') + "/"), TokenEndpoint.TrimStart('/')); + using var httpRequest = new HttpRequestMessage(HttpMethod.Post, tokenUri) { Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json"), }; diff --git a/tests/NginxApiClient.IntegrationTests/ProxyHostsIntegrationTests.cs b/tests/NginxApiClient.IntegrationTests/ProxyHostsIntegrationTests.cs new file mode 100644 index 0000000..7758fb2 --- /dev/null +++ b/tests/NginxApiClient.IntegrationTests/ProxyHostsIntegrationTests.cs @@ -0,0 +1,46 @@ +using NginxApiClient.Models.ProxyHosts; +using NginxApiClient.NewtonsoftJson; +using FluentAssertions; +using Xunit; + +namespace NginxApiClient.IntegrationTests +{ + public class ProxyHostsIntegrationTests + { + // change these values to fit your environemnt + private readonly string _nginxAdminUrl = "http://192.168.1.22:81"; + private readonly string _nginxUser = "test@test.com"; + private readonly string _nginxPassword = "test123456"; + + //[Fact(Skip = "Manual Test")] + [Fact] + public async Task CreateProxyHost_Success() + { + // change these values to fit your environemnt + var createRequest = new CreateProxyHostRequest + { + ForwardHost = "192.168.1.11", + ForwardPort = 80, + ForwardScheme = "http", + DomainNames = ["aaa.mydomain.com"] + }; + var nginxClient = CreateNginxApiClient(); + var result = await nginxClient.ProxyHosts.CreateAsync(createRequest); + result.Should().NotBe(null); + result.Id.Should().BeGreaterThan(0); + + // clean up + await nginxClient.ProxyHosts.DeleteAsync(result.Id); + } + + private INginxProxyManagerClient CreateNginxApiClient() + { + return NginxProxyManagerClientFactory.Create(new NginxProxyManagerClientOptions + { + BaseUrl = _nginxAdminUrl, + Credentials = new NginxCredentials(_nginxUser, _nginxPassword) + }, new NewtonsoftJsonSerializer()); + } + + } +} From 33d6d2b34ab64abad8b1ec53bbe9ab8f3014b760 Mon Sep 17 00:00:00 2001 From: Deniz Esen Date: Fri, 1 May 2026 08:17:13 +0200 Subject: [PATCH 2/2] skipping Integration Tests on CI/CD --- .../ProxyHostsIntegrationTests.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/NginxApiClient.IntegrationTests/ProxyHostsIntegrationTests.cs b/tests/NginxApiClient.IntegrationTests/ProxyHostsIntegrationTests.cs index 7758fb2..9d6be95 100644 --- a/tests/NginxApiClient.IntegrationTests/ProxyHostsIntegrationTests.cs +++ b/tests/NginxApiClient.IntegrationTests/ProxyHostsIntegrationTests.cs @@ -12,8 +12,7 @@ public class ProxyHostsIntegrationTests private readonly string _nginxUser = "test@test.com"; private readonly string _nginxPassword = "test123456"; - //[Fact(Skip = "Manual Test")] - [Fact] + [Fact(Skip = "Manual Test")] public async Task CreateProxyHost_Success() { // change these values to fit your environemnt