consolidation of some of the modules, localization fixes, product advisories work, qa work
This commit is contained in:
@@ -1,113 +0,0 @@
|
||||
using System.Collections.Immutable;
|
||||
using FluentAssertions;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Time.Testing;
|
||||
using StellaOps.AdvisoryLens.DependencyInjection;
|
||||
using StellaOps.AdvisoryLens.Models;
|
||||
using StellaOps.AdvisoryLens.Services;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.AdvisoryLens.Tests;
|
||||
|
||||
public sealed class AdvisoryLensIntegrationTests
|
||||
{
|
||||
[Fact]
|
||||
public void DI_Registration_Resolves_Service()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddAdvisoryLens();
|
||||
using var provider = services.BuildServiceProvider();
|
||||
|
||||
var service = provider.GetService<IAdvisoryLensService>();
|
||||
|
||||
service.Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Tenant_Scoping_Flows_Through_Context()
|
||||
{
|
||||
var service = new AdvisoryLensService(CreatePatterns(), new FakeTimeProvider(new DateTimeOffset(2026, 2, 8, 0, 0, 0, TimeSpan.Zero)));
|
||||
|
||||
var tenantA = service.Evaluate(CreateContext("tenant-a"));
|
||||
var tenantB = service.Evaluate(CreateContext("tenant-b"));
|
||||
|
||||
tenantA.Should().NotBeNull();
|
||||
tenantA.InputHash.Should().StartWith("sha256:");
|
||||
tenantA.InputHash.Should().NotBe(tenantB.InputHash);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Error_Mapping_For_Invalid_Input()
|
||||
{
|
||||
var service = new AdvisoryLensService(Array.Empty<CasePattern>());
|
||||
|
||||
Action evaluate = () => service.Evaluate(null!);
|
||||
|
||||
evaluate.Should().Throw<ArgumentNullException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Offline_Execution_No_Network()
|
||||
{
|
||||
var service = new AdvisoryLensService(CreatePatterns());
|
||||
|
||||
var result = service.Evaluate(CreateContext("tenant-offline"));
|
||||
|
||||
result.Should().NotBeNull();
|
||||
result.MatchedPatterns.Should().ContainSingle().Which.Should().Be("custom-pattern");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DI_Registration_With_Custom_Patterns()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddAdvisoryLens(
|
||||
CreatePatterns(),
|
||||
new FakeTimeProvider(new DateTimeOffset(2026, 2, 8, 1, 0, 0, TimeSpan.Zero)));
|
||||
using var provider = services.BuildServiceProvider();
|
||||
|
||||
var service = provider.GetRequiredService<IAdvisoryLensService>();
|
||||
var result = service.Evaluate(CreateContext("tenant-custom"));
|
||||
|
||||
result.MatchedPatterns.Should().ContainSingle().Which.Should().Be("custom-pattern");
|
||||
result.Suggestions.Should().ContainSingle();
|
||||
result.Suggestions[0].Title.Should().Be("Custom escalation");
|
||||
result.EvaluatedAtUtc.Should().Be(new DateTime(2026, 2, 8, 1, 0, 0, DateTimeKind.Utc));
|
||||
}
|
||||
|
||||
private static LensContext CreateContext(string tenantId)
|
||||
{
|
||||
return new LensContext
|
||||
{
|
||||
AdvisoryCase = new AdvisoryCase
|
||||
{
|
||||
AdvisoryId = "ADV-INT-01",
|
||||
Cve = "CVE-2026-7777",
|
||||
Purl = "pkg:nuget/integration.demo@1.2.3",
|
||||
Severity = AdvisorySeverity.High,
|
||||
Source = "NVD"
|
||||
},
|
||||
TenantId = tenantId,
|
||||
VexStatements = ImmutableArray.Create("vex-int-1"),
|
||||
ReachabilityData = ImmutableArray.Create("reach-int-1"),
|
||||
PolicyTraces = ImmutableArray.Create("policy-int-1")
|
||||
};
|
||||
}
|
||||
|
||||
private static IReadOnlyList<CasePattern> CreatePatterns()
|
||||
{
|
||||
return
|
||||
[
|
||||
new CasePattern
|
||||
{
|
||||
PatternId = "custom-pattern",
|
||||
SeverityRange = new SeverityRange { Min = AdvisorySeverity.Medium, Max = AdvisorySeverity.Critical },
|
||||
EcosystemMatch = "nuget",
|
||||
CvePattern = "CVE-2026",
|
||||
DefaultAction = SuggestionAction.Escalate,
|
||||
SuggestionTitle = "Custom escalation",
|
||||
SuggestionRationale = "Integration-registered pattern should be selected"
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Text.Json;
|
||||
using FluentAssertions;
|
||||
using StellaOps.AdvisoryLens.Models;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.AdvisoryLens.Tests;
|
||||
|
||||
public sealed class AdvisoryLensModelTests
|
||||
{
|
||||
[Fact]
|
||||
public void Models_SerializeRoundTrip_AllTypes_ShouldRemainEquivalent()
|
||||
{
|
||||
var advisoryCase = new AdvisoryCase
|
||||
{
|
||||
AdvisoryId = "ADV-001",
|
||||
Cve = "CVE-2026-1234",
|
||||
Purl = "pkg:nuget/test.pkg@1.2.3",
|
||||
Severity = AdvisorySeverity.High,
|
||||
Source = "NVD",
|
||||
Title = "Sample advisory",
|
||||
Description = "Sample description",
|
||||
Metadata = ImmutableDictionary<string, string>.Empty.Add("region", "us")
|
||||
};
|
||||
|
||||
var suggestion = new LensSuggestion
|
||||
{
|
||||
Rank = 1,
|
||||
Title = "Patch now",
|
||||
Rationale = "Exploitability is high",
|
||||
Confidence = 0.95,
|
||||
Action = SuggestionAction.Mitigate,
|
||||
PatternId = "pat-critical"
|
||||
};
|
||||
|
||||
var hint = new LensHint
|
||||
{
|
||||
Text = "Reachability data available",
|
||||
Category = HintCategory.Reachability,
|
||||
EvidenceRefs = ImmutableArray.Create("reach-1")
|
||||
};
|
||||
|
||||
var pattern = new CasePattern
|
||||
{
|
||||
PatternId = "pat-critical",
|
||||
Description = "Critical nuget pattern",
|
||||
SeverityRange = new SeverityRange { Min = AdvisorySeverity.High, Max = AdvisorySeverity.Critical },
|
||||
EcosystemMatch = "nuget",
|
||||
CvePattern = "CVE-2026",
|
||||
RequiredVexStatus = ImmutableArray.Create("affected"),
|
||||
DefaultAction = SuggestionAction.Mitigate,
|
||||
SuggestionTitle = "Patch now",
|
||||
SuggestionRationale = "Critical package issue"
|
||||
};
|
||||
|
||||
var context = new LensContext
|
||||
{
|
||||
AdvisoryCase = advisoryCase,
|
||||
TenantId = "tenant-a",
|
||||
VexStatements = ImmutableArray.Create("vex-1"),
|
||||
PolicyTraces = ImmutableArray.Create("policy-1"),
|
||||
ReachabilityData = ImmutableArray.Create("reach-1"),
|
||||
EvaluationTimestampUtc = new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc)
|
||||
};
|
||||
|
||||
var result = new LensResult
|
||||
{
|
||||
Suggestions = ImmutableArray.Create(suggestion),
|
||||
Hints = ImmutableArray.Create(hint),
|
||||
MatchedPatterns = ImmutableArray.Create(pattern.PatternId),
|
||||
EvaluatedAtUtc = new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc),
|
||||
InputHash = "sha256:abc"
|
||||
};
|
||||
|
||||
RoundTrip(advisoryCase).Should().BeEquivalentTo(advisoryCase);
|
||||
RoundTrip(suggestion).Should().BeEquivalentTo(suggestion);
|
||||
RoundTrip(hint).Should().BeEquivalentTo(hint);
|
||||
RoundTrip(pattern).Should().BeEquivalentTo(pattern);
|
||||
RoundTrip(pattern.SeverityRange!).Should().BeEquivalentTo(pattern.SeverityRange);
|
||||
RoundTrip(context).Should().BeEquivalentTo(context);
|
||||
RoundTrip(result).Should().BeEquivalentTo(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Models_SerializeTwice_SameInput_ShouldProduceSameJson()
|
||||
{
|
||||
var payload = new LensContext
|
||||
{
|
||||
AdvisoryCase = new AdvisoryCase
|
||||
{
|
||||
AdvisoryId = "ADV-002",
|
||||
Cve = "CVE-2026-2222",
|
||||
Purl = "pkg:nuget/pkg@2.0.0",
|
||||
Severity = AdvisorySeverity.Medium,
|
||||
Source = "OSV",
|
||||
Metadata = ImmutableDictionary<string, string>.Empty.Add("k", "v")
|
||||
},
|
||||
TenantId = "tenant-deterministic",
|
||||
VexStatements = ImmutableArray.Create("vex-a"),
|
||||
PolicyTraces = ImmutableArray.Create("policy-a"),
|
||||
ReachabilityData = ImmutableArray.Create("reach-a"),
|
||||
EvaluationTimestampUtc = new DateTime(2026, 2, 2, 0, 0, 0, DateTimeKind.Utc)
|
||||
};
|
||||
|
||||
var first = JsonSerializer.Serialize(payload);
|
||||
var second = JsonSerializer.Serialize(payload);
|
||||
|
||||
second.Should().Be(first);
|
||||
}
|
||||
|
||||
private static T RoundTrip<T>(T instance)
|
||||
{
|
||||
var json = JsonSerializer.Serialize(instance);
|
||||
return JsonSerializer.Deserialize<T>(json)!;
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Text.Json;
|
||||
using FluentAssertions;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Time.Testing;
|
||||
using StellaOps.AdvisoryLens.DependencyInjection;
|
||||
using StellaOps.AdvisoryLens.Models;
|
||||
using StellaOps.AdvisoryLens.Services;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.AdvisoryLens.Tests;
|
||||
|
||||
public sealed class AdvisoryLensServiceTests
|
||||
{
|
||||
[Fact]
|
||||
public void Evaluate_FullFlow_ReturnsExpectedResult()
|
||||
{
|
||||
var context = CreateContext();
|
||||
var service = new AdvisoryLensService(CreatePatterns(), new FakeTimeProvider(new DateTimeOffset(2026, 1, 1, 0, 0, 0, TimeSpan.Zero)));
|
||||
|
||||
var result = service.Evaluate(context);
|
||||
|
||||
result.Suggestions.Should().NotBeEmpty();
|
||||
result.Hints.Should().HaveCount(4);
|
||||
result.MatchedPatterns.Should().ContainSingle().Which.Should().Be("pat-core");
|
||||
result.EvaluatedAtUtc.Should().Be(context.EvaluationTimestampUtc);
|
||||
result.InputHash.Should().StartWith("sha256:");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Evaluate_SameFrozenInput_IsDeterministic()
|
||||
{
|
||||
var context = CreateContext();
|
||||
var service = new AdvisoryLensService(CreatePatterns(), new FakeTimeProvider(new DateTimeOffset(2026, 1, 1, 0, 0, 0, TimeSpan.Zero)));
|
||||
|
||||
var first = service.Evaluate(context);
|
||||
var second = service.Evaluate(context);
|
||||
|
||||
JsonSerializer.Serialize(second).Should().Be(JsonSerializer.Serialize(first));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Evaluate_HintsGeneration_ContainsSeverityVexReachabilityPolicy()
|
||||
{
|
||||
var context = CreateContext();
|
||||
var service = new AdvisoryLensService(Array.Empty<CasePattern>(), new FakeTimeProvider(new DateTimeOffset(2026, 1, 1, 0, 0, 0, TimeSpan.Zero)));
|
||||
|
||||
var result = service.Evaluate(context);
|
||||
|
||||
result.Hints.Select(h => h.Category).Should().Equal(
|
||||
HintCategory.Severity,
|
||||
HintCategory.Reachability,
|
||||
HintCategory.Vex,
|
||||
HintCategory.Policy);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Evaluate_EmptyPatterns_ReturnsEmptySuggestionsWithValidResult()
|
||||
{
|
||||
var context = CreateContext();
|
||||
var service = new AdvisoryLensService(Array.Empty<CasePattern>(), new FakeTimeProvider(new DateTimeOffset(2026, 1, 1, 0, 0, 0, TimeSpan.Zero)));
|
||||
|
||||
var result = service.Evaluate(context);
|
||||
|
||||
result.Suggestions.Should().BeEmpty();
|
||||
result.MatchedPatterns.Should().BeEmpty();
|
||||
result.InputHash.Should().StartWith("sha256:");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Evaluate_InputHashStability_SameContextProducesSameHash()
|
||||
{
|
||||
var context = CreateContext();
|
||||
var service = new AdvisoryLensService(Array.Empty<CasePattern>(), new FakeTimeProvider(new DateTimeOffset(2026, 1, 1, 0, 0, 0, TimeSpan.Zero)));
|
||||
|
||||
var first = service.Evaluate(context);
|
||||
var second = service.Evaluate(context);
|
||||
|
||||
second.InputHash.Should().Be(first.InputHash);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddAdvisoryLens_RegistersResolvableService()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddAdvisoryLens(CreatePatterns(), new FakeTimeProvider(new DateTimeOffset(2026, 3, 1, 0, 0, 0, TimeSpan.Zero)));
|
||||
using var provider = services.BuildServiceProvider();
|
||||
|
||||
var service = provider.GetService<IAdvisoryLensService>();
|
||||
|
||||
service.Should().NotBeNull();
|
||||
var result = service!.Evaluate(CreateContext(withEvaluationTimestamp: false));
|
||||
result.EvaluatedAtUtc.Should().Be(new DateTime(2026, 3, 1, 0, 0, 0, DateTimeKind.Utc));
|
||||
}
|
||||
|
||||
private static LensContext CreateContext(bool withEvaluationTimestamp = true)
|
||||
{
|
||||
return new LensContext
|
||||
{
|
||||
AdvisoryCase = new AdvisoryCase
|
||||
{
|
||||
AdvisoryId = "ADV-900",
|
||||
Cve = "CVE-2026-9000",
|
||||
Purl = "pkg:nuget/test.lib@9.0.0",
|
||||
Severity = AdvisorySeverity.Critical,
|
||||
Source = "NVD"
|
||||
},
|
||||
TenantId = "tenant-1",
|
||||
VexStatements = ImmutableArray.Create("vex-1"),
|
||||
PolicyTraces = ImmutableArray.Create("policy-1"),
|
||||
ReachabilityData = ImmutableArray.Create("reach-1"),
|
||||
EvaluationTimestampUtc = withEvaluationTimestamp
|
||||
? new DateTime(2026, 1, 5, 12, 0, 0, DateTimeKind.Utc)
|
||||
: null
|
||||
};
|
||||
}
|
||||
|
||||
private static IReadOnlyList<CasePattern> CreatePatterns()
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
new CasePattern
|
||||
{
|
||||
PatternId = "pat-core",
|
||||
SeverityRange = new SeverityRange { Min = AdvisorySeverity.High, Max = AdvisorySeverity.Critical },
|
||||
EcosystemMatch = "nuget",
|
||||
CvePattern = "CVE-2026",
|
||||
DefaultAction = SuggestionAction.Escalate,
|
||||
SuggestionTitle = "Escalate review",
|
||||
SuggestionRationale = "Critical advisory in primary ecosystem"
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
using FluentAssertions;
|
||||
using StellaOps.AdvisoryLens.Matching;
|
||||
using StellaOps.AdvisoryLens.Models;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.AdvisoryLens.Tests;
|
||||
|
||||
public sealed class CaseMatcherTests
|
||||
{
|
||||
private static AdvisoryCase CreateCase(AdvisorySeverity severity = AdvisorySeverity.High)
|
||||
=> new()
|
||||
{
|
||||
AdvisoryId = "ADV-101",
|
||||
Cve = "CVE-2026-1001",
|
||||
Purl = "pkg:nuget/demo.package@1.0.0",
|
||||
Severity = severity
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Match_HappyPath_ReturnsPositiveScore()
|
||||
{
|
||||
var matcher = new CaseMatcher();
|
||||
var patterns = new[]
|
||||
{
|
||||
new CasePattern
|
||||
{
|
||||
PatternId = "pat-1",
|
||||
SeverityRange = new SeverityRange { Min = AdvisorySeverity.Medium, Max = AdvisorySeverity.Critical },
|
||||
EcosystemMatch = "nuget",
|
||||
DefaultAction = SuggestionAction.Mitigate,
|
||||
SuggestionTitle = "Mitigate",
|
||||
SuggestionRationale = "Matching pattern"
|
||||
}
|
||||
};
|
||||
|
||||
var results = matcher.Match(CreateCase(), patterns);
|
||||
|
||||
results.Should().HaveCount(1);
|
||||
results[0].PatternId.Should().Be("pat-1");
|
||||
results[0].Score.Should().BeGreaterThan(0.0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Match_SeverityOutsideRange_ReturnsEmpty()
|
||||
{
|
||||
var matcher = new CaseMatcher();
|
||||
var patterns = new[]
|
||||
{
|
||||
new CasePattern
|
||||
{
|
||||
PatternId = "pat-2",
|
||||
SeverityRange = new SeverityRange { Min = AdvisorySeverity.Critical, Max = AdvisorySeverity.Critical },
|
||||
DefaultAction = SuggestionAction.Escalate,
|
||||
SuggestionTitle = "Escalate",
|
||||
SuggestionRationale = "Severity mismatch"
|
||||
}
|
||||
};
|
||||
|
||||
var results = matcher.Match(CreateCase(AdvisorySeverity.Low), patterns);
|
||||
|
||||
results.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Match_MultiplePatterns_OrdersByScoreThenPatternId()
|
||||
{
|
||||
var matcher = new CaseMatcher();
|
||||
var patterns = new[]
|
||||
{
|
||||
new CasePattern
|
||||
{
|
||||
PatternId = "b-pattern",
|
||||
SeverityRange = new SeverityRange { Min = AdvisorySeverity.Medium, Max = AdvisorySeverity.Critical },
|
||||
DefaultAction = SuggestionAction.Mitigate,
|
||||
SuggestionTitle = "B",
|
||||
SuggestionRationale = "B"
|
||||
},
|
||||
new CasePattern
|
||||
{
|
||||
PatternId = "a-pattern",
|
||||
SeverityRange = new SeverityRange { Min = AdvisorySeverity.Medium, Max = AdvisorySeverity.Critical },
|
||||
DefaultAction = SuggestionAction.Mitigate,
|
||||
SuggestionTitle = "A",
|
||||
SuggestionRationale = "A"
|
||||
},
|
||||
new CasePattern
|
||||
{
|
||||
PatternId = "c-pattern",
|
||||
DefaultAction = SuggestionAction.Defer,
|
||||
SuggestionTitle = "C",
|
||||
SuggestionRationale = "C"
|
||||
}
|
||||
};
|
||||
|
||||
var results = matcher.Match(CreateCase(), patterns);
|
||||
|
||||
results.Select(r => r.PatternId).Should().Equal("a-pattern", "b-pattern", "c-pattern");
|
||||
results[0].Score.Should().Be(1.0);
|
||||
results[2].Score.Should().Be(0.5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Match_SameInputRepeated_IsDeterministic()
|
||||
{
|
||||
var matcher = new CaseMatcher();
|
||||
var patterns = new[]
|
||||
{
|
||||
new CasePattern
|
||||
{
|
||||
PatternId = "pat-det-1",
|
||||
SeverityRange = new SeverityRange { Min = AdvisorySeverity.Low, Max = AdvisorySeverity.Critical },
|
||||
DefaultAction = SuggestionAction.Accept,
|
||||
SuggestionTitle = "Det",
|
||||
SuggestionRationale = "Det"
|
||||
},
|
||||
new CasePattern
|
||||
{
|
||||
PatternId = "pat-det-2",
|
||||
DefaultAction = SuggestionAction.Defer,
|
||||
SuggestionTitle = "Det2",
|
||||
SuggestionRationale = "Det2"
|
||||
}
|
||||
};
|
||||
|
||||
var first = matcher.Match(CreateCase(), patterns);
|
||||
var second = matcher.Match(CreateCase(), patterns);
|
||||
|
||||
second.Should().Equal(first);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Match_EmptyPatterns_ReturnsEmpty()
|
||||
{
|
||||
var matcher = new CaseMatcher();
|
||||
|
||||
var results = matcher.Match(CreateCase(), Array.Empty<CasePattern>());
|
||||
|
||||
results.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Match_NullArguments_ThrowArgumentNullException()
|
||||
{
|
||||
var matcher = new CaseMatcher();
|
||||
|
||||
Action nullCase = () => matcher.Match(null!, Array.Empty<CasePattern>());
|
||||
Action nullPatterns = () => matcher.Match(CreateCase(), null!);
|
||||
|
||||
nullCase.Should().Throw<ArgumentNullException>();
|
||||
nullPatterns.Should().Throw<ArgumentNullException>();
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseConcelierTestInfra>false</UseConcelierTestInfra>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentAssertions" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
|
||||
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\StellaOps.AdvisoryLens\StellaOps.AdvisoryLens.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
|
||||
"parallelizeTestCollections": false,
|
||||
"maxParallelThreads": 1
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
using StellaOps.Orchestrator.Schemas;
|
||||
using StellaOps.JobEngine.Schemas;
|
||||
using System.Text.Json;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Orchestrator.Schemas.Tests;
|
||||
namespace StellaOps.JobEngine.Schemas.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for OrchestratorEnvelope generic record.
|
||||
/// Tests for JobEngineEnvelope generic record.
|
||||
/// </summary>
|
||||
public sealed class OrchestratorEnvelopeTests
|
||||
public sealed class JobEngineEnvelopeTests
|
||||
{
|
||||
[Fact]
|
||||
public void OrchestratorEnvelope_RequiredProperties_HaveDefaults()
|
||||
public void JobEngineEnvelope_RequiredProperties_HaveDefaults()
|
||||
{
|
||||
var envelope = new OrchestratorEnvelope<string>
|
||||
var envelope = new JobEngineEnvelope<string>
|
||||
{
|
||||
Payload = "test"
|
||||
};
|
||||
@@ -27,16 +27,16 @@ public sealed class OrchestratorEnvelopeTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OrchestratorEnvelope_WithAllProperties_ContainsValues()
|
||||
public void JobEngineEnvelope_WithAllProperties_ContainsValues()
|
||||
{
|
||||
var eventId = Guid.NewGuid();
|
||||
var occurredAt = DateTimeOffset.UtcNow;
|
||||
var recordedAt = occurredAt.AddSeconds(1);
|
||||
|
||||
var envelope = new OrchestratorEnvelope<string>
|
||||
var envelope = new JobEngineEnvelope<string>
|
||||
{
|
||||
EventId = eventId,
|
||||
Kind = OrchestratorEventKinds.ScannerReportReady,
|
||||
Kind = JobEngineEventKinds.ScannerReportReady,
|
||||
Version = 1,
|
||||
Tenant = "tenant-001",
|
||||
OccurredAt = occurredAt,
|
||||
@@ -50,7 +50,7 @@ public sealed class OrchestratorEnvelopeTests
|
||||
};
|
||||
|
||||
Assert.Equal(eventId, envelope.EventId);
|
||||
Assert.Equal(OrchestratorEventKinds.ScannerReportReady, envelope.Kind);
|
||||
Assert.Equal(JobEngineEventKinds.ScannerReportReady, envelope.Kind);
|
||||
Assert.Equal(1, envelope.Version);
|
||||
Assert.Equal("tenant-001", envelope.Tenant);
|
||||
Assert.Equal(occurredAt, envelope.OccurredAt);
|
||||
@@ -61,9 +61,9 @@ public sealed class OrchestratorEnvelopeTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OrchestratorEnvelope_WithScope_ContainsScope()
|
||||
public void JobEngineEnvelope_WithScope_ContainsScope()
|
||||
{
|
||||
var scope = new OrchestratorScope
|
||||
var scope = new JobEngineScope
|
||||
{
|
||||
Namespace = "production",
|
||||
Repo = "myapp",
|
||||
@@ -72,7 +72,7 @@ public sealed class OrchestratorEnvelopeTests
|
||||
Image = "myapp:v1.0.0"
|
||||
};
|
||||
|
||||
var envelope = new OrchestratorEnvelope<string>
|
||||
var envelope = new JobEngineEnvelope<string>
|
||||
{
|
||||
Scope = scope,
|
||||
Payload = "test"
|
||||
@@ -85,7 +85,7 @@ public sealed class OrchestratorEnvelopeTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OrchestratorEnvelope_WithAttributes_ContainsAttributes()
|
||||
public void JobEngineEnvelope_WithAttributes_ContainsAttributes()
|
||||
{
|
||||
var attributes = new Dictionary<string, string>
|
||||
{
|
||||
@@ -93,7 +93,7 @@ public sealed class OrchestratorEnvelopeTests
|
||||
["environment"] = "staging"
|
||||
};
|
||||
|
||||
var envelope = new OrchestratorEnvelope<string>
|
||||
var envelope = new JobEngineEnvelope<string>
|
||||
{
|
||||
Attributes = attributes,
|
||||
Payload = "test"
|
||||
@@ -105,9 +105,9 @@ public sealed class OrchestratorEnvelopeTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OrchestratorEnvelope_OptionalProperties_AreNullByDefault()
|
||||
public void JobEngineEnvelope_OptionalProperties_AreNullByDefault()
|
||||
{
|
||||
var envelope = new OrchestratorEnvelope<string>
|
||||
var envelope = new JobEngineEnvelope<string>
|
||||
{
|
||||
Payload = "test"
|
||||
};
|
||||
@@ -121,7 +121,7 @@ public sealed class OrchestratorEnvelopeTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OrchestratorEnvelope_GenericPayload_WorksWithComplexTypes()
|
||||
public void JobEngineEnvelope_GenericPayload_WorksWithComplexTypes()
|
||||
{
|
||||
var payload = new ScannerReportReadyPayload
|
||||
{
|
||||
@@ -129,9 +129,9 @@ public sealed class OrchestratorEnvelopeTests
|
||||
Verdict = "PASS"
|
||||
};
|
||||
|
||||
var envelope = new OrchestratorEnvelope<ScannerReportReadyPayload>
|
||||
var envelope = new JobEngineEnvelope<ScannerReportReadyPayload>
|
||||
{
|
||||
Kind = OrchestratorEventKinds.ScannerReportReady,
|
||||
Kind = JobEngineEventKinds.ScannerReportReady,
|
||||
Payload = payload
|
||||
};
|
||||
|
||||
@@ -141,14 +141,14 @@ public sealed class OrchestratorEnvelopeTests
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests for OrchestratorScope record.
|
||||
/// Tests for JobEngineScope record.
|
||||
/// </summary>
|
||||
public sealed class OrchestratorScopeTests
|
||||
public sealed class JobEngineScopeTests
|
||||
{
|
||||
[Fact]
|
||||
public void OrchestratorScope_RequiredProperties_HaveDefaults()
|
||||
public void JobEngineScope_RequiredProperties_HaveDefaults()
|
||||
{
|
||||
var scope = new OrchestratorScope();
|
||||
var scope = new JobEngineScope();
|
||||
|
||||
Assert.Null(scope.Namespace);
|
||||
Assert.Equal(string.Empty, scope.Repo);
|
||||
@@ -158,9 +158,9 @@ public sealed class OrchestratorScopeTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OrchestratorScope_WithAllProperties_ContainsValues()
|
||||
public void JobEngineScope_WithAllProperties_ContainsValues()
|
||||
{
|
||||
var scope = new OrchestratorScope
|
||||
var scope = new JobEngineScope
|
||||
{
|
||||
Namespace = "default",
|
||||
Repo = "registry.example.com/myapp",
|
||||
@@ -177,15 +177,15 @@ public sealed class OrchestratorScopeTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OrchestratorScope_RecordEquality_WorksCorrectly()
|
||||
public void JobEngineScope_RecordEquality_WorksCorrectly()
|
||||
{
|
||||
var scope1 = new OrchestratorScope
|
||||
var scope1 = new JobEngineScope
|
||||
{
|
||||
Repo = "myapp",
|
||||
Digest = "sha256:abc"
|
||||
};
|
||||
|
||||
var scope2 = new OrchestratorScope
|
||||
var scope2 = new JobEngineScope
|
||||
{
|
||||
Repo = "myapp",
|
||||
Digest = "sha256:abc"
|
||||
@@ -196,20 +196,20 @@ public sealed class OrchestratorScopeTests
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests for OrchestratorEventKinds constants.
|
||||
/// Tests for JobEngineEventKinds constants.
|
||||
/// </summary>
|
||||
public sealed class OrchestratorEventKindsTests
|
||||
public sealed class JobEngineEventKindsTests
|
||||
{
|
||||
[Fact]
|
||||
public void OrchestratorEventKinds_ScannerReportReady_HasCorrectValue()
|
||||
public void JobEngineEventKinds_ScannerReportReady_HasCorrectValue()
|
||||
{
|
||||
Assert.Equal("scanner.event.report.ready", OrchestratorEventKinds.ScannerReportReady);
|
||||
Assert.Equal("scanner.event.report.ready", JobEngineEventKinds.ScannerReportReady);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OrchestratorEventKinds_ScannerScanCompleted_HasCorrectValue()
|
||||
public void JobEngineEventKinds_ScannerScanCompleted_HasCorrectValue()
|
||||
{
|
||||
Assert.Equal("scanner.event.scan.completed", OrchestratorEventKinds.ScannerScanCompleted);
|
||||
Assert.Equal("scanner.event.scan.completed", JobEngineEventKinds.ScannerScanCompleted);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\StellaOps.Orchestrator.Schemas\StellaOps.Orchestrator.Schemas.csproj" />
|
||||
<ProjectReference Include="..\..\StellaOps.JobEngine.Schemas\StellaOps.JobEngine.Schemas.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
Reference in New Issue
Block a user