fix: add Discord OAuth token exchange logging for production diagnostics
PR Checks / test-and-build (pull_request) Failing after 6m20s
PR Checks / test-and-build (pull_request) Failing after 6m20s
- Log status code and response body when Discord /oauth2/token fails - Helps identify why ExchangeCodeAsync returns null in production Bump version → 2.8.1 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Text.Json;
|
||||
using GmRelay.Web;
|
||||
using GmRelay.Web.Services;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
|
||||
namespace GmRelay.Bot.Tests.Web;
|
||||
|
||||
@@ -20,7 +21,7 @@ public class DiscordAuthServiceTests
|
||||
})
|
||||
.Build();
|
||||
|
||||
var service = new DiscordAuthService(new TestHttpClientFactory(), config);
|
||||
var service = new DiscordAuthService(new TestHttpClientFactory(), config, NullLogger<DiscordAuthService>.Instance);
|
||||
var url = service.BuildAuthorizeUrl("state123");
|
||||
|
||||
Assert.Contains("client_id=12345", url);
|
||||
@@ -33,7 +34,7 @@ public class DiscordAuthServiceTests
|
||||
public void BuildAuthorizeUrl_WithMissingConfig_ThrowsInvalidOperationException()
|
||||
{
|
||||
var config = new ConfigurationBuilder().Build();
|
||||
var service = new DiscordAuthService(new TestHttpClientFactory(), config);
|
||||
var service = new DiscordAuthService(new TestHttpClientFactory(), config, NullLogger<DiscordAuthService>.Instance);
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() => service.BuildAuthorizeUrl("state"));
|
||||
}
|
||||
@@ -74,7 +75,7 @@ public class DiscordAuthServiceTests
|
||||
.Build();
|
||||
|
||||
var factory = new TestHttpClientFactory(handler);
|
||||
var service = new DiscordAuthService(factory, config);
|
||||
var service = new DiscordAuthService(factory, config, NullLogger<DiscordAuthService>.Instance);
|
||||
|
||||
var result = await service.ExchangeCodeAsync("valid_code");
|
||||
|
||||
@@ -102,7 +103,7 @@ public class DiscordAuthServiceTests
|
||||
.Build();
|
||||
|
||||
var factory = new TestHttpClientFactory(handler);
|
||||
var service = new DiscordAuthService(factory, config);
|
||||
var service = new DiscordAuthService(factory, config, NullLogger<DiscordAuthService>.Instance);
|
||||
|
||||
var result = await service.ExchangeCodeAsync("invalid_code");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user