-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 'not recognized as an internal or external command' for dev envs …
…on windows (#3853)
- Loading branch information
Showing
8 changed files
with
122 additions
and
77 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
.changes/next-release/bugfix-5f45163e-463d-46d7-84de-155f8eecc467.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"type" : "bugfix", | ||
"description" : "Fix 'not recognzied as an ... command' when connecting to CodeCatalyst Dev Environments on Windows" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...are/aws/toolkits/jetbrains/gateway/connection/caws/CawsSshConnectionConfigModifierTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.jetbrains.gateway.connection.caws | ||
|
||
import com.intellij.openapi.util.SystemInfo | ||
import com.intellij.ssh.PromiscuousSshHostKeyVerifier | ||
import com.intellij.ssh.config.SshConnectionConfig | ||
import com.intellij.ssh.config.SshProxyConfig | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.mockito.kotlin.doReturn | ||
import org.mockito.kotlin.mock | ||
import software.aws.toolkits.core.region.AwsRegion | ||
import software.aws.toolkits.jetbrains.core.tools.MockToolManagerRule | ||
import software.aws.toolkits.jetbrains.core.tools.Tool | ||
import software.aws.toolkits.jetbrains.gateway.connection.AbstractSsmCommandExecutor | ||
import software.aws.toolkits.jetbrains.gateway.connection.StartSessionResponse | ||
import software.aws.toolkits.jetbrains.services.ssm.SsmPlugin | ||
import java.nio.file.Path | ||
|
||
class CawsSshConnectionConfigModifierTest { | ||
@Rule | ||
@JvmField | ||
val toolManager = MockToolManagerRule() | ||
|
||
@Test | ||
fun `modify only mutates CodeCatalyst targets`() { | ||
val initial = SshConnectionConfig("test") | ||
val sut = CawsSshConnectionConfigModifier() | ||
|
||
assertThat(sut.modify(initial.host, initial)).isEqualTo(initial) | ||
} | ||
|
||
@Test | ||
fun `modify adds proxy command to CodeCatalyst targets`() { | ||
val dummyExecutor = object : AbstractSsmCommandExecutor(AwsRegion.GLOBAL, "test") { | ||
val response = StartSessionResponse("session", "stream", "token") | ||
|
||
override fun startSsh() = response | ||
override fun startSsm(exe: String, vararg args: String) = response | ||
} | ||
val mockPath = Path.of("ssm") | ||
val mockTool = mock<Tool<SsmPlugin>> { | ||
on { | ||
path | ||
}.doReturn(mockPath) | ||
} | ||
|
||
toolManager.registerTool(SsmPlugin, mockTool) | ||
|
||
val proxyCommand = if (SystemInfo.isWindows) { | ||
"""${mockPath.toAbsolutePath()} "{\"streamUrl\":\"stream\",\"tokenValue\":\"token\",\"sessionId\":\"session\"}" aws-global StartSession""" | ||
} else { | ||
"""${mockPath.toAbsolutePath()} '{"streamUrl":"stream","tokenValue":"token","sessionId":"session"}' 'aws-global' 'StartSession'""" | ||
} | ||
|
||
assertThat(CawsSshConnectionConfigModifier.modify(dummyExecutor, SshConnectionConfig("test"))) | ||
.isEqualTo( | ||
SshConnectionConfig("test").copy( | ||
proxyConfig = SshProxyConfig.Command(command = proxyCommand), | ||
hostKeyVerifier = PromiscuousSshHostKeyVerifier | ||
) | ||
) | ||
} | ||
} |