Update Dockerfile to use pre-built OpenSSH binary and fix test reference to SSH binary (#522)
* Update Dockerfile to use pre-built OpenSSH binary and fix test reference to SSH binary * Add support for multiple SSH binary versions in tests
This commit is contained in:
parent
9b7128b965
commit
77e9b2181a
2 changed files with 50 additions and 39 deletions
10
Dockerfile
10
Dockerfile
|
|
@ -13,15 +13,9 @@ RUN --mount=target=/src,type=bind,source=. --mount=type=cache,target=/root/.cach
|
||||||
ADD entrypoint.sh /sshpiperd
|
ADD entrypoint.sh /sshpiperd
|
||||||
|
|
||||||
FROM builder as testrunner
|
FROM builder as testrunner
|
||||||
RUN apt update && apt install -y autoconf automake libssl-dev libz-dev
|
|
||||||
|
|
||||||
RUN cd /tmp && \
|
COPY --from=farmer1992/openssh-static:V_9_8_P1 /usr/bin/ssh /usr/bin/ssh-9.8p1
|
||||||
curl -fsSL https://github.com/openssh/openssh-portable/archive/refs/tags/V_9_8_P1.tar.gz | tar xz && \
|
COPY --from=farmer1992/openssh-static:V_8_0_P1 /usr/bin/ssh /usr/bin/ssh-8.0p1
|
||||||
cd openssh-portable-V_9_8_P1 && \
|
|
||||||
autoreconf && \
|
|
||||||
./configure && \
|
|
||||||
make ssh && \
|
|
||||||
cp ssh /usr/bin/ssh-9.8.1p1
|
|
||||||
|
|
||||||
FROM docker.io/busybox
|
FROM docker.io/busybox
|
||||||
# LABEL maintainer="Boshi Lian<farmer1992@gmail.com>"
|
# LABEL maintainer="Boshi Lian<farmer1992@gmail.com>"
|
||||||
|
|
|
||||||
|
|
@ -30,41 +30,58 @@ func TestFixed(t *testing.T) {
|
||||||
|
|
||||||
waitForEndpointReady(piperaddr)
|
waitForEndpointReady(piperaddr)
|
||||||
|
|
||||||
randtext := uuid.New().String()
|
for _, tc := range []struct {
|
||||||
targetfie := uuid.New().String()
|
name string
|
||||||
|
bin string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "without-sshping",
|
||||||
|
bin: "ssh-8.0p1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "with-sshping",
|
||||||
|
bin: "ssh-9.8p1",
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
randtext := uuid.New().String()
|
||||||
|
targetfie := uuid.New().String()
|
||||||
|
|
||||||
c, stdin, stdout, err := runCmd(
|
c, stdin, stdout, err := runCmd(
|
||||||
"ssh-9.8.1p1",
|
tc.bin,
|
||||||
"-v",
|
"-v",
|
||||||
"-o",
|
"-o",
|
||||||
"StrictHostKeyChecking=no",
|
"StrictHostKeyChecking=no",
|
||||||
"-o",
|
"-o",
|
||||||
"UserKnownHostsFile=/dev/null",
|
"UserKnownHostsFile=/dev/null",
|
||||||
"-o",
|
"-o",
|
||||||
"RequestTTY=yes",
|
"RequestTTY=yes",
|
||||||
"-p",
|
"-p",
|
||||||
piperport,
|
piperport,
|
||||||
"-l",
|
"-l",
|
||||||
"user",
|
"user",
|
||||||
"127.0.0.1",
|
"127.0.0.1",
|
||||||
fmt.Sprintf(`sh -c "echo SSHREADY && sleep 1 && echo -n %v > /shared/%v"`, randtext, targetfie), // sleep 1 to cover https://github.com/tg123/sshpiper/issues/323
|
fmt.Sprintf(`sh -c "echo SSHREADY && sleep 1 && echo -n %v > /shared/%v"`, randtext, targetfie), // sleep 1 to cover https://github.com/tg123/sshpiper/issues/323
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to ssh to piper-fixed, %v", err)
|
t.Errorf("failed to ssh to piper-fixed, %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer killCmd(c)
|
||||||
|
|
||||||
|
enterPassword(stdin, stdout, "pass")
|
||||||
|
|
||||||
|
waitForStdoutContains(stdout, "SSHREADY", func(_ string) {
|
||||||
|
_, _ = stdin.Write([]byte(fmt.Sprintf("%v\n", "triggerping")))
|
||||||
|
})
|
||||||
|
|
||||||
|
time.Sleep(time.Second * 3) // wait for file flush
|
||||||
|
|
||||||
|
checkSharedFileContent(t, targetfie, randtext)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
defer killCmd(c)
|
|
||||||
|
|
||||||
enterPassword(stdin, stdout, "pass")
|
|
||||||
|
|
||||||
waitForStdoutContains(stdout, "SSHREADY", func(_ string) {
|
|
||||||
_, _ = stdin.Write([]byte(fmt.Sprintf("%v\n", "triggerping")))
|
|
||||||
})
|
|
||||||
|
|
||||||
time.Sleep(time.Second * 3) // wait for file flush
|
|
||||||
|
|
||||||
checkSharedFileContent(t, targetfie, randtext)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHostkeyParam(t *testing.T) {
|
func TestHostkeyParam(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue