Skip to content

Commit 1be088c

Browse files
authored
Merge pull request #1473 from tgauth/update-subsystem-resource
Update subsystem resource
2 parents bdd1c12 + 884df3a commit 1be088c

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

resources/sshdconfig/src/repeat_keyword.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ pub struct NameValueEntry {
7878
pub value: Option<String>,
7979
}
8080

81+
fn default_true() -> bool { true }
82+
8183
/// Input for name-value keyword single-entry operations (e.g., subsystem).
8284
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
8385
pub struct RepeatInput {
8486
/// Whether the entry should exist (true) or be removed (false)
85-
#[serde(rename = "_exist", default)]
87+
#[serde(rename = "_exist", default = "default_true")]
8688
pub exist: bool,
8789
/// Metadata for the operation
8890
#[serde(rename = "_metadata", skip_serializing_if = "Option::is_none")]

resources/sshdconfig/tests/sshdconfigRepeat.tests.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,5 +212,23 @@ PasswordAuthentication yes
212212

213213
Remove-Item -Path $stderrFile -Force -ErrorAction SilentlyContinue
214214
}
215+
216+
It 'Should default to _exist=true when not specified explicitly' {
217+
$inputConfig = @{
218+
_metadata = @{
219+
filepath = $TestConfigPath
220+
}
221+
subsystem = @{
222+
name = "testExistDefault"
223+
value = "/path/to/subsystem"
224+
}
225+
} | ConvertTo-Json
226+
227+
$output = sshdconfig set --input $inputConfig -s sshd-config-repeat 2>$null
228+
$LASTEXITCODE | Should -Be 0
229+
# verify subsystem was added (defaulting to _exist=true)
230+
$subsystems = Get-Content $TestConfigPath | Where-Object { $_ -match '^\s*subsystem\s+' }
231+
$subsystems | Should -Contain "subsystem testExistDefault /path/to/subsystem"
232+
}
215233
}
216234
}

0 commit comments

Comments
 (0)