stabilize tests
This commit is contained in:
@@ -2,10 +2,11 @@
|
||||
// Sprint: SPRINT_20260109_009_003_BE_cve_symbol_mapping
|
||||
// Task: Implement API endpoints
|
||||
|
||||
using System.Collections.Immutable;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
using StellaOps.Reachability.Core.CveMapping;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace StellaOps.ReachGraph.WebService.Controllers;
|
||||
|
||||
|
||||
@@ -62,9 +62,14 @@ public class ReachGraphController : ControllerBase
|
||||
StoredAt = result.StoredAt
|
||||
};
|
||||
|
||||
return result.Created
|
||||
? CreatedAtAction(nameof(GetByDigestAsync), new { digest = result.Digest }, response)
|
||||
: Ok(response);
|
||||
if (result.Created)
|
||||
{
|
||||
var location = Url.Action(nameof(GetByDigestAsync), null, new { digest = result.Digest })
|
||||
?? $"/v1/reachgraphs/{Uri.EscapeDataString(result.Digest)}";
|
||||
return Created(location, response);
|
||||
}
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
// Licensed to StellaOps under the BUSL-1.1 license.
|
||||
|
||||
using System.Threading.RateLimiting;
|
||||
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
using Npgsql;
|
||||
using StackExchange.Redis;
|
||||
using StellaOps.ReachGraph.Cache;
|
||||
using StellaOps.ReachGraph.Hashing;
|
||||
using StellaOps.ReachGraph.Persistence;
|
||||
using StellaOps.ReachGraph.Serialization;
|
||||
using StellaOps.ReachGraph.WebService.Services;
|
||||
using StackExchange.Redis;
|
||||
using System.Threading.RateLimiting;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -25,18 +26,22 @@ builder.Services.AddSwaggerGen(options =>
|
||||
});
|
||||
});
|
||||
|
||||
// PostgreSQL
|
||||
var connectionString = builder.Configuration.GetConnectionString("PostgreSQL")
|
||||
?? throw new InvalidOperationException("PostgreSQL connection string not configured");
|
||||
var dataSourceBuilder = new NpgsqlDataSourceBuilder(connectionString);
|
||||
var dataSource = dataSourceBuilder.Build();
|
||||
builder.Services.AddSingleton(dataSource);
|
||||
// PostgreSQL (lazy so integration tests can replace before first resolve)
|
||||
builder.Services.AddSingleton<NpgsqlDataSource>(sp =>
|
||||
{
|
||||
var config = sp.GetRequiredService<IConfiguration>();
|
||||
var connStr = config.GetConnectionString("PostgreSQL")
|
||||
?? throw new InvalidOperationException("PostgreSQL connection string not configured");
|
||||
return new NpgsqlDataSourceBuilder(connStr).Build();
|
||||
});
|
||||
|
||||
// Redis/Valkey
|
||||
var redisConnectionString = builder.Configuration.GetConnectionString("Redis")
|
||||
?? "localhost:6379";
|
||||
var redis = ConnectionMultiplexer.Connect(redisConnectionString);
|
||||
builder.Services.AddSingleton<IConnectionMultiplexer>(redis);
|
||||
// Redis/Valkey (lazy so integration tests can replace before first resolve)
|
||||
builder.Services.AddSingleton<IConnectionMultiplexer>(sp =>
|
||||
{
|
||||
var config = sp.GetRequiredService<IConfiguration>();
|
||||
var redisConnStr = config.GetConnectionString("Redis") ?? "localhost:6379";
|
||||
return ConnectionMultiplexer.Connect(redisConnStr);
|
||||
});
|
||||
|
||||
// Core services
|
||||
builder.Services.AddSingleton<CanonicalReachGraphSerializer>();
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Licensed to StellaOps under the BUSL-1.1 license.
|
||||
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
using StellaOps.ReachGraph.Schema;
|
||||
using StellaOps.ReachGraph.WebService.Models;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace StellaOps.ReachGraph.WebService.Services;
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Licensed to StellaOps under the BUSL-1.1 license.
|
||||
|
||||
using System.Diagnostics;
|
||||
|
||||
using StellaOps.ReachGraph.Hashing;
|
||||
using StellaOps.ReachGraph.Persistence;
|
||||
using StellaOps.ReachGraph.WebService.Models;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace StellaOps.ReachGraph.WebService.Services;
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// Licensed to StellaOps under the BUSL-1.1 license.
|
||||
|
||||
|
||||
using StellaOps.ReachGraph.Cache;
|
||||
using StellaOps.ReachGraph.Schema;
|
||||
using StellaOps.ReachGraph.WebService.Models;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using StellaOps.ReachGraph.Cache;
|
||||
using StellaOps.ReachGraph.Schema;
|
||||
using StellaOps.ReachGraph.WebService.Models;
|
||||
|
||||
namespace StellaOps.ReachGraph.WebService.Services;
|
||||
|
||||
|
||||
8
src/ReachGraph/StellaOps.ReachGraph.WebService/TASKS.md
Normal file
8
src/ReachGraph/StellaOps.ReachGraph.WebService/TASKS.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# StellaOps.ReachGraph.WebService Task Board
|
||||
This board mirrors active sprint tasks for this module.
|
||||
Source of truth: `docs/implplan/SPRINT_20260130_002_Tools_csproj_remediation_solid_review.md`.
|
||||
|
||||
| Task ID | Status | Notes |
|
||||
| --- | --- | --- |
|
||||
| REMED-05 | TODO | Remediation checklist: docs/implplan/audits/csproj-standards/remediation/checklists/src/ReachGraph/StellaOps.ReachGraph.WebService/StellaOps.ReachGraph.WebService.md. |
|
||||
| REMED-06 | DONE | SOLID review notes captured for SPRINT_20260130_002. |
|
||||
@@ -6,8 +6,10 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using StellaOps.ReachGraph.Cache;
|
||||
using StellaOps.ReachGraph.Hashing;
|
||||
using StellaOps.ReachGraph.Persistence;
|
||||
using StellaOps.ReachGraph.Schema;
|
||||
using StellaOps.ReachGraph.Serialization;
|
||||
using StackExchange.Redis;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
@@ -60,11 +62,12 @@ internal sealed class InMemoryReachGraphRepository : IReachGraphRepository
|
||||
private readonly ConcurrentDictionary<string, List<string>> _byArtifact = new();
|
||||
private readonly ConcurrentDictionary<string, List<string>> _byCve = new();
|
||||
private readonly List<ReplayLogEntry> _replayLog = new();
|
||||
private readonly ReachGraphDigestComputer _digestComputer = new(new CanonicalReachGraphSerializer());
|
||||
|
||||
public Task<StoreResult> StoreAsync(ReachGraphMinimal graph, string tenantId, CancellationToken ct)
|
||||
{
|
||||
ct.ThrowIfCancellationRequested();
|
||||
var digest = $"blake3:{Guid.NewGuid():N}";
|
||||
var digest = _digestComputer.ComputeDigest(graph);
|
||||
var key = MakeKey(tenantId, digest);
|
||||
var isNew = _graphs.TryAdd(key, (graph, DateTimeOffset.UtcNow));
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# StellaOps.ReachGraph.WebService.Tests Task Board
|
||||
This board mirrors active sprint tasks for this module.
|
||||
Source of truth: `docs/implplan/SPRINT_20260130_002_Tools_csproj_remediation_solid_review.md`.
|
||||
|
||||
| Task ID | Status | Notes |
|
||||
| --- | --- | --- |
|
||||
| REMED-05 | TODO | Remediation checklist: docs/implplan/audits/csproj-standards/remediation/checklists/src/ReachGraph/__Tests/StellaOps.ReachGraph.WebService.Tests/StellaOps.ReachGraph.WebService.Tests.md. |
|
||||
| REMED-06 | DONE | SOLID review notes captured for SPRINT_20260130_002. |
|
||||
Reference in New Issue
Block a user