warnings fixes, tests fixes, sprints completions
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using StellaOps.Auth.Abstractions;
|
||||
using StellaOps.Determinism.Abstractions;
|
||||
using StellaOps.Policy.Engine.Services;
|
||||
using StellaOps.Policy.Persistence.Postgres.Models;
|
||||
using StellaOps.Policy.Persistence.Postgres.Repositories;
|
||||
@@ -335,6 +336,8 @@ internal static class ViolationEndpoints
|
||||
HttpContext context,
|
||||
[FromBody] CreateViolationRequest request,
|
||||
IViolationEventRepository repository,
|
||||
TimeProvider timeProvider,
|
||||
IGuidProvider guidProvider,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var scopeResult = ScopeAuthorization.RequireScope(context, StellaOpsScopes.PolicyEdit);
|
||||
@@ -356,7 +359,7 @@ internal static class ViolationEndpoints
|
||||
|
||||
var entity = new ViolationEventEntity
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Id = guidProvider.NewGuid(),
|
||||
TenantId = tenantId,
|
||||
PolicyId = request.PolicyId,
|
||||
RuleId = request.RuleId,
|
||||
@@ -366,7 +369,7 @@ internal static class ViolationEndpoints
|
||||
Details = request.Details ?? "{}",
|
||||
Remediation = request.Remediation,
|
||||
CorrelationId = request.CorrelationId,
|
||||
OccurredAt = request.OccurredAt ?? DateTimeOffset.UtcNow
|
||||
OccurredAt = request.OccurredAt ?? timeProvider.GetUtcNow()
|
||||
};
|
||||
|
||||
try
|
||||
@@ -389,6 +392,8 @@ internal static class ViolationEndpoints
|
||||
HttpContext context,
|
||||
[FromBody] CreateViolationBatchRequest request,
|
||||
IViolationEventRepository repository,
|
||||
TimeProvider timeProvider,
|
||||
IGuidProvider guidProvider,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var scopeResult = ScopeAuthorization.RequireScope(context, StellaOpsScopes.PolicyEdit);
|
||||
@@ -408,9 +413,10 @@ internal static class ViolationEndpoints
|
||||
});
|
||||
}
|
||||
|
||||
var now = timeProvider.GetUtcNow();
|
||||
var entities = request.Violations.Select(v => new ViolationEventEntity
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Id = guidProvider.NewGuid(),
|
||||
TenantId = tenantId,
|
||||
PolicyId = v.PolicyId,
|
||||
RuleId = v.RuleId,
|
||||
@@ -420,7 +426,7 @@ internal static class ViolationEndpoints
|
||||
Details = v.Details ?? "{}",
|
||||
Remediation = v.Remediation,
|
||||
CorrelationId = v.CorrelationId,
|
||||
OccurredAt = v.OccurredAt ?? DateTimeOffset.UtcNow
|
||||
OccurredAt = v.OccurredAt ?? now
|
||||
}).ToList();
|
||||
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user