mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 10:22:58 +08:00
feat: support X11 forwarding (#443)
This commit is contained in:
@@ -1,45 +1,15 @@
|
||||
package app.termora
|
||||
|
||||
import org.apache.sshd.sftp.client.impl.DefaultSftpClientFactory
|
||||
import org.testcontainers.containers.GenericContainer
|
||||
import java.nio.file.Files
|
||||
import kotlin.test.AfterTest
|
||||
import kotlin.test.BeforeTest
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class SFTPTest {
|
||||
private val sftpContainer = GenericContainer("linuxserver/openssh-server")
|
||||
.withEnv("PUID", "1000")
|
||||
.withEnv("PGID", "1000")
|
||||
.withEnv("TZ", "Etc/UTC")
|
||||
.withEnv("SUDO_ACCESS", "true")
|
||||
.withEnv("PASSWORD_ACCESS", "true")
|
||||
.withEnv("USER_NAME", "foo")
|
||||
.withEnv("USER_PASSWORD", "pass")
|
||||
.withEnv("SUDO_ACCESS", "true")
|
||||
.withExposedPorts(2222)
|
||||
class SFTPTest : SSHDTest() {
|
||||
|
||||
@BeforeTest
|
||||
fun setup() {
|
||||
sftpContainer.start()
|
||||
}
|
||||
|
||||
@AfterTest
|
||||
fun teardown() {
|
||||
sftpContainer.stop()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test() {
|
||||
val host = Host(
|
||||
name = sftpContainer.containerName,
|
||||
protocol = Protocol.SSH,
|
||||
host = "127.0.0.1",
|
||||
port = sftpContainer.getMappedPort(2222),
|
||||
username = "foo",
|
||||
authentication = Authentication.No.copy(type = AuthenticationType.Password, password = "pass"),
|
||||
)
|
||||
|
||||
val client = SshClients.openClient(host)
|
||||
val session = SshClients.openSession(host, client)
|
||||
|
||||
41
src/test/kotlin/app/termora/SSHDTest.kt
Normal file
41
src/test/kotlin/app/termora/SSHDTest.kt
Normal file
@@ -0,0 +1,41 @@
|
||||
package app.termora
|
||||
|
||||
import org.testcontainers.containers.GenericContainer
|
||||
import kotlin.test.AfterTest
|
||||
import kotlin.test.BeforeTest
|
||||
|
||||
|
||||
abstract class SSHDTest {
|
||||
protected val sshd: GenericContainer<*> = GenericContainer("sshd")
|
||||
.withEnv("PUID", "1000")
|
||||
.withEnv("PGID", "1000")
|
||||
.withEnv("TZ", "Etc/UTC")
|
||||
.withEnv("SUDO_ACCESS", "true")
|
||||
.withEnv("PASSWORD_ACCESS", "true")
|
||||
.withEnv("USER_NAME", "foo")
|
||||
.withEnv("USER_PASSWORD", "pass")
|
||||
.withEnv("SUDO_ACCESS", "true")
|
||||
.withExposedPorts(2222)
|
||||
|
||||
protected val host by lazy {
|
||||
Host(
|
||||
name = sshd.containerName,
|
||||
protocol = Protocol.SSH,
|
||||
host = "127.0.0.1",
|
||||
port = sshd.getMappedPort(2222),
|
||||
username = "foo",
|
||||
authentication = Authentication.No.copy(type = AuthenticationType.Password, password = "pass"),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@BeforeTest
|
||||
fun setup() {
|
||||
sshd.start()
|
||||
}
|
||||
|
||||
@AfterTest
|
||||
fun teardown() {
|
||||
sshd.stop()
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
FROM linuxserver/openssh-server
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
||||
&& apk update && apk add wget gcc g++ git make zsh htop stress-ng inetutils-telnet xclock xorg-server xinit && wget https://ohse.de/uwe/releases/lrzsz-0.12.20.tar.gz \
|
||||
&& apk update && apk add wget gcc g++ git make zsh htop stress-ng inetutils-telnet xclock xcalc xorg-server xinit && wget https://ohse.de/uwe/releases/lrzsz-0.12.20.tar.gz \
|
||||
&& tar -xf lrzsz-0.12.20.tar.gz && cd lrzsz-0.12.20 && ./configure && make && make install \
|
||||
&& ln -s /usr/local/bin/lrz /usr/local/bin/rz && ln -s /usr/local/bin/lsz /usr/local/bin/sz
|
||||
RUN sed -i 's/#AllowAgentForwarding yes/AllowAgentForwarding yes/g' /etc/ssh/sshd_config
|
||||
|
||||
Reference in New Issue
Block a user