@@ -62,62 +62,57 @@ Describe 'Default Shell Configuration Tests' -Skip:(!$IsWindows) {
62
62
$testShell = " C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
63
63
New-ItemProperty - Path $RegistryPath - Name " DefaultShell" - Value $testShell
64
64
65
- $output = sshdconfig get
65
+ $output = sshdconfig get - r windows - global
66
66
$LASTEXITCODE | Should - Be 0
67
67
68
68
$result = $output | ConvertFrom-Json
69
69
$result.shell | Should - Be $testShell
70
70
$result.cmd_option | Should - BeNullOrEmpty
71
71
$result.escape_arguments | Should - BeNullOrEmpty
72
- $result.shell_arguments | Should - BeNullOrEmpty
73
72
}
74
73
75
74
It ' Should get default shell with args when registry value exists' {
76
75
$testShell = " C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
77
- $testShellWithArgs = " C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NonInteractive "
76
+ $testShellWithArgs = " C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
78
77
New-ItemProperty - Path $RegistryPath - Name " DefaultShell" - Value $testShellWithArgs
79
78
New-ItemProperty - Path $RegistryPath - Name " DefaultShellCommandOption" - Value " /c"
80
79
New-ItemProperty - Path $RegistryPath - Name " DefaultShellEscapeArguments" - Value 0 - Type DWord
81
80
82
- $output = sshdconfig get
81
+ $output = sshdconfig get - r windows - global
83
82
$LASTEXITCODE | Should - Be 0
84
83
85
84
$result = $output | ConvertFrom-Json
86
85
$result.shell | Should - Be $testShell
87
86
$result.cmd_option | Should - Be " /c"
88
87
$result.escape_arguments | Should - Be $false
89
- $result.shell_arguments | Should - Be @ (" -NoProfile" , " -NonInteractive" )
90
88
}
91
89
92
90
It ' Should handle empty default shell registry values' - Skip:(! $IsWindows ) {
93
- $output = sshdconfig get
91
+ $output = sshdconfig get - r windows - global
94
92
$LASTEXITCODE | Should - Be 0
95
93
96
94
$result = $output | ConvertFrom-Json
97
95
$result.shell | Should - BeNullOrEmpty
98
96
$result.cmd_option | Should - BeNullOrEmpty
99
97
$result.escape_arguments | Should - BeNullOrEmpty
100
- $result.shell_arguments | Should - BeNullOrEmpty
101
98
}
102
99
}
103
100
104
101
Context ' Set Default Shell' {
105
102
It ' Should set default shell with valid configuration' {
106
103
$testShell = " C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
107
- $testShellWithArgs = " C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NonInteractive"
108
104
109
105
$inputConfig = @ {
110
106
shell = $testShell
111
107
cmd_option = " /c"
112
108
escape_arguments = $false
113
- shell_arguments = @ (" -NoProfile" , " -NonInteractive" )
114
109
} | ConvertTo-Json
115
110
116
111
sshdconfig set -- input $inputConfig
117
112
$LASTEXITCODE | Should - Be 0
118
113
119
114
$defaultShell = Get-ItemProperty - Path $RegistryPath - Name " DefaultShell" - ErrorAction SilentlyContinue
120
- $defaultShell.DefaultShell | Should - Be $testShellWithArgs
115
+ $defaultShell.DefaultShell | Should - Be $testShell
121
116
122
117
$cmdOption = Get-ItemProperty - Path $RegistryPath - Name " DefaultShellCommandOption" - ErrorAction SilentlyContinue
123
118
$cmdOption.DefaultShellCommandOption | Should - Be " /c"
@@ -164,22 +159,20 @@ Describe 'Default Shell Configuration Tests' -Skip:(!$IsWindows) {
164
159
shell = " C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
165
160
cmd_option = " /c"
166
161
escape_arguments = $true
167
- shell_arguments = @ (" -NoProfile" , " -NonInteractive" )
168
162
}
169
163
$inputJson = $originalConfig | ConvertTo-Json
170
164
171
165
sshdconfig set -- input $inputJson
172
166
$LASTEXITCODE | Should - Be 0
173
167
174
- $getOutput = sshdconfig get
168
+ $getOutput = sshdconfig get - r windows - global
175
169
$LASTEXITCODE | Should - Be 0
176
170
177
171
$retrievedConfig = $getOutput | ConvertFrom-Json
178
172
179
173
$retrievedConfig.shell | Should - Be $originalConfig.shell
180
174
$retrievedConfig.cmd_option | Should - Be $originalConfig.cmd_option
181
175
$retrievedConfig.escape_arguments | Should - Be $originalConfig.escape_arguments
182
- $retrievedConfig.shell_arguments | Should - Be $originalConfig.shell_arguments
183
176
}
184
177
}
185
178
@@ -209,7 +202,7 @@ Describe 'Default Shell Configuration Error Handling on Non-Windows Platforms' -
209
202
}
210
203
211
204
It ' Should return error for get command' {
212
- $out = sshdconfig get 2>&1
205
+ $out = sshdconfig get - r windows - global 2>&1
213
206
$LASTEXITCODE | Should -Not - Be 0
214
207
$out | Should - BeLike ' *not applicable to this platform*'
215
208
}
0 commit comments