mirror of
https://github.com/DuendeSoftware/products
synced 2026-05-24 09:28:24 +00:00
Added diagnostic entry for basic server info
This commit is contained in:
parent
2a4086ae8b
commit
befbcdf38f
3 changed files with 44 additions and 0 deletions
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#nullable enable
|
||||
|
||||
using System.Net;
|
||||
using Duende.IdentityServer;
|
||||
using Duende.IdentityServer.Configuration;
|
||||
using Duende.IdentityServer.Configuration.DependencyInjection;
|
||||
|
|
@ -220,6 +221,7 @@ public static class IdentityServerBuilderExtensionsCore
|
|||
builder.Services.AddSingleton<IDiagnosticEntry, DataProtectionDiagnosticEntry>();
|
||||
builder.Services.AddSingleton<IDiagnosticEntry, TokenIssueCountDiagnosticEntry>();
|
||||
builder.Services.AddSingleton<IDiagnosticEntry, LicenseUsageDiagnosticEntry>();
|
||||
builder.Services.AddSingleton<IDiagnosticEntry>(new BasicServerInfoDiagnosticEntry(Dns.GetHostName));
|
||||
builder.Services.AddSingleton<DiagnosticSummary>();
|
||||
builder.Services.AddHostedService<DiagnosticHostedService>();
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Duende Software. All rights reserved.
|
||||
// See LICENSE in the project root for license information.
|
||||
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Duende.IdentityServer.Licensing.V2.Diagnostics.DiagnosticEntries;
|
||||
|
||||
internal class BasicServerInfoDiagnosticEntry(Func<string> hostNameResolver) : IDiagnosticEntry
|
||||
{
|
||||
public Task WriteAsync(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject("BasicServerInfo");
|
||||
|
||||
writer.WriteString("HostName", hostNameResolver());
|
||||
|
||||
writer.WriteEndObject();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (c) Duende Software. All rights reserved.
|
||||
// See LICENSE in the project root for license information.
|
||||
|
||||
using Duende.IdentityServer.Licensing.V2.Diagnostics.DiagnosticEntries;
|
||||
using IdentityServer.UnitTests.Licensing.V2.DiagnosticEntries;
|
||||
|
||||
namespace IdentityServer.UnitTests.Licensing.v2.DiagnosticEntries;
|
||||
|
||||
public class BasicServerInfoDiagnosticEntryTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task WriteAsync_ShouldWriteBasicServerInfo()
|
||||
{
|
||||
const string expectedHostName = "testing.local";
|
||||
var subject = new BasicServerInfoDiagnosticEntry(() => expectedHostName);
|
||||
|
||||
var result = await DiagnosticEntryTestHelper.WriteEntryToJson(subject);
|
||||
|
||||
var basicServerInfo = result.RootElement.GetProperty("BasicServerInfo");
|
||||
basicServerInfo.GetProperty("HostName").GetString().ShouldBe(expectedHostName);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue