Merge all changes
This commit is contained in:
@@ -32,7 +32,7 @@ public sealed class BudgetLedgerTests
|
||||
public async Task GetBudget_ReturnsExistingBudget()
|
||||
{
|
||||
var existing = CreateBudget("existing-service", consumed: 50);
|
||||
await _store.CreateAsync(existing, CancellationToken.None);
|
||||
await _store.CreateAsync(existing, TestContext.Current.CancellationToken);
|
||||
|
||||
var budget = await _ledger.GetBudgetAsync("existing-service", _currentWindow);
|
||||
|
||||
@@ -43,7 +43,7 @@ public sealed class BudgetLedgerTests
|
||||
public async Task Consume_DeductsBudget()
|
||||
{
|
||||
var initial = CreateBudget("test-service", consumed: 50);
|
||||
await _store.CreateAsync(initial, CancellationToken.None);
|
||||
await _store.CreateAsync(initial, TestContext.Current.CancellationToken);
|
||||
|
||||
var result = await _ledger.ConsumeAsync("test-service", 20, "release-1");
|
||||
|
||||
@@ -58,7 +58,7 @@ public sealed class BudgetLedgerTests
|
||||
public async Task Consume_FailsWhenInsufficientBudget()
|
||||
{
|
||||
var initial = CreateBudget("test-service", consumed: 190);
|
||||
await _store.CreateAsync(initial, CancellationToken.None);
|
||||
await _store.CreateAsync(initial, TestContext.Current.CancellationToken);
|
||||
|
||||
var result = await _ledger.ConsumeAsync("test-service", 20, "release-1");
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ public sealed class PolicyBinderTests
|
||||
Strict = true,
|
||||
};
|
||||
|
||||
var exitCode = await cli.RunAsync(options, CancellationToken.None);
|
||||
var exitCode = await cli.RunAsync(options, TestContext.Current.CancellationToken);
|
||||
|
||||
Assert.Equal(2, exitCode);
|
||||
Assert.Contains("WARNING", output.ToString());
|
||||
|
||||
@@ -35,7 +35,7 @@ rules:
|
||||
var timeProvider = new FakeTimeProvider();
|
||||
var store = new PolicySnapshotStore(snapshotRepo, auditRepo, timeProvider, null, NullLogger<PolicySnapshotStore>.Instance);
|
||||
|
||||
await store.SaveAsync(new PolicySnapshotContent(yaml, PolicyDocumentFormat.Yaml, "tester", null, null), CancellationToken.None);
|
||||
await store.SaveAsync(new PolicySnapshotContent(yaml, PolicyDocumentFormat.Yaml, "tester", null, null), TestContext.Current.CancellationToken);
|
||||
|
||||
var service = new PolicyPreviewService(store, NullLogger<PolicyPreviewService>.Instance);
|
||||
|
||||
@@ -51,11 +51,11 @@ rules:
|
||||
"sha256:abc",
|
||||
findings,
|
||||
baseline),
|
||||
CancellationToken.None);
|
||||
TestContext.Current.CancellationToken);
|
||||
|
||||
Assert.True(response.Success);
|
||||
Assert.Equal(1, response.ChangedCount);
|
||||
var diff1 = Assert.Single(response.Diffs.Where(diff => diff.Projected.FindingId == "finding-1"));
|
||||
var diff1 = Assert.Single(response.Diffs, diff => diff.Projected.FindingId == "finding-1");
|
||||
Assert.Equal(PolicyVerdictStatus.Pass, diff1.Baseline.Status);
|
||||
Assert.Equal(PolicyVerdictStatus.Blocked, diff1.Projected.Status);
|
||||
Assert.Equal("Block Critical", diff1.Projected.RuleName);
|
||||
@@ -94,7 +94,7 @@ rules:
|
||||
baseline,
|
||||
SnapshotOverride: null,
|
||||
ProposedPolicy: new PolicySnapshotContent(yaml, PolicyDocumentFormat.Yaml, "tester", null, "dev override")),
|
||||
CancellationToken.None);
|
||||
TestContext.Current.CancellationToken);
|
||||
|
||||
Assert.True(response.Success);
|
||||
var diff = Assert.Single(response.Diffs);
|
||||
@@ -122,7 +122,7 @@ rules:
|
||||
SnapshotOverride: null,
|
||||
ProposedPolicy: new PolicySnapshotContent(invalid, PolicyDocumentFormat.Yaml, null, null, null));
|
||||
|
||||
var response = await service.PreviewAsync(request, CancellationToken.None);
|
||||
var response = await service.PreviewAsync(request, TestContext.Current.CancellationToken);
|
||||
|
||||
Assert.False(response.Success);
|
||||
Assert.NotEmpty(response.Issues);
|
||||
@@ -160,7 +160,7 @@ rules:
|
||||
Assert.True(binding.Document.Rules[0].Action.Quiet);
|
||||
|
||||
var store = new PolicySnapshotStore(new InMemoryPolicySnapshotRepository(), new InMemoryPolicyAuditRepository(), TimeProvider.System, null, NullLogger<PolicySnapshotStore>.Instance);
|
||||
await store.SaveAsync(new PolicySnapshotContent(yaml, PolicyDocumentFormat.Yaml, "tester", null, "quiet test"), CancellationToken.None);
|
||||
await store.SaveAsync(new PolicySnapshotContent(yaml, PolicyDocumentFormat.Yaml, "tester", null, "quiet test"), TestContext.Current.CancellationToken);
|
||||
var snapshot = await store.GetLatestAsync();
|
||||
Assert.NotNull(snapshot);
|
||||
Assert.True(snapshot!.Document.Rules[0].Action.Quiet);
|
||||
@@ -178,7 +178,7 @@ rules:
|
||||
"sha256:quiet",
|
||||
findings,
|
||||
baseline),
|
||||
CancellationToken.None);
|
||||
TestContext.Current.CancellationToken);
|
||||
|
||||
Assert.True(response.Success);
|
||||
var verdict = Assert.Single(response.Diffs).Projected;
|
||||
|
||||
@@ -29,7 +29,7 @@ rules:
|
||||
|
||||
var content = new PolicySnapshotContent(BasePolicyYaml, PolicyDocumentFormat.Yaml, "cli", "test", null);
|
||||
|
||||
var result = await store.SaveAsync(content, CancellationToken.None);
|
||||
var result = await store.SaveAsync(content, TestContext.Current.CancellationToken);
|
||||
|
||||
Assert.True(result.Success);
|
||||
Assert.True(result.Created);
|
||||
@@ -59,11 +59,11 @@ rules:
|
||||
var store = new PolicySnapshotStore(snapshotRepo, auditRepo, timeProvider, null, NullLogger<PolicySnapshotStore>.Instance);
|
||||
|
||||
var content = new PolicySnapshotContent(BasePolicyYaml, PolicyDocumentFormat.Yaml, "cli", "test", null);
|
||||
var first = await store.SaveAsync(content, CancellationToken.None);
|
||||
var first = await store.SaveAsync(content, TestContext.Current.CancellationToken);
|
||||
Assert.True(first.Created);
|
||||
|
||||
timeProvider.Advance(TimeSpan.FromHours(1));
|
||||
var second = await store.SaveAsync(content, CancellationToken.None);
|
||||
var second = await store.SaveAsync(content, TestContext.Current.CancellationToken);
|
||||
|
||||
Assert.True(second.Success);
|
||||
Assert.False(second.Created);
|
||||
@@ -86,7 +86,7 @@ rules:
|
||||
const string invalidYaml = "version: '1.0'\nrules: []";
|
||||
var content = new PolicySnapshotContent(invalidYaml, PolicyDocumentFormat.Yaml, null, null, null);
|
||||
|
||||
var result = await store.SaveAsync(content, CancellationToken.None);
|
||||
var result = await store.SaveAsync(content, TestContext.Current.CancellationToken);
|
||||
|
||||
Assert.False(result.Success);
|
||||
Assert.False(result.Created);
|
||||
|
||||
Reference in New Issue
Block a user