init file from sshd_config_default on Windows#1474
init file from sshd_config_default on Windows#1474tgauth wants to merge 6 commits intoPowerShell:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses #1469 by changing how the sshdconfig resource behaves when the target sshd_config file is missing—on Windows, it attempts to seed the file from the system’s sshd_config_default so subsequent subsystem-related operations don’t fail due to an empty/nonexistent config.
Changes:
- Added
ensure_sshd_config_exists()to seed a missingsshd_configfromsshd_config_defaulton Windows. - Updated
setflows to require/ensure an existing config before applying non-purge updates and repeat-keyword updates. - Expanded Pester coverage to validate behavior when the target config file is missing.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| resources/sshdconfig/src/util.rs | Adds seeding helper to create a missing target config from a Windows default source. |
| resources/sshdconfig/src/set.rs | Calls the new seeding helper before reading/modifying config for non-purge and repeat operations. |
| resources/sshdconfig/locales/en-us.toml | Adds new localized messages for seeding and missing-default-source scenarios. |
| resources/sshdconfig/tests/sshdconfig.set.tests.ps1 | Updates/extends set tests for missing-file behavior. |
| resources/sshdconfig/tests/sshdconfigRepeat.tests.ps1 | Adds repeat-keyword test for missing-file behavior. |
| resources/sshdconfig/tests/sshdconfigRepeatList.tests.ps1 | Adds repeat-list test for missing-file behavior. |
| resources/sshdconfig/tests/sshdconfig.get.tests.ps1 | Tightens get tests to ensure missing config doesn’t get created. |
| $stderr = Get-Content -Path $stderrFile -Raw -ErrorAction SilentlyContinue | ||
| $stderr | Should -Match "_purge=false requires an existing sshd_config file" | ||
| $stderr | Should -Match "Use _purge=true to create a new configuration file" | ||
| if ($IsWindows -and $script:DefaultSourceExists) { |
There was a problem hiding this comment.
Is it possible to have test cases that cover both cases instead of relying on what is setup on the system?
There was a problem hiding this comment.
Test cases for both $env:WINDIR\System32\OpenSSH\sshd_config_default existing and not existing?
There was a problem hiding this comment.
Yes, rather than rely on the system under test, have explicit tests for both cases
PR Summary
PR Context