feat(p7-05): fill signal & log stubs — SignalHandlerTests, ServerLoggerTests
- Add RemovePassFromTrace, RemoveAuthTokenFromTrace, RemoveSecretsFromTrace static methods to ServerLogging (mirrors removeSecretsFromTrace/redact in server/client.go); uses same regex patterns as Go source to redact only the first match's value with [REDACTED]. - Update ClientConnection.RemoveSecretsFromTrace stub to delegate to ServerLogging.RemoveSecretsFromTrace. - Add 2 unit tests to SignalHandlerTests (T:2919 invalid command, T:2920 invalid PID); mark 14 process-injection/subprocess tests as deferred ([Fact(Skip=…)]). - Create ServerLoggerTests with 3 test methods (T:2020, T:2021, T:2022) covering NoPasswordsFromConnectTrace, RemovePassFromTrace (8 theory cases), RemoveAuthTokenFromTrace (8 theory cases). - DB: 3 log tests → complete, 2 signal tests → complete, 14 signal tests → deferred. - All 663 unit tests pass (was 645), 14 deferred skipped.
This commit is contained in:
@@ -67,4 +67,100 @@ public class SignalHandlerTests
|
||||
var err = SignalHandler.ProcessSignal(ServerCommand.Stop, "not-a-pid");
|
||||
err.ShouldNotBeNull();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Tests ported from server/signal_test.go
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// <summary>
|
||||
/// Mirrors TestProcessSignalInvalidCommand.
|
||||
/// An out-of-range ServerCommand enum value is treated as an unknown signal
|
||||
/// and ProcessSignal returns a non-null error.
|
||||
/// </summary>
|
||||
[Fact] // T:2919
|
||||
public void ProcessSignalInvalidCommand_ShouldSucceed()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
return; // Skip on Windows
|
||||
|
||||
var err = SignalHandler.ProcessSignal((ServerCommand)99, "123");
|
||||
err.ShouldNotBeNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mirrors TestProcessSignalInvalidPid.
|
||||
/// A non-numeric PID string returns an error containing "invalid pid".
|
||||
/// </summary>
|
||||
[Fact] // T:2920
|
||||
public void ProcessSignalInvalidPid_ShouldSucceed()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
return; // Skip on Windows
|
||||
|
||||
var err = SignalHandler.ProcessSignal(ServerCommand.Stop, "abc");
|
||||
err.ShouldNotBeNull();
|
||||
err!.Message.ShouldContain("invalid pid");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Deferred signal tests — require pgrep/kill injection or real OS process spawning.
|
||||
// These cannot be unit-tested without refactoring SignalHandler to accept
|
||||
// injectable pgrep/kill delegates (as the Go source does).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// <summary>Mirrors TestProcessSignalMultipleProcesses — deferred: requires pgrep injection.</summary>
|
||||
[Fact(Skip = "deferred: requires pgrep/kill injection")] // T:2913
|
||||
public void ProcessSignalMultipleProcesses_ShouldSucceed() { }
|
||||
|
||||
/// <summary>Mirrors TestProcessSignalMultipleProcessesGlob — deferred: requires pgrep injection.</summary>
|
||||
[Fact(Skip = "deferred: requires pgrep/kill injection")] // T:2914
|
||||
public void ProcessSignalMultipleProcessesGlob_ShouldSucceed() { }
|
||||
|
||||
/// <summary>Mirrors TestProcessSignalMultipleProcessesGlobPartial — deferred: requires pgrep injection.</summary>
|
||||
[Fact(Skip = "deferred: requires pgrep/kill injection")] // T:2915
|
||||
public void ProcessSignalMultipleProcessesGlobPartial_ShouldSucceed() { }
|
||||
|
||||
/// <summary>Mirrors TestProcessSignalPgrepError — deferred: requires pgrep injection.</summary>
|
||||
[Fact(Skip = "deferred: requires pgrep injection")] // T:2916
|
||||
public void ProcessSignalPgrepError_ShouldSucceed() { }
|
||||
|
||||
/// <summary>Mirrors TestProcessSignalPgrepMangled — deferred: requires pgrep injection.</summary>
|
||||
[Fact(Skip = "deferred: requires pgrep injection")] // T:2917
|
||||
public void ProcessSignalPgrepMangled_ShouldSucceed() { }
|
||||
|
||||
/// <summary>Mirrors TestProcessSignalResolveSingleProcess — deferred: requires pgrep and kill injection.</summary>
|
||||
[Fact(Skip = "deferred: requires pgrep/kill injection")] // T:2918
|
||||
public void ProcessSignalResolveSingleProcess_ShouldSucceed() { }
|
||||
|
||||
/// <summary>Mirrors TestProcessSignalQuitProcess — deferred: requires kill injection.</summary>
|
||||
[Fact(Skip = "deferred: requires kill injection")] // T:2921
|
||||
public void ProcessSignalQuitProcess_ShouldSucceed() { }
|
||||
|
||||
/// <summary>Mirrors TestProcessSignalTermProcess — deferred: requires kill injection and commandTerm equivalent.</summary>
|
||||
[Fact(Skip = "deferred: requires kill injection")] // T:2922
|
||||
public void ProcessSignalTermProcess_ShouldSucceed() { }
|
||||
|
||||
/// <summary>Mirrors TestProcessSignalReopenProcess — deferred: requires kill injection.</summary>
|
||||
[Fact(Skip = "deferred: requires kill injection")] // T:2923
|
||||
public void ProcessSignalReopenProcess_ShouldSucceed() { }
|
||||
|
||||
/// <summary>Mirrors TestProcessSignalReloadProcess — deferred: requires kill injection.</summary>
|
||||
[Fact(Skip = "deferred: requires kill injection")] // T:2924
|
||||
public void ProcessSignalReloadProcess_ShouldSucceed() { }
|
||||
|
||||
/// <summary>Mirrors TestProcessSignalLameDuckMode — deferred: requires kill injection and commandLDMode equivalent.</summary>
|
||||
[Fact(Skip = "deferred: requires kill injection")] // T:2925
|
||||
public void ProcessSignalLameDuckMode_ShouldSucceed() { }
|
||||
|
||||
/// <summary>Mirrors TestProcessSignalTermDuringLameDuckMode — deferred: requires full server (RunServer) and real OS signal.</summary>
|
||||
[Fact(Skip = "deferred: requires RunServer and real OS SIGTERM")] // T:2926
|
||||
public void ProcessSignalTermDuringLameDuckMode_ShouldSucceed() { }
|
||||
|
||||
/// <summary>Mirrors TestSignalInterruptHasSuccessfulExit — deferred: requires spawning a subprocess to test exit code on SIGINT.</summary>
|
||||
[Fact(Skip = "deferred: requires subprocess process spawning")] // T:2927
|
||||
public void SignalInterruptHasSuccessfulExit_ShouldSucceed() { }
|
||||
|
||||
/// <summary>Mirrors TestSignalTermHasSuccessfulExit — deferred: requires spawning a subprocess to test exit code on SIGTERM.</summary>
|
||||
[Fact(Skip = "deferred: requires subprocess process spawning")] // T:2928
|
||||
public void SignalTermHasSuccessfulExit_ShouldSucceed() { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user