Add unit tests for Router configuration and transport layers
- Implemented tests for RouterConfig, RoutingOptions, StaticInstanceConfig, and RouterConfigOptions to ensure default values are set correctly. - Added tests for RouterConfigProvider to validate configurations and ensure defaults are returned when no file is specified. - Created tests for ConfigValidationResult to check success and error scenarios. - Developed tests for ServiceCollectionExtensions to verify service registration for RouterConfig. - Introduced UdpTransportTests to validate serialization, connection, request-response, and error handling in UDP transport. - Added scripts for signing authority gaps and hashing DevPortal SDK snippets.
This commit is contained in:
207
src/Cli/StellaOps.Cli/Services/Models/AttestorTransportModels.cs
Normal file
207
src/Cli/StellaOps.Cli/Services/Models/AttestorTransportModels.cs
Normal file
@@ -0,0 +1,207 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace StellaOps.Cli.Services.Models;
|
||||
|
||||
// CLI-ATTEST-73-001: Attestor SDK transport contract models
|
||||
// Based on docs/schemas/attestor-transport.schema.json
|
||||
|
||||
/// <summary>
|
||||
/// Request to create an attestation.
|
||||
/// </summary>
|
||||
internal sealed class AttestationRequest
|
||||
{
|
||||
[JsonPropertyName("requestType")]
|
||||
public string RequestType { get; init; } = "CREATE_ATTESTATION";
|
||||
|
||||
[JsonPropertyName("requestId")]
|
||||
public string RequestId { get; init; } = Guid.NewGuid().ToString();
|
||||
|
||||
[JsonPropertyName("correlationId")]
|
||||
public string? CorrelationId { get; init; }
|
||||
|
||||
[JsonPropertyName("predicateType")]
|
||||
public string PredicateType { get; init; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("subject")]
|
||||
public IReadOnlyList<AttestationSubjectDto> Subject { get; init; } = Array.Empty<AttestationSubjectDto>();
|
||||
|
||||
[JsonPropertyName("predicate")]
|
||||
public object Predicate { get; init; } = new { };
|
||||
|
||||
[JsonPropertyName("signingOptions")]
|
||||
public SigningOptionsDto? SigningOptions { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Response for attestation creation.
|
||||
/// </summary>
|
||||
internal sealed class AttestationResponseDto
|
||||
{
|
||||
[JsonPropertyName("responseType")]
|
||||
public string ResponseType { get; init; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("requestId")]
|
||||
public string RequestId { get; init; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("status")]
|
||||
public string Status { get; init; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("attestation")]
|
||||
public AttestationEnvelopeDto? Attestation { get; init; }
|
||||
|
||||
[JsonPropertyName("error")]
|
||||
public AttestationErrorDto? Error { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subject for attestation.
|
||||
/// </summary>
|
||||
internal sealed class AttestationSubjectDto
|
||||
{
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; init; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("digest")]
|
||||
public Dictionary<string, string> Digest { get; init; } = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Signing options for attestation.
|
||||
/// </summary>
|
||||
internal sealed class SigningOptionsDto
|
||||
{
|
||||
[JsonPropertyName("keyId")]
|
||||
public string? KeyId { get; init; }
|
||||
|
||||
[JsonPropertyName("provider")]
|
||||
public string? Provider { get; init; }
|
||||
|
||||
[JsonPropertyName("algorithm")]
|
||||
public string? Algorithm { get; init; }
|
||||
|
||||
[JsonPropertyName("transparencyLog")]
|
||||
public bool TransparencyLog { get; init; }
|
||||
|
||||
[JsonPropertyName("timestampAuthority")]
|
||||
public string? TimestampAuthority { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DSSE attestation envelope from response.
|
||||
/// </summary>
|
||||
internal sealed class AttestationEnvelopeDto
|
||||
{
|
||||
[JsonPropertyName("payloadType")]
|
||||
public string PayloadType { get; init; } = "application/vnd.in-toto+json";
|
||||
|
||||
[JsonPropertyName("payload")]
|
||||
public string Payload { get; init; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("signatures")]
|
||||
public IReadOnlyList<DsseSignatureDto> Signatures { get; init; } = Array.Empty<DsseSignatureDto>();
|
||||
|
||||
[JsonPropertyName("envelopeDigest")]
|
||||
public string? EnvelopeDigest { get; init; }
|
||||
|
||||
[JsonPropertyName("transparencyLogEntry")]
|
||||
public TransparencyLogEntryDto? TransparencyLogEntry { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DSSE signature.
|
||||
/// </summary>
|
||||
internal sealed class DsseSignatureDto
|
||||
{
|
||||
[JsonPropertyName("keyid")]
|
||||
public string KeyId { get; init; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("sig")]
|
||||
public string Sig { get; init; } = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transparency log entry from Rekor.
|
||||
/// </summary>
|
||||
internal sealed class TransparencyLogEntryDto
|
||||
{
|
||||
[JsonPropertyName("logIndex")]
|
||||
public long LogIndex { get; init; }
|
||||
|
||||
[JsonPropertyName("logId")]
|
||||
public string? LogId { get; init; }
|
||||
|
||||
[JsonPropertyName("integratedTime")]
|
||||
public DateTimeOffset? IntegratedTime { get; init; }
|
||||
|
||||
[JsonPropertyName("inclusionProof")]
|
||||
public string? InclusionProof { get; init; }
|
||||
|
||||
[JsonPropertyName("entryUri")]
|
||||
public string? EntryUri { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Error from attestation operation.
|
||||
/// </summary>
|
||||
internal sealed class AttestationErrorDto
|
||||
{
|
||||
[JsonPropertyName("code")]
|
||||
public string Code { get; init; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("message")]
|
||||
public string Message { get; init; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("details")]
|
||||
public Dictionary<string, object>? Details { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Options for the attest sign command.
|
||||
/// </summary>
|
||||
internal sealed class AttestSignOptions
|
||||
{
|
||||
public string PredicatePath { get; init; } = string.Empty;
|
||||
public string PredicateType { get; init; } = string.Empty;
|
||||
public string SubjectName { get; init; } = string.Empty;
|
||||
public string SubjectDigest { get; init; } = string.Empty;
|
||||
public string? KeyId { get; init; }
|
||||
public bool Keyless { get; init; }
|
||||
public bool UseRekor { get; init; }
|
||||
public string? OutputPath { get; init; }
|
||||
public string Format { get; init; } = "dsse";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Result from attest sign command.
|
||||
/// </summary>
|
||||
internal sealed class AttestSignResult
|
||||
{
|
||||
[JsonPropertyName("success")]
|
||||
public bool Success { get; init; }
|
||||
|
||||
[JsonPropertyName("envelopePath")]
|
||||
public string? EnvelopePath { get; init; }
|
||||
|
||||
[JsonPropertyName("envelopeDigest")]
|
||||
public string? EnvelopeDigest { get; init; }
|
||||
|
||||
[JsonPropertyName("predicateType")]
|
||||
public string PredicateType { get; init; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("subjectName")]
|
||||
public string SubjectName { get; init; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("subjectDigest")]
|
||||
public string SubjectDigest { get; init; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("keyId")]
|
||||
public string? KeyId { get; init; }
|
||||
|
||||
[JsonPropertyName("transparencyLogEntry")]
|
||||
public TransparencyLogEntryDto? TransparencyLogEntry { get; init; }
|
||||
|
||||
[JsonPropertyName("error")]
|
||||
public string? Error { get; init; }
|
||||
}
|
||||
Reference in New Issue
Block a user