Skip to content

tests: add option to run tests without docker - #762

Merged
vszakats merged 1 commit into
libssh2:masterfrom
vszakats:tests-nodocker
Nov 12, 2022
Merged

vszakats merged 1 commit into
libssh2:masterfrom
vszakats:tests-nodocker

Conversation

@vszakats

@vszakats vszakats commented Oct 22, 2022 •

Copy link
Copy Markdown
Member

via export OPENSSH_NO_DOCKER=1.

SSH server host can be set via:
export OPENSSH_SERVER_HOST=127.0.0.1

SSH server port via existing:
export OPENSSH_SERVER_PORT=4711

This requires more work to be usable out of the box. The necessery sshd config is (partly) embedded into tests/openssh_server/Dockerfile.

After this patch, it is possible to run tests in envs where docker is not installed or not available, by running a preconfigured, non-containerized sshd.

Diff without whitespaces: https://github.com/libssh2/libssh2/pull/762/files?w=1

@vszakats vszakats mentioned this pull request Oct 22, 2022
@vszakats

Copy link
Copy Markdown
Member Author

So far very little success with running sshd via chroot or other tricks.

@vszakats

Copy link
Copy Markdown
Member Author

sshserver.pl from curl looks promising.

via `export OPENSSH_NO_DOCKER=1`.

SSH server host can be set via:
  `export OPENSSH_SERVER_HOST=127.0.0.1`

SSH server port via existing:
  `export OPENSSH_SERVER_PORT=4711`

This requires more work to be usable out of the box. The necessery sshd
config is (partly) embedded into `tests/openssh_server/Dockerfile`.

After this patch, it is possible to run tests in envs where docker is
not installed or not available, by running a preconfigured,
non-containerized sshd.
@vszakats

Copy link
Copy Markdown
Member Author

Some success:

#!/bin/sh

cd "$(dirname "$0")" || exit 1

case "$(uname)" in
  Darwin*) sed() { gsed "$@"; };;
esac

CURL_PATH='../../curl'

cp -p \
  "${CURL_PATH}"/tests/pathhelp.pm \
  "${CURL_PATH}"/tests/serverhelp.pm \
  "${CURL_PATH}"/tests/sshhelp.pm \
  .

# shellcheck disable=SC2016
sed \
  -e '/"HostKey /a push @cfgarr, "HostKey ".abs_path("$path/curl_host_ecdsa_key");' \
  -e '/"HostKey /a push @cfgarr, "HostKey ".abs_path("$path/curl_host_ed25519_key");' \
  -e 's/PasswordAuthentication no/PasswordAuthentication yes/g' \
  -e 's/ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/g' \
  < "${CURL_PATH}"/tests/sshserver.pl > sshserver.pl

cp -p openssh_server/authorized_keys curl_client_key.pub
chmod 600 curl_client_key.pub

for t in rsa ecdsa ed25519; do
  cp -p "openssh_server/ssh_host_${t}_key" "curl_host_${t}_key"
  chmod 600 "curl_host_${t}_key"
  ssh-keygen -y -f "curl_host_${t}_key" > "curl_host_${t}_key.pub"
  cut -d ' ' -f 2 < "curl_host_${t}_key.pub" | base64 -d | openssl dgst -md5 | tr -d \\n > "curl_host_${t}_key.pub_md5"
  cut -d ' ' -f 2 < "curl_host_${t}_key.pub" | base64 -d | openssl dgst -sha256 -binary | base64 | tr -d \\n > "curl_host_${t}_key.pub_sha256"
done

perl -I. sshserver.pl --sshport 4711 --user libssh2

Then:

OPENSSH_NO_DOCKER=1 LIBSSH2_TRACE_ALL=1 FIXTURE_TRACE_ALL=1 ./test_hostkey

@vszakats
vszakats merged commit f6694be into libssh2:master Nov 12, 2022
@vszakats
vszakats deleted the tests-nodocker branch November 12, 2022 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant