Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#nullable enable

using System.Net;
using Duende.IdentityServer;
using Duende.IdentityServer.Configuration;
using Duende.IdentityServer.Configuration.DependencyInjection;
Expand Down Expand Up @@ -220,6 +221,7 @@ public static IIdentityServerBuilder AddCoreServices(this IIdentityServerBuilder
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>();

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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