@@ -249,6 +249,44 @@ Host coder-vscode.dev.coder.com--*
249249 } )
250250} )
251251
252+ it ( "throws an error if there is a missing end block" , async ( ) => {
253+ // The below config is missing an end block.
254+ // This is a malformed config and should throw an error.
255+ const existentSSHConfig = `Host beforeconfig
256+ HostName before.config.tld
257+ User before
258+
259+ # --- START CODER VSCODE dev.coder.com ---
260+ Host coder-vscode.dev.coder.com--*
261+ ConnectTimeout 0
262+ LogLevel ERROR
263+ ProxyCommand some-command-here
264+ StrictHostKeyChecking no
265+ UserKnownHostsFile /dev/null
266+
267+ Host afterconfig
268+ HostName after.config.tld
269+ User after`
270+
271+ const sshConfig = new SSHConfig ( sshFilePath , mockFileSystem )
272+ mockFileSystem . readFile . mockResolvedValueOnce ( existentSSHConfig )
273+ await sshConfig . load ( )
274+
275+ // When we try to update the config, it should throw an error.
276+ await expect (
277+ sshConfig . update ( "dev.coder.com" , {
278+ Host : "coder-vscode.dev.coder.com--*" ,
279+ ProxyCommand : "some-command-here" ,
280+ ConnectTimeout : "0" ,
281+ StrictHostKeyChecking : "no" ,
282+ UserKnownHostsFile : "/dev/null" ,
283+ LogLevel : "ERROR" ,
284+ } ) ,
285+ ) . rejects . toThrow (
286+ `Malformed config: Unterminated START CODER VSCODE dev.coder.com block: Each START block must have an END block.` ,
287+ )
288+ } )
289+
252290it ( "throws an error if there is a mismatched start and end block count" , async ( ) => {
253291 // The below config contains two start blocks and one end block.
254292 // This is a malformed config and should throw an error.
0 commit comments