From fb8eba9f91d0b9f55078b6a2843d88d11ebeba4c Mon Sep 17 00:00:00 2001 From: Boshi Lian Date: Wed, 14 Feb 2024 22:24:21 -0800 Subject: [PATCH] fix ping@openssh being passed to unsupported sshd (#326) * add testcase * Fix formatting in e2e/fixed_test.go * disable ping until we have a solution --- Dockerfile | 5 ++++- crypto | 2 +- e2e/docker-compose.yml | 2 +- e2e/fixed_test.go | 10 ++++++++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 99d1171a..9950be26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/golang:1.22-bullseye as builder +FROM docker.io/golang:1.22.0-alpine3.19 as builder ARG VER=devel ARG BUILDTAGS="" @@ -12,6 +12,9 @@ RUN --mount=target=/src,type=bind,source=. --mount=type=cache,target=/root/.cach RUN --mount=target=/src,type=bind,source=. --mount=type=cache,target=/root/.cache/go-build if [ "$EXTERNAL" = "1" ]; then cp -r plugins /sshpiperd ; else go build -o /sshpiperd/plugins -tags "$BUILDTAGS" ./plugin/...; fi ADD entrypoint.sh /sshpiperd +FROM builder as testrunner +RUN apk add openssh-client git bash coreutils + FROM docker.io/busybox LABEL maintainer="Boshi Lian" diff --git a/crypto b/crypto index e94916ba..06bd4d37 160000 --- a/crypto +++ b/crypto @@ -1 +1 @@ -Subproject commit e94916bae9d623c977f9f515cc21cd9f39f5cb3a +Subproject commit 06bd4d377ec44ce00cbd9a5084f40b8980c94e0e diff --git a/e2e/docker-compose.yml b/e2e/docker-compose.yml index bea1a4d0..fbee44c5 100644 --- a/e2e/docker-compose.yml +++ b/e2e/docker-compose.yml @@ -86,7 +86,7 @@ services: - DOCKER_API_VERSION=1.40 build: context: ../ - target: builder + target: testrunner args: - BUILDTAGS=e2e volumes: diff --git a/e2e/fixed_test.go b/e2e/fixed_test.go index c486cfd9..4291e3ed 100644 --- a/e2e/fixed_test.go +++ b/e2e/fixed_test.go @@ -40,12 +40,14 @@ func TestFixed(t *testing.T) { "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", + "-o", + "RequestTTY=yes", "-p", piperport, "-l", "user", "127.0.0.1", - fmt.Sprintf(`sh -c "echo -n %v > /shared/%v"`, randtext, targetfie), + 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 { @@ -56,7 +58,11 @@ func TestFixed(t *testing.T) { enterPassword(stdin, stdout, "pass") - time.Sleep(time.Second) // wait for file flush + 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) }