Revert "Test host: bind Kestrel to Site:Authority instead of dynamic port"
This reverts commit 402bcc1db8.
This commit is contained in:
parent
1ab0bef9a4
commit
09604092c5
3 changed files with 17 additions and 76 deletions
|
|
@ -1,7 +1,6 @@
|
|||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Net.Security;
|
||||
using IdentityModel.Client;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Yavsc.Org.Tests
|
||||
{
|
||||
|
|
@ -25,43 +24,7 @@ namespace Yavsc.Org.Tests
|
|||
|
||||
HttpClient client = NewHttpClient();
|
||||
var disco = await client.GetDiscoveryDocumentAsync(serverUrl);
|
||||
if (disco.IsError)
|
||||
{
|
||||
// Diagnostic 2026-07-12 : capture the raw HTTP response
|
||||
// AND dump the OIDC-related DB state so we can pinpoint
|
||||
// which state is corrupt when the discovery is broken.
|
||||
var rawResp = await client.GetAsync(serverUrl + "/.well-known/openid-configuration");
|
||||
var body = await rawResp.Content.ReadAsStringAsync();
|
||||
|
||||
string dbState = "no logger";
|
||||
try
|
||||
{
|
||||
using var scope = _serverFixture.Services.CreateScope();
|
||||
var cfg = scope.ServiceProvider
|
||||
.GetRequiredService<IdentityServer8.EntityFramework.DbContexts.ConfigurationDbContext>();
|
||||
var clients = cfg.Clients.Select(c => new {
|
||||
c.Id, c.ClientId, c.Enabled, c.RequireClientSecret
|
||||
}).ToList();
|
||||
var apiScopes = cfg.ApiScopes.Select(s => new { s.Name, s.Enabled }).ToList();
|
||||
var apiResources = cfg.ApiResources.Select(r => new { r.Name, r.Enabled }).ToList();
|
||||
var identityResources = cfg.IdentityResources.Select(r => new { r.Name, r.Enabled }).ToList();
|
||||
dbState = $"clients={System.Text.Json.JsonSerializer.Serialize(clients)}\n" +
|
||||
$"apiScopes={System.Text.Json.JsonSerializer.Serialize(apiScopes)}\n" +
|
||||
$"apiResources={System.Text.Json.JsonSerializer.Serialize(apiResources)}\n" +
|
||||
$"identityResources={System.Text.Json.JsonSerializer.Serialize(identityResources)}";
|
||||
}
|
||||
catch (Exception dumpEx)
|
||||
{
|
||||
dbState = $"dump failed: {dumpEx.Message}";
|
||||
}
|
||||
|
||||
throw new Exception(
|
||||
$"disco.Error={disco.Error}\n" +
|
||||
$"HTTP status={(int)rawResp.StatusCode}\n" +
|
||||
$"Body[0..2000]:\n{body.Substring(0, Math.Min(2000, body.Length))}\n" +
|
||||
$"---\n" +
|
||||
$"OIDC DB state at failure:\n{dbState}");
|
||||
}
|
||||
if (disco.IsError) throw new Exception(disco.Error);
|
||||
|
||||
var response = await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
|
||||
{
|
||||
|
|
|
|||
|
|
@ -73,19 +73,6 @@ public sealed class WebServerFixture : WebHostFixture
|
|||
// that plus the in-memory overrides below.
|
||||
builder.AddConfiguration(null).AddInMemoryCollection(new Dictionary<string, string?>
|
||||
{
|
||||
// Test host: fixed authority + external URL. Matches
|
||||
// the Kestrel bind in WebHostFixture.InitializeAsync
|
||||
// (https://localhost:44300) so IdentityServer8's
|
||||
// discovery document and the test client agree on the
|
||||
// same base URL. IdentityServer8 reads Site:Authority
|
||||
// to populate the `issuer` claim, the discovery
|
||||
// document's `issuer` and endpoint URLs — leaving it
|
||||
// pointed at the production host (e.g.
|
||||
// mercure.pschneider.fr) made /.well-known/openid-configuration
|
||||
// return URLs unreachable from the test, hence
|
||||
// "Internal Server Error" in the discovery call.
|
||||
["Site:Authority"] = "https://localhost:44300",
|
||||
["Site:ExternalUrl"] = "https://localhost:44300",
|
||||
[$"ConnectionStrings:{YavscConstants.YavscConnectionStringName}"] = "InMemory",
|
||||
// SMTP test config: UserName non-null so MailSender
|
||||
// exercises the Authenticate branch — the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue