From a7ec2898d61f4e0e83b73af8b99a4b8fba4f2087 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Jun 2026 15:30:51 +0000 Subject: [PATCH 1/8] Initial plan From 8d579f6316d665ee7ecf0d8efccd263c7b477350 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Jun 2026 15:38:52 +0000 Subject: [PATCH 2/8] Move filepath from _metadata to _filepath property in sshdconfig resource --- .../sshdconfig/src/canonical_properties.rs | 10 ++-- resources/sshdconfig/src/get.rs | 6 +-- resources/sshdconfig/src/inputs.rs | 25 ++------- resources/sshdconfig/src/repeat_keyword.rs | 14 ++--- resources/sshdconfig/src/set.rs | 6 +-- resources/sshdconfig/src/util.rs | 18 +++---- .../sshd-subsystem.dsc.resource.json | 11 ++-- .../sshd-subsystemList.dsc.resource.json | 11 ++-- .../sshdconfig/sshd_config.dsc.resource.json | 7 ++- .../sshdconfig/tests/sshdconfig.get.tests.ps1 | 16 ++---- .../sshdconfig/tests/sshdconfig.set.tests.ps1 | 52 +++++-------------- .../tests/sshdconfigRepeat.tests.ps1 | 28 +++------- .../tests/sshdconfigRepeatList.tests.ps1 | 44 ++++------------ 13 files changed, 78 insertions(+), 170 deletions(-) diff --git a/resources/sshdconfig/src/canonical_properties.rs b/resources/sshdconfig/src/canonical_properties.rs index 6c7dc90e9..dd48cea6e 100644 --- a/resources/sshdconfig/src/canonical_properties.rs +++ b/resources/sshdconfig/src/canonical_properties.rs @@ -13,12 +13,12 @@ use crate::error::SshdConfigError; pub enum CanonicalProperty { /// Boolean flag indicating if an entry should exist or be removed Exist, + /// Path to the sshd_config file to be processed + Filepath, /// Boolean flag to include default values in output IncludeDefaults, /// Contains SSH default values inherited from system InheritedDefaults, - /// Metadata object containing filepath and other configuration info - Metadata, /// Boolean flag indicating if non-specified entries should be removed Purge, } @@ -28,9 +28,9 @@ impl CanonicalProperty { pub const fn as_str(self) -> &'static str { match self { Self::Exist => "_exist", + Self::Filepath => "_filepath", Self::IncludeDefaults => "_includeDefaults", Self::InheritedDefaults => "_inheritedDefaults", - Self::Metadata => "_metadata", Self::Purge => "_purge", } } @@ -39,9 +39,9 @@ impl CanonicalProperty { pub fn from_str(s: &str) -> Option { match s { "_exist" => Some(Self::Exist), + "_filepath" => Some(Self::Filepath), "_includeDefaults" => Some(Self::IncludeDefaults), "_inheritedDefaults" => Some(Self::InheritedDefaults), - "_metadata" => Some(Self::Metadata), "_purge" => Some(Self::Purge), _ => None, } @@ -51,9 +51,9 @@ impl CanonicalProperty { pub const fn all() -> &'static [CanonicalProperty] { &[ Self::Exist, + Self::Filepath, Self::IncludeDefaults, Self::InheritedDefaults, - Self::Metadata, Self::Purge, ] } diff --git a/resources/sshdconfig/src/get.rs b/resources/sshdconfig/src/get.rs index a162b57e2..839ed0f92 100644 --- a/resources/sshdconfig/src/get.rs +++ b/resources/sshdconfig/src/get.rs @@ -118,7 +118,7 @@ pub fn get_sshd_settings(cmd_info: &CommandInfo, is_get: bool) -> Result = Vec::new(); // parse settings from sshd_config file - let sshd_config_file = read_sshd_config(cmd_info.metadata.filepath.clone())?; + let sshd_config_file = read_sshd_config(cmd_info.filepath.clone())?; let explicit_settings = parse_text_to_map(&sshd_config_file)?; // handle special cases for keywords @@ -163,8 +163,8 @@ pub fn get_sshd_settings(cmd_info: &CommandInfo, is_get: bool) -> Result, - /// metadata provided with the command - pub metadata: Metadata, + /// Filepath for the `sshd_config` file to be processed + pub filepath: Option, #[serde(rename = "_purge")] pub purge: bool, /// additional arguments for the call to sshd -T @@ -26,7 +25,7 @@ impl CommandInfo { pub fn new( include_defaults: bool, input: Map, - metadata: Metadata, + filepath: Option, purge: bool, sshd_args: Option ) -> Self { @@ -38,29 +37,13 @@ impl CommandInfo { Self { include_defaults, input, - metadata, + filepath, purge, sshd_args } } } -#[derive(Debug, Default, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)] -pub struct Metadata { - /// Filepath for the `sshd_config` file to be processed - #[serde(skip_serializing_if = "Option::is_none")] - pub filepath: Option -} - -impl Metadata { - /// Create a new `Metadata` instance. - pub fn new() -> Self { - Self { - filepath: None - } - } -} - #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct SshdCommandArgs { /// the path to the `sshd_config` file to be processed diff --git a/resources/sshdconfig/src/repeat_keyword.rs b/resources/sshdconfig/src/repeat_keyword.rs index edf8d4cc5..cb5f2802e 100644 --- a/resources/sshdconfig/src/repeat_keyword.rs +++ b/resources/sshdconfig/src/repeat_keyword.rs @@ -5,9 +5,9 @@ use rust_i18n::t; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; +use std::path::PathBuf; use crate::error::SshdConfigError; -use crate::inputs::Metadata; // the multi-arg comma-separated and space-separated lists are mutually exclusive, but the repeatable list can overlap with either of them. // the multi-arg lists are maintained for formatting arrays into the correct format when writing back to the config file. @@ -84,9 +84,9 @@ pub struct RepeatInput { /// Whether the entry should exist (true) or be removed (false) #[serde(rename = "_exist", default)] pub exist: bool, - /// Metadata for the operation - #[serde(rename = "_metadata", skip_serializing_if = "Option::is_none")] - pub metadata: Option, + /// Path to the sshd_config file to be processed + #[serde(rename = "_filepath", skip_serializing_if = "Option::is_none")] + pub filepath: Option, /// The keyword and its entry (e.g., "subsystem": {"name": "sftp", "value": "/usr/bin/sftp"}) #[serde(flatten)] pub additional_properties: Map, @@ -98,9 +98,9 @@ pub struct RepeatListInput { /// Whether to remove entries not in the input list #[serde(rename = "_purge", default)] pub purge: bool, - /// Metadata for the operation - #[serde(rename = "_metadata", skip_serializing_if = "Option::is_none")] - pub metadata: Option, + /// Path to the sshd_config file to be processed + #[serde(rename = "_filepath", skip_serializing_if = "Option::is_none")] + pub filepath: Option, /// The keyword and its array of entries (e.g., "subsystem": [{"name": "sftp", "value": "..."}]) #[serde(flatten)] pub additional_properties: Map, diff --git a/resources/sshdconfig/src/set.rs b/resources/sshdconfig/src/set.rs index 14c7564ad..551ed66d3 100644 --- a/resources/sshdconfig/src/set.rs +++ b/resources/sshdconfig/src/set.rs @@ -89,7 +89,7 @@ fn set_sshd_config_repeat(input: &str, cmd_info: &CommandInfo) -> Result Result Result<(), SshdConfigError> { existing_config }; - write_and_validate_config(&mut config_to_write, cmd_info.metadata.filepath.as_ref()) + write_and_validate_config(&mut config_to_write, cmd_info.filepath.as_ref()) } /// Write configuration to file after validation. diff --git a/resources/sshdconfig/src/util.rs b/resources/sshdconfig/src/util.rs index 4031e190b..12d6604fd 100644 --- a/resources/sshdconfig/src/util.rs +++ b/resources/sshdconfig/src/util.rs @@ -10,7 +10,7 @@ use tracing_subscriber::{EnvFilter, Layer, prelude::__tracing_subscriber_Subscri use crate::args::{TraceFormat, TraceLevel}; use crate::canonical_properties::{CanonicalProperty, CanonicalProperties}; use crate::error::SshdConfigError; -use crate::inputs::{CommandInfo, Metadata, SshdCommandArgs}; +use crate::inputs::{CommandInfo, SshdCommandArgs}; use crate::metadata::{SSHD_CONFIG_DEFAULT_PATH_UNIX, SSHD_CONFIG_DEFAULT_PATH_WINDOWS}; use crate::parser::parse_text_to_map; @@ -183,14 +183,14 @@ pub fn extract_sshd_defaults() -> Result, SshdConfigError> { Ok(sshd_config) } -/// Extract _metadata field from the input string, if it can be parsed as JSON. +/// Extract _filepath field from the input string, if it can be parsed as JSON. /// /// # Errors /// -/// This function will return an error if it fails to parse the input string and if the _metadata field exists, extract it. +/// This function will return an error if it fails to parse the input string and if the _filepath field exists, extract it. pub fn build_command_info(input: Option<&String>, is_get: bool) -> Result { let mut include_defaults = is_get; - let mut metadata: Metadata = Metadata::new(); + let mut filepath: Option = None; let mut purge = false; let mut sshd_args: Option = None; let mut sshd_config: Map = Map::new(); @@ -199,14 +199,14 @@ pub fn build_command_info(input: Option<&String>, is_get: bool) -> Result, is_get: bool) -> Result$null | ConvertFrom-Json $result.Port | Should -Be "5555" @@ -132,9 +124,7 @@ Describe 'sshd_config Set Tests' -Skip:($skipTest) { It 'Should not create backup when file is already managed by DSC' { # Create a DSC-managed file $initialConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _purge = $true Port = "6789" } | ConvertTo-Json @@ -143,9 +133,7 @@ Describe 'sshd_config Set Tests' -Skip:($skipTest) { # Update the file $newConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _purge = $true Port = "7777" } | ConvertTo-Json @@ -158,9 +146,7 @@ Describe 'sshd_config Set Tests' -Skip:($skipTest) { # Verify content using get $getInput = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath } | ConvertTo-Json $result = sshdconfig get --input $getInput -s sshd-config 2>$null | ConvertFrom-Json $result.Port | Should -Be "7777" @@ -171,9 +157,7 @@ Describe 'sshd_config Set Tests' -Skip:($skipTest) { BeforeEach { # Create initial file with valid config $validConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _purge = $true Port = "9999" } | ConvertTo-Json @@ -184,9 +168,7 @@ Describe 'sshd_config Set Tests' -Skip:($skipTest) { $nonExistentPath = Join-Path $TestDrive "nonexistent_sshd_config" $inputConfig = @{ - _metadata = @{ - filepath = $nonExistentPath - } + _filepath = $nonExistentPath _purge = $false Port = "8888" } | ConvertTo-Json @@ -204,17 +186,13 @@ Describe 'sshd_config Set Tests' -Skip:($skipTest) { It 'Should fail with invalid keyword and not modify file' { # Get original content $getInput = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath } | ConvertTo-Json $originalResult = sshdconfig get --input $getInput -s sshd-config 2>$null | ConvertFrom-Json # Try to set with invalid keyword $invalidConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _purge = $true FakeKeyword = "1234" } | ConvertTo-Json @@ -314,9 +292,7 @@ Match Group administrators param($Title, $InputConfig, $ExpectedContains, $ExpectedNotContains, $VerifyOrder) $config = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _purge = $false } foreach ($key in $InputConfig.Keys) { @@ -360,9 +336,7 @@ Match Group administrators It 'Should overwrite all instances of a repeatable keyword' { $inputConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _purge = $false Port = @(8888, 9999) } | ConvertTo-Json diff --git a/resources/sshdconfig/tests/sshdconfigRepeat.tests.ps1 b/resources/sshdconfig/tests/sshdconfigRepeat.tests.ps1 index ac39caf23..ed1550f09 100644 --- a/resources/sshdconfig/tests/sshdconfigRepeat.tests.ps1 +++ b/resources/sshdconfig/tests/sshdconfigRepeat.tests.ps1 @@ -59,9 +59,7 @@ PasswordAuthentication yes It 'Should add a new subsystem that does not already exist' { $inputConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _exist = $true subsystem = @{ name = "newsubsystem" @@ -83,9 +81,7 @@ PasswordAuthentication yes It 'Should treat subsystem names as case-sensitive (SFTP is different from sftp)' { $inputConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _exist = $true subsystem = @{ name = "SFTP" # Uppercase - should be treated as different from lowercase sftp @@ -98,9 +94,7 @@ PasswordAuthentication yes # Verify SFTP was added as a new entry (not updating existing sftp) using get $getInput = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath } | ConvertTo-Json $result = sshdconfig get --input $getInput -s sshd-config 2>$null | ConvertFrom-Json $LASTEXITCODE | Should -Be 0 @@ -123,9 +117,7 @@ PasswordAuthentication yes It 'Should remove a subsystem when _exist is false' { $inputConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _exist = $false subsystem = @{ name = "sftp" @@ -145,9 +137,7 @@ PasswordAuthentication yes It 'Should preserve case when adding subsystem with mixed case name' { $inputConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _exist = $true subsystem = @{ name = "MyCustomSubsystem" @@ -165,9 +155,7 @@ PasswordAuthentication yes It 'Should handle paths with spaces correctly' { $inputConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _exist = $true subsystem = @{ name = "spacepath" @@ -187,9 +175,7 @@ PasswordAuthentication yes It 'Should fail when subsystem name is missing' { $inputConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _exist = $true subsystem = @{ value = "/path/to/something" diff --git a/resources/sshdconfig/tests/sshdconfigRepeatList.tests.ps1 b/resources/sshdconfig/tests/sshdconfigRepeatList.tests.ps1 index 1869ea60d..f59b7b74f 100644 --- a/resources/sshdconfig/tests/sshdconfigRepeatList.tests.ps1 +++ b/resources/sshdconfig/tests/sshdconfigRepeatList.tests.ps1 @@ -59,9 +59,7 @@ PasswordAuthentication yes It 'Should add multiple new subsystems' { $inputConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _purge = $false subsystem = @( @{ @@ -80,9 +78,7 @@ PasswordAuthentication yes # Verify all subsystems are present (old + new) using get $getInput = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath } | ConvertTo-Json $result = sshdconfig get --input $getInput -s sshd-config 2>$null | ConvertFrom-Json $LASTEXITCODE | Should -Be 0 @@ -105,9 +101,7 @@ PasswordAuthentication yes It 'Should update existing subsystems and add new ones' { $inputConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _purge = $false subsystem = @( @{ @@ -143,9 +137,7 @@ PasswordAuthentication yes It 'Should preserve unlisted subsystems when _purge is false' { $inputConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _purge = $false subsystem = @( @{ @@ -160,9 +152,7 @@ PasswordAuthentication yes # Verify all existing subsystems are still present plus the new one using get $getInput = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath } | ConvertTo-Json $result = sshdconfig get --input $getInput -s sshd-config 2>$null | ConvertFrom-Json $LASTEXITCODE | Should -Be 0 @@ -181,9 +171,7 @@ PasswordAuthentication yes It 'Should remove unlisted subsystems when _purge is true' { $inputConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _purge = $true subsystem = @( @{ @@ -202,9 +190,7 @@ PasswordAuthentication yes # Verify only specified subsystems remain using get $getInput = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath } | ConvertTo-Json $result = sshdconfig get --input $getInput -s sshd-config 2>$null | ConvertFrom-Json $LASTEXITCODE | Should -Be 0 @@ -227,9 +213,7 @@ PasswordAuthentication yes It 'Should preserve case in subsystem names' { $inputConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _purge = $false subsystem = @( @{ @@ -254,9 +238,7 @@ PasswordAuthentication yes It 'Should handle paths with spaces in list' { $inputConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _purge = $false subsystem = @( @{ @@ -286,9 +268,7 @@ PasswordAuthentication yes It 'Should fail with missing required name property' { $inputConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _purge = $false subsystem = @( @{ @@ -306,9 +286,7 @@ PasswordAuthentication yes It 'Should handle empty subsystem array when _purge is true' { $inputConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath _purge = $true subsystem = @() } | ConvertTo-Json -Depth 10 From b369cc6224917818ceb09451dfc6289d061b48fe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Jun 2026 16:13:53 +0000 Subject: [PATCH 3/8] Fix compile errors: replace metadata.filepath with filepath in set.rs --- Cargo.lock | 9 --------- resources/sshdconfig/src/set.rs | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index da9d04550..96aeab039 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4239,15 +4239,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_feature" -version = "0.1.0" -dependencies = [ - "rust-i18n", - "serde", - "serde_json", -] - [[package]] name = "windows_firewall" version = "0.1.0" diff --git a/resources/sshdconfig/src/set.rs b/resources/sshdconfig/src/set.rs index f31905f50..23ea87653 100644 --- a/resources/sshdconfig/src/set.rs +++ b/resources/sshdconfig/src/set.rs @@ -189,7 +189,7 @@ fn set_sshd_config(cmd_info: &mut CommandInfo) -> Result<(), SshdConfigError> { let mut get_cmd_info = cmd_info.clone(); get_cmd_info.include_defaults = false; get_cmd_info.input = Map::new(); - ensure_sshd_config_exists(get_cmd_info.metadata.filepath.clone())?; + ensure_sshd_config_exists(get_cmd_info.filepath.clone())?; let mut existing_config = get_sshd_settings(&get_cmd_info, true)?; for (key, value) in &cmd_info.input { @@ -274,6 +274,6 @@ fn get_existing_config(cmd_info: &CommandInfo) -> Result, Ssh let mut get_cmd_info = cmd_info.clone(); get_cmd_info.include_defaults = false; get_cmd_info.input = Map::new(); - ensure_sshd_config_exists(get_cmd_info.metadata.filepath.clone())?; + ensure_sshd_config_exists(get_cmd_info.filepath.clone())?; get_sshd_settings(&get_cmd_info, false) } From 65a583784b759e9a00b6e4c6886859f2268b7ad8 Mon Sep 17 00:00:00 2001 From: Tess Gauthier Date: Tue, 16 Jun 2026 13:51:43 -0400 Subject: [PATCH 4/8] remove cargo.lock changes --- Cargo.lock | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 96aeab039..1f2f37d97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -914,7 +914,7 @@ dependencies = [ [[package]] name = "dsc-resource-registry" -version = "1.0.0" +version = "1.1.0" dependencies = [ "clap", "crossterm", @@ -4239,6 +4239,15 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_feature" +version = "0.1.0" +dependencies = [ + "rust-i18n", + "serde", + "serde_json", +] + [[package]] name = "windows_firewall" version = "0.1.0" From c2f98101b9f37d5f06c843b5307c2f0797f84d60 Mon Sep 17 00:00:00 2001 From: Tess Gauthier Date: Tue, 16 Jun 2026 14:00:23 -0400 Subject: [PATCH 5/8] bump resource version --- resources/sshdconfig/sshd-subsystem.dsc.resource.json | 2 +- resources/sshdconfig/sshd-subsystemList.dsc.resource.json | 2 +- resources/sshdconfig/sshd-windows.dsc.resource.json | 2 +- resources/sshdconfig/sshd_config.dsc.resource.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/sshdconfig/sshd-subsystem.dsc.resource.json b/resources/sshdconfig/sshd-subsystem.dsc.resource.json index 9b67be3a8..6f0472a41 100644 --- a/resources/sshdconfig/sshd-subsystem.dsc.resource.json +++ b/resources/sshdconfig/sshd-subsystem.dsc.resource.json @@ -2,7 +2,7 @@ "$schema": "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json", "type": "Microsoft.OpenSSH.SSHD/Subsystem", "description": "Manage SSH Server Subsystem keyword (single entry)", - "version": "0.1.0", + "version": "1.1.0", "condition": "[not(equals(tryWhich('sshd'), null()))]", "get": { "executable": "sshdconfig", diff --git a/resources/sshdconfig/sshd-subsystemList.dsc.resource.json b/resources/sshdconfig/sshd-subsystemList.dsc.resource.json index 3a6348f29..558258e43 100644 --- a/resources/sshdconfig/sshd-subsystemList.dsc.resource.json +++ b/resources/sshdconfig/sshd-subsystemList.dsc.resource.json @@ -2,7 +2,7 @@ "$schema": "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json", "type": "Microsoft.OpenSSH.SSHD/SubsystemList", "description": "Manage SSH Server Subsystem keyword (accepts multiple entries)", - "version": "0.1.0", + "version": "1.1.0", "condition": "[not(equals(tryWhich('sshd'), null()))]", "get": { "executable": "sshdconfig", diff --git a/resources/sshdconfig/sshd-windows.dsc.resource.json b/resources/sshdconfig/sshd-windows.dsc.resource.json index 814b9d1df..a90a912c5 100644 --- a/resources/sshdconfig/sshd-windows.dsc.resource.json +++ b/resources/sshdconfig/sshd-windows.dsc.resource.json @@ -6,7 +6,7 @@ "Windows" ], "condition": "[not(equals(tryWhich('sshd'), null()))]", - "version": "0.1.0", + "version": "1.1.0", "get": { "executable": "sshdconfig", "args": [ diff --git a/resources/sshdconfig/sshd_config.dsc.resource.json b/resources/sshdconfig/sshd_config.dsc.resource.json index 2e8febe7c..60687f727 100644 --- a/resources/sshdconfig/sshd_config.dsc.resource.json +++ b/resources/sshdconfig/sshd_config.dsc.resource.json @@ -3,7 +3,7 @@ "type": "Microsoft.OpenSSH.SSHD/sshd_config", "description": "Manage SSH Server Configuration", "condition": "[not(equals(tryWhich('sshd'), null()))]", - "version": "0.1.0", + "version": "1.1.0", "get": { "executable": "sshdconfig", "args": [ From 995e0099ddd66cb101b535c434f196d315453bf0 Mon Sep 17 00:00:00 2001 From: Tess Gauthier Date: Tue, 16 Jun 2026 14:09:55 -0400 Subject: [PATCH 6/8] update remaining tests --- resources/sshdconfig/src/get.rs | 2 +- .../tests/sshdconfigRepeat.tests.ps1 | 20 +++++-------------- .../tests/sshdconfigRepeatList.tests.ps1 | 16 ++++----------- 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/resources/sshdconfig/src/get.rs b/resources/sshdconfig/src/get.rs index 839ed0f92..17e7f9603 100644 --- a/resources/sshdconfig/src/get.rs +++ b/resources/sshdconfig/src/get.rs @@ -107,7 +107,7 @@ fn get_default_shell() -> Result<(), SshdConfigError> { /// /// # Arguments /// -/// * `cmd_info` - `CommandInfo` struct containing optional filters, metadata, and includeDefaults flag. +/// * `cmd_info` - `CommandInfo` struct containing optional filters, filepath, and includeDefaults flag. /// /// # Errors /// diff --git a/resources/sshdconfig/tests/sshdconfigRepeat.tests.ps1 b/resources/sshdconfig/tests/sshdconfigRepeat.tests.ps1 index 251829133..75c0157cc 100644 --- a/resources/sshdconfig/tests/sshdconfigRepeat.tests.ps1 +++ b/resources/sshdconfig/tests/sshdconfigRepeat.tests.ps1 @@ -202,9 +202,7 @@ PasswordAuthentication yes It 'Should default to _exist=true when not specified explicitly' { $inputConfig = @{ - _metadata = @{ - filepath = $TestConfigPath - } + _filepath = $TestConfigPath subsystem = @{ name = "testExistDefault" value = "/path/to/subsystem" @@ -224,9 +222,7 @@ PasswordAuthentication yes $nonExistentPath = Join-Path $TestDrive "nonexistent_sshd_config_repeat_nonwindows" $stderrFile = Join-Path $TestDrive "stderr_nofile_repeat_nonwindows.txt" $inputConfig = @{ - _metadata = @{ - filepath = $nonExistentPath - } + _filepath = $nonExistentPath _exist = $true subsystem = @{ name = "powershell" @@ -269,9 +265,7 @@ PasswordAuthentication yes ) -Encoding ascii $inputConfig = @{ - _metadata = @{ - filepath = $script:CurrentWindowsTargetPath - } + _filepath = $script:CurrentWindowsTargetPath _exist = $true subsystem = @{ name = "powershell" @@ -291,9 +285,7 @@ PasswordAuthentication yes $LASTEXITCODE | Should -Be 0 Test-Path $script:CurrentWindowsTargetPath | Should -Be $true $getInput = @{ - _metadata = @{ - filepath = $script:CurrentWindowsTargetPath - } + _filepath = $script:CurrentWindowsTargetPath } | ConvertTo-Json $result = sshdconfig get --input $getInput -s sshd-config 2>$null | ConvertFrom-Json $result.subsystem.name | Should -Be "powershell" @@ -309,9 +301,7 @@ PasswordAuthentication yes Test-Path -Path $script:WindowsDefaultSourcePath -PathType Leaf -ErrorAction SilentlyContinue | Should -Be $false $inputConfig = @{ - _metadata = @{ - filepath = $script:CurrentWindowsTargetPath - } + _filepath = $script:CurrentWindowsTargetPath _exist = $true subsystem = @{ name = "powershell" diff --git a/resources/sshdconfig/tests/sshdconfigRepeatList.tests.ps1 b/resources/sshdconfig/tests/sshdconfigRepeatList.tests.ps1 index 370f0a06c..92da3e653 100644 --- a/resources/sshdconfig/tests/sshdconfigRepeatList.tests.ps1 +++ b/resources/sshdconfig/tests/sshdconfigRepeatList.tests.ps1 @@ -306,9 +306,7 @@ PasswordAuthentication yes $nonExistentPath = Join-Path $TestDrive "nonexistent_sshd_config_repeatlist_nonwindows" $stderrFile = Join-Path $TestDrive "stderr_nofile_repeatlist_nonwindows.txt" $inputConfig = @{ - _metadata = @{ - filepath = $nonExistentPath - } + _filepath = $nonExistentPath _purge = $false subsystem = @( @{ @@ -353,9 +351,7 @@ PasswordAuthentication yes ) -Encoding ascii $inputConfig = @{ - _metadata = @{ - filepath = $script:CurrentWindowsTargetPath - } + _filepath = $script:CurrentWindowsTargetPath _purge = $false subsystem = @( @{ @@ -377,9 +373,7 @@ PasswordAuthentication yes $LASTEXITCODE | Should -Be 0 Test-Path $script:CurrentWindowsTargetPath | Should -Be $true $getInput = @{ - _metadata = @{ - filepath = $script:CurrentWindowsTargetPath - } + _filepath = $script:CurrentWindowsTargetPath } | ConvertTo-Json $result = sshdconfig get --input $getInput -s sshd-config 2>$null | ConvertFrom-Json $psEntry = $result.subsystem | Where-Object { $_.name -eq "powershell" } @@ -396,9 +390,7 @@ PasswordAuthentication yes Test-Path -Path $script:WindowsDefaultSourcePath -PathType Leaf -ErrorAction SilentlyContinue | Should -Be $false $inputConfig = @{ - _metadata = @{ - filepath = $script:CurrentWindowsTargetPath - } + _filepath = $script:CurrentWindowsTargetPath _purge = $false subsystem = @( @{ From 2f7eb7df1de740cde2cae0f32868915f2d1fcb44 Mon Sep 17 00:00:00 2001 From: Tess Gauthier Date: Tue, 16 Jun 2026 15:41:47 -0400 Subject: [PATCH 7/8] update dsc tests --- dsc/tests/dsc_sshdconfig.tests.ps1 | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/dsc/tests/dsc_sshdconfig.tests.ps1 b/dsc/tests/dsc_sshdconfig.tests.ps1 index de46da74b..4c7177047 100644 --- a/dsc/tests/dsc_sshdconfig.tests.ps1 +++ b/dsc/tests/dsc_sshdconfig.tests.ps1 @@ -27,9 +27,8 @@ metadata: resources: - name: sshdconfig type: Microsoft.OpenSSH.SSHD/sshd_config - metadata: - filepath: $filepath properties: + _filepath: $filepath "@ } @@ -64,9 +63,8 @@ metadata: resources: - name: sshdconfig type: Microsoft.OpenSSH.SSHD/sshd_config - metadata: - filepath: $filepath properties: + _filepath: $filepath passwordauthentication: 'yes' "@ $out = dsc config export -i "$export_yaml" | ConvertFrom-Json -Depth 10 @@ -90,9 +88,8 @@ metadata: resources: - name: sshdconfig type: Microsoft.OpenSSH.SSHD/sshd_config - metadata: - filepath: $filepath properties: + _filepath: $filepath _includeDefaults: $includeDefaults "@ $out = dsc config $command -i "$input" | ConvertFrom-Json -Depth 10 @@ -148,9 +145,8 @@ metadata: resources: - name: sshdconfig type: Microsoft.OpenSSH.SSHD/sshd_config - metadata: - filepath: $filepath properties: + _filepath: $filepath _purge: true port: 1234 allowUsers: @@ -228,9 +224,8 @@ metadata: resources: - name: newsub type: Microsoft.OpenSSH.SSHD/Subsystem - metadata: - filepath: $script:TestConfigPath properties: + _filepath: $script:TestConfigPath _exist: true subsystem: name: newsubsystem @@ -260,9 +255,8 @@ metadata: resources: - name: removesub type: Microsoft.OpenSSH.SSHD/Subsystem - metadata: - filepath: $script:TestConfigPath properties: + _filepath: $script:TestConfigPath _exist: false subsystem: name: sftp @@ -286,9 +280,8 @@ metadata: resources: - name: multisubsystem type: Microsoft.OpenSSH.SSHD/SubsystemList - metadata: - filepath: $script:TestConfigPath properties: + _filepath: $script:TestConfigPath _purge: false subsystem: - name: newsub1 @@ -331,9 +324,8 @@ metadata: resources: - name: preservesubsystem type: Microsoft.OpenSSH.SSHD/SubsystemList - metadata: - filepath: $script:TestConfigPath properties: + _filepath: $script:TestConfigPath _purge: false subsystem: - name: addedSubsystem @@ -367,9 +359,8 @@ metadata: resources: - name: purgesubsystem type: Microsoft.OpenSSH.SSHD/SubsystemList - metadata: - filepath: $script:TestConfigPath properties: + _filepath: $script:TestConfigPath _purge: true subsystem: - name: sftp From 1b3dbc4fdb9ce1f037f474c54d8770ed508b02b0 Mon Sep 17 00:00:00 2001 From: Tess Gauthier Date: Wed, 17 Jun 2026 10:13:46 -0400 Subject: [PATCH 8/8] Update test assertions for SSHD config properties --- dsc/tests/dsc_sshdconfig.tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dsc/tests/dsc_sshdconfig.tests.ps1 b/dsc/tests/dsc_sshdconfig.tests.ps1 index 4c7177047..247e5af0a 100644 --- a/dsc/tests/dsc_sshdconfig.tests.ps1 +++ b/dsc/tests/dsc_sshdconfig.tests.ps1 @@ -70,7 +70,7 @@ resources: $out = dsc config export -i "$export_yaml" | ConvertFrom-Json -Depth 10 $LASTEXITCODE | Should -Be 0 $out.resources.count | Should -Be 1 - ($out.resources[0].properties.psobject.properties | Measure-Object).count | Should -Be 1 + ($out.resources[0].properties.psobject.properties | Measure-Object).count | Should -Be 2 $out.resources[0].properties.passwordAuthentication | Should -Be $false } @@ -101,7 +101,7 @@ resources: $out.resources[0].properties._inheritedDefaults | Should -BeNullOrEmpty } else { $out.results.count | Should -Be 1 - ($out.results.result.actualState.psobject.properties | Measure-Object).count | Should -Be 2 + ($out.results.result.actualState.psobject.properties | Measure-Object).count | Should -Be 3 $out.results.result.actualState.loglevel | Should -Be 'debug3' $out.results.result.actualState._inheritedDefaults | Should -BeNullOrEmpty }