fix(scanner): Fix WebService test infrastructure failure

- Update PostgresIdempotencyKeyRepository to use ScannerDataSource instead
  of NpgsqlDataSource directly (aligns with other Postgres repositories)
- Move IIdempotencyKeyRepository registration from IdempotencyMiddlewareExtensions
  to ServiceCollectionExtensions.RegisterScannerStorageServices
- Use Dapper instead of raw NpgsqlCommand for consistency
- Fixes: System.InvalidOperationException: Unable to resolve service for type
  'Npgsql.NpgsqlDataSource' when running WebService tests

Sprint planning:
- Create SPRINT_3500_0004_0001 CLI Verbs & Offline Bundles
- Create SPRINT_3500_0004_0002 UI Components & Visualization
- Create SPRINT_3500_0004_0003 Integration Tests & Corpus
- Create SPRINT_3500_0004_0004 Documentation & Handoff

Sprint: SPRINT_3500_0002_0003
This commit is contained in:
StellaOps Bot
2025-12-20 18:40:34 +02:00
parent 3698ebf4a8
commit 3c6e14fca5
8 changed files with 1111 additions and 71 deletions

View File

@@ -8,8 +8,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using StellaOps.Scanner.Storage.Postgres;
using StellaOps.Scanner.Storage.Repositories;
using StellaOps.Scanner.WebService.Options;
namespace StellaOps.Scanner.WebService.Middleware;
@@ -21,6 +19,7 @@ public static class IdempotencyMiddlewareExtensions
{
/// <summary>
/// Adds idempotency services to the service collection.
/// Note: IIdempotencyKeyRepository is registered by AddScannerStorage.
/// </summary>
public static IServiceCollection AddIdempotency(
this IServiceCollection services,
@@ -32,8 +31,6 @@ public static class IdempotencyMiddlewareExtensions
services.Configure<IdempotencyOptions>(
configuration.GetSection(IdempotencyOptions.SectionName));
services.AddScoped<IIdempotencyKeyRepository, PostgresIdempotencyKeyRepository>();
return services;
}