refactor(adminui): omit error key on success cert-audit rows + assert OccurredAtUtc (review)
This commit is contained in:
@@ -28,18 +28,17 @@ public static class CertAuditEvents
|
||||
/// <see cref="AuditOutcome.Success" />); otherwise <see langword="false" /> (Outcome
|
||||
/// <see cref="AuditOutcome.Failure" />).</param>
|
||||
/// <param name="error">On failure, the error text carried in the details payload; ignored on
|
||||
/// success (the details payload serializes <see langword="null" /> for the error field).</param>
|
||||
/// success (the <c>error</c> field is omitted from the details payload entirely).</param>
|
||||
/// <returns>A fully populated <see cref="AuditEvent" /> with a fresh <see cref="AuditEvent.EventId" />
|
||||
/// and <see cref="AuditEvent.OccurredAtUtc" /> set to now (UTC).</returns>
|
||||
public static AuditEvent Build(
|
||||
string action, string store, string thumbprint, string actor, bool success, string? error)
|
||||
{
|
||||
var detailsJson = JsonSerializer.Serialize(new
|
||||
{
|
||||
store,
|
||||
thumbprint,
|
||||
error = success ? null : error,
|
||||
});
|
||||
// On success the error field is omitted entirely (not serialized as null) so the common
|
||||
// success-path audit row carries no dead "error" key.
|
||||
var detailsJson = JsonSerializer.Serialize(success
|
||||
? (object)new { store, thumbprint }
|
||||
: new { store, thumbprint, error });
|
||||
|
||||
return new AuditEvent
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user