mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PySshDockerContainer: simplify and document port usage
GitOrigin-RevId: 4b3a2b6cae1142ec418cb47d603e6eec35a05741
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c51f227a33
commit
7373cc97bb
+7
-1
@@ -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<PySshDockerContainer>(
|
||||
init {
|
||||
addExposedPort(22)
|
||||
}
|
||||
|
||||
/**
|
||||
* Port to connect SSH client to
|
||||
*/
|
||||
val sshPort: UShort get() = firstMappedPort.toUShort()
|
||||
}
|
||||
+2
-2
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user