From d52aef19fabb75fe33ba716b4ba1aed3027b65e0 Mon Sep 17 00:00:00 2001 From: Tess Gauthier Date: Thu, 9 Apr 2026 11:27:09 -0400 Subject: [PATCH 1/2] add test --- .../tests/sshdconfigRepeat.tests.ps1 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/resources/sshdconfig/tests/sshdconfigRepeat.tests.ps1 b/resources/sshdconfig/tests/sshdconfigRepeat.tests.ps1 index ac39caf23..8a2a34d7b 100644 --- a/resources/sshdconfig/tests/sshdconfigRepeat.tests.ps1 +++ b/resources/sshdconfig/tests/sshdconfigRepeat.tests.ps1 @@ -212,5 +212,23 @@ PasswordAuthentication yes Remove-Item -Path $stderrFile -Force -ErrorAction SilentlyContinue } + + It 'Should default to _exist=true when not specified explicitly' { + $inputConfig = @{ + _metadata = @{ + filepath = $TestConfigPath + } + subsystem = @{ + name = "testExistDefault" + value = "/path/to/subsystem" + } + } | ConvertTo-Json + + $output = sshdconfig set --input $inputConfig -s sshd-config-repeat 2>$null + $LASTEXITCODE | Should -Be 0 + # verify subsystem was added (defaulting to _exist=true) + $subsystems = Get-Content $TestConfigPath | Where-Object { $_ -match '^\s*subsystem\s+' } + $subsystems | Should -Contain "subsystem testExistDefault /path/to/subsystem" + } } } From 884df3ab4a65113462c67092d4e4dbd368805d14 Mon Sep 17 00:00:00 2001 From: Tess Gauthier Date: Thu, 9 Apr 2026 11:52:30 -0400 Subject: [PATCH 2/2] default _exist to true --- resources/sshdconfig/src/repeat_keyword.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/sshdconfig/src/repeat_keyword.rs b/resources/sshdconfig/src/repeat_keyword.rs index edf8d4cc5..e27f51c9e 100644 --- a/resources/sshdconfig/src/repeat_keyword.rs +++ b/resources/sshdconfig/src/repeat_keyword.rs @@ -78,11 +78,13 @@ pub struct NameValueEntry { pub value: Option, } +fn default_true() -> bool { true } + /// Input for name-value keyword single-entry operations (e.g., subsystem). #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] pub struct RepeatInput { /// Whether the entry should exist (true) or be removed (false) - #[serde(rename = "_exist", default)] + #[serde(rename = "_exist", default = "default_true")] pub exist: bool, /// Metadata for the operation #[serde(rename = "_metadata", skip_serializing_if = "Option::is_none")]