fix: corriger les issues mineures du review

🟡 SnapshotUrl: validation sécurité SSRF (scheme + loopback)
🟡 Integration tests: skip graceful sans PostgreSQL (TestContainers)
This commit is contained in:
Arnaud Dartois committed 2026-07-27 09:09:14 +00:00
1 parent fba29b3eb4
commit a6b2a21ebc
3 files changed
+54 -2

No files matched your search

@@ -44,6 +44,16 @@ public sealed class PostgreSqlContainerFixture : IAsyncLifetime
}
}
/// <summary>
/// Indicates whether the PostgreSQL container started successfully.
/// </summary>
public bool IsAvailable { get; private set; } = true;
/// <summary>
/// Reason the container is unavailable (for test skip messages).
/// </summary>
public string? SkipReason { get; private set; }
/// <summary>
/// Connection string for the PostgreSQL instance.
/// In CI mode returns the DATABASE_URL env var directly.
@@ -65,7 +75,23 @@ public sealed class PostgreSqlContainerFixture : IAsyncLifetime
}
if (shouldStart && Container is not null)
await Container.StartAsync();
{
try
{
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
await Container.StartAsync(cts.Token);
}
catch (Exception ex) when (ex is InvalidOperationException or TimeoutException or TaskCanceledException)
{
IsAvailable = false;
SkipReason = $"PostgreSQL TestContainers unavailable (Docker not running?): {ex.Message}";
}
catch (Exception ex)
{
IsAvailable = false;
SkipReason = $"PostgreSQL TestContainers failed: {ex.Message}";
}
}
}
public async Task DisposeAsync()
@@ -77,7 +103,7 @@ public sealed class PostgreSqlContainerFixture : IAsyncLifetime
shouldStop = _refCount == 0;
}
if (shouldStop && Container is not null)
if (shouldStop && Container is not null && IsAvailable)
await Container.DisposeAsync();
}
}