File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed
Configuration/DependencyInjection/BuilderExtensions
Licensing/V2/Diagnostics/DiagnosticEntries
test/IdentityServer.UnitTests/Licensing/v2/DiagnosticEntries Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 44
55#nullable enable
66
7+ using System . Net ;
78using Duende . IdentityServer ;
89using Duende . IdentityServer . Configuration ;
910using Duende . IdentityServer . Configuration . DependencyInjection ;
@@ -220,6 +221,7 @@ public static IIdentityServerBuilder AddCoreServices(this IIdentityServerBuilder
220221 builder . Services . AddSingleton < IDiagnosticEntry , DataProtectionDiagnosticEntry > ( ) ;
221222 builder . Services . AddSingleton < IDiagnosticEntry , TokenIssueCountDiagnosticEntry > ( ) ;
222223 builder . Services . AddSingleton < IDiagnosticEntry , LicenseUsageDiagnosticEntry > ( ) ;
224+ builder . Services . AddSingleton < IDiagnosticEntry > ( new BasicServerInfoDiagnosticEntry ( Dns . GetHostName ) ) ;
223225 builder . Services . AddSingleton < DiagnosticSummary > ( ) ;
224226 builder . Services . AddHostedService < DiagnosticHostedService > ( ) ;
225227
Original file line number Diff line number Diff line change 1+ // Copyright (c) Duende Software. All rights reserved.
2+ // See LICENSE in the project root for license information.
3+
4+ using System . Text . Json ;
5+
6+ namespace Duende . IdentityServer . Licensing . V2 . Diagnostics . DiagnosticEntries ;
7+
8+ internal class BasicServerInfoDiagnosticEntry ( Func < string > hostNameResolver ) : IDiagnosticEntry
9+ {
10+ public Task WriteAsync ( Utf8JsonWriter writer )
11+ {
12+ writer . WriteStartObject ( "BasicServerInfo" ) ;
13+
14+ writer . WriteString ( "HostName" , hostNameResolver ( ) ) ;
15+
16+ writer . WriteEndObject ( ) ;
17+
18+ return Task . CompletedTask ;
19+ }
20+ }
Original file line number Diff line number Diff line change 1+ // Copyright (c) Duende Software. All rights reserved.
2+ // See LICENSE in the project root for license information.
3+
4+ using Duende . IdentityServer . Licensing . V2 . Diagnostics . DiagnosticEntries ;
5+ using IdentityServer . UnitTests . Licensing . V2 . DiagnosticEntries ;
6+
7+ namespace IdentityServer . UnitTests . Licensing . v2 . DiagnosticEntries ;
8+
9+ public class BasicServerInfoDiagnosticEntryTests
10+ {
11+ [ Fact ]
12+ public async Task WriteAsync_ShouldWriteBasicServerInfo ( )
13+ {
14+ const string expectedHostName = "testing.local" ;
15+ var subject = new BasicServerInfoDiagnosticEntry ( ( ) => expectedHostName ) ;
16+
17+ var result = await DiagnosticEntryTestHelper . WriteEntryToJson ( subject ) ;
18+
19+ var basicServerInfo = result . RootElement . GetProperty ( "BasicServerInfo" ) ;
20+ basicServerInfo . GetProperty ( "HostName" ) . GetString ( ) . ShouldBe ( expectedHostName ) ;
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments