tests fixes
This commit is contained in:
@@ -73,6 +73,7 @@ public abstract class PostgresIntegrationFixture : IAsyncLifetime
|
||||
{
|
||||
_container = new PostgreSqlBuilder()
|
||||
.WithImage(PostgresImage)
|
||||
.WithCommand("-c", "max_connections=200")
|
||||
.Build();
|
||||
|
||||
await _container.StartAsync();
|
||||
|
||||
@@ -24,8 +24,7 @@ public class ControlPlaneOutageTests : IClassFixture<ControlPlaneClusterFixture>
|
||||
public ControlPlaneOutageTests(ControlPlaneClusterFixture fixture)
|
||||
{
|
||||
_fixture = fixture;
|
||||
_fixture.FailureInjector.RecoverAll();
|
||||
_fixture.ClearEventLog();
|
||||
_fixture.ResetAll();
|
||||
}
|
||||
|
||||
#region Authority Outage Tests
|
||||
|
||||
@@ -365,6 +365,42 @@ public sealed class ControlPlaneClusterFixture : IAsyncLifetime
|
||||
while (_eventLog.TryDequeue(out _)) { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the pending jobs queue.
|
||||
/// </summary>
|
||||
public void ClearPendingJobs()
|
||||
{
|
||||
while (_pendingJobs.TryDequeue(out _)) { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the token cache.
|
||||
/// </summary>
|
||||
public void ClearTokenCache()
|
||||
{
|
||||
_tokenCache.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the data store.
|
||||
/// </summary>
|
||||
public void ClearDataStore()
|
||||
{
|
||||
_dataStore.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets all state for test isolation.
|
||||
/// </summary>
|
||||
public void ResetAll()
|
||||
{
|
||||
ClearEventLog();
|
||||
ClearPendingJobs();
|
||||
ClearTokenCache();
|
||||
ClearDataStore();
|
||||
_failureInjector.RecoverAll();
|
||||
}
|
||||
|
||||
private void LogEvent(string service, string eventType, string details)
|
||||
{
|
||||
var seq = Interlocked.Increment(ref _eventSequence);
|
||||
|
||||
@@ -25,8 +25,7 @@ public class PartialOutageTests : IClassFixture<ControlPlaneClusterFixture>
|
||||
public PartialOutageTests(ControlPlaneClusterFixture fixture)
|
||||
{
|
||||
_fixture = fixture;
|
||||
_fixture.FailureInjector.RecoverAll();
|
||||
_fixture.ClearEventLog();
|
||||
_fixture.ResetAll();
|
||||
}
|
||||
|
||||
#region Partial Failure Rate Tests
|
||||
|
||||
@@ -165,7 +165,9 @@ public sealed class CryptographicFailuresTests : SecurityTestBase
|
||||
{
|
||||
var patterns = new[]
|
||||
{
|
||||
@"-----BEGIN[\s\S]*?-----END[A-Z\s]+-----",
|
||||
@"-----BEGIN[\s\S]*?-----END[A-Z\s]+-----", // Full PEM blocks
|
||||
@"-----BEGIN[A-Z\s]*PRIVATE\s*KEY-----", // PEM headers
|
||||
@"PRIVATE\s+KEY", // "PRIVATE KEY" with space
|
||||
@"private[_\-]?key[^\s]*",
|
||||
@"PRIVATE[_\-]?KEY[^\s]*"
|
||||
};
|
||||
|
||||
@@ -196,15 +196,17 @@ public sealed class AuthenticationFailuresTests : SecurityTestBase
|
||||
private static async Task<AuthResult> SimulateAuthAttempt(string username, string password)
|
||||
{
|
||||
await Task.Delay(1); // Simulate async operation
|
||||
|
||||
|
||||
// Always increment attempt count for lockout tracking
|
||||
IncrementAttemptCount(username);
|
||||
|
||||
// Simulate rate limiting after 5 attempts
|
||||
var attempts = GetAttemptCount(username);
|
||||
if (attempts >= 5)
|
||||
{
|
||||
return new AuthResult(false, true, "Authentication failed");
|
||||
}
|
||||
|
||||
IncrementAttemptCount(username);
|
||||
|
||||
return new AuthResult(false, false, "Authentication failed");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user