diff --git a/python/junit5Tests-framework/src/com/intellij/python/junit5Tests/framework/unit/PySshDockerContainer.kt b/python/junit5Tests-framework/src/com/intellij/python/junit5Tests/framework/unit/PySshDockerContainer.kt index f41ee82b564f..f1b4e6baf8c6 100644 --- a/python/junit5Tests-framework/src/com/intellij/python/junit5Tests/framework/unit/PySshDockerContainer.kt +++ b/python/junit5Tests-framework/src/com/intellij/python/junit5Tests/framework/unit/PySshDockerContainer.kt @@ -4,7 +4,7 @@ import org.testcontainers.containers.GenericContainer import org.testcontainers.utility.DockerImageName /** - * Docker container with python and ssh. Login with `user:123@127.0.0.1` + * Docker container with python and ssh. Login with `user:123@127.0.0.1:${sshContainer.sshPort}` * ```kotlin * @Testcontainers * class PySshDockerTest { @@ -15,6 +15,7 @@ import org.testcontainers.utility.DockerImageName * } * @Test * fun testContainer() { + * sshContainer.sshPort // 22 -> * } *``` */ @@ -23,4 +24,9 @@ class PySshDockerContainer : GenericContainer( init { addExposedPort(22) } + + /** + * Port to connect SSH client to + */ + val sshPort: UShort get() = firstMappedPort.toUShort() } \ No newline at end of file diff --git a/python/junit5Tests-framework/src/com/intellij/python/junit5Tests/unit/showCase/PySshDockerTest.kt b/python/junit5Tests-framework/src/com/intellij/python/junit5Tests/unit/showCase/PySshDockerTest.kt index 18b91bc5fd62..90e5e6f28a12 100644 --- a/python/junit5Tests-framework/src/com/intellij/python/junit5Tests/unit/showCase/PySshDockerTest.kt +++ b/python/junit5Tests-framework/src/com/intellij/python/junit5Tests/unit/showCase/PySshDockerTest.kt @@ -22,8 +22,8 @@ class PySshDockerTest { val client = SshClient.setUpDefaultClient() client.start() try { - val sessionFuture = client.connect("user", InetSocketAddress("127.0.0.1", sshContainer.firstMappedPort)) - Assertions.assertTrue(sessionFuture.await(10_000), "Failed to connect to ${sshContainer.firstMappedPort}") + val sessionFuture = client.connect("user", InetSocketAddress("127.0.0.1", sshContainer.sshPort.toInt())) + Assertions.assertTrue(sessionFuture.await(10_000), "Failed to connect to ${sshContainer.sshPort}") val session = sessionFuture.session session.addPasswordIdentity("123") Assertions.assertTrue(session.auth().verify().isSuccess, "failed to authenticate")