diff options
-rw-r--r-- | Dockerfile | 13 | ||||
-rw-r--r-- | test/test_key_factory.rb | 15 |
2 files changed, 21 insertions, 7 deletions
@@ -1,6 +1,17 @@ ARG RUBY_VERSION=3.1 FROM ruby:${RUBY_VERSION} +RUN apt update && apt install -y openssh-server sudo netcat \ + && useradd --create-home --shell '/bin/bash' --comment 'NetSSH' 'net_ssh_1' \ + && useradd --create-home --shell '/bin/bash' --comment 'NetSSH' 'net_ssh_2' \ + && echo net_ssh_1:foopwd | chpasswd \ + && echo net_ssh_2:foo2pwd | chpasswd \ + && mkdir -p /home/net_ssh_1/.ssh \ + && mkdir -p /home/net_ssh_2/.ssh \ + && echo "net_ssh_1 ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \ + && echo "net_ssh_2 ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \ + && ssh-keygen -f /etc/ssh/users_ca -N '' + ENV INSTALL_PATH="/netssh" WORKDIR $INSTALL_PATH @@ -13,4 +24,4 @@ RUN gem install bundler && bundle install COPY . $INSTALL_PATH/ -CMD rake test +CMD service ssh start && rake test && NET_SSH_NO_ED25519=1 rake test diff --git a/test/test_key_factory.rb b/test/test_key_factory.rb index 2254f33..b0ba6f5 100644 --- a/test/test_key_factory.rb +++ b/test/test_key_factory.rb @@ -131,9 +131,10 @@ class TestKeyFactory < NetSSHTest end def test_load_should_parse_openssh_format_private_ecdsa_sha2_nistp256_key + return if ENV['NET_SSH_NO_ED25519'] + File.expects(:read).with(@key_file).returns(ecdsa_sha2_nistp256_key_openssh) - assert_equal ecdsa_sha2_nistp256_key.to_blob, - Net::SSH::KeyFactory.load_private_key('/key-file').to_blob + assert_equal ecdsa_sha2_nistp256_key.to_blob, Net::SSH::KeyFactory.load_private_key('/key-file').to_blob end def test_load_unencrypted_private_ecdsa_sha2_nistp384_key_should_have_fp_md5 @@ -147,9 +148,10 @@ class TestKeyFactory < NetSSHTest end def test_load_should_parse_openssh_format_private_ecdsa_sha2_nistp384_key + return if ENV['NET_SSH_NO_ED25519'] + File.expects(:read).with(@key_file).returns(ecdsa_sha2_nistp384_key_openssh) - assert_equal ecdsa_sha2_nistp384_key.to_blob, - Net::SSH::KeyFactory.load_private_key('/key-file').to_blob + assert_equal ecdsa_sha2_nistp384_key.to_blob, Net::SSH::KeyFactory.load_private_key('/key-file').to_blob end def test_load_unencrypted_private_ecdsa_sha2_nistp521_key_should_have_fp_md5 @@ -163,9 +165,10 @@ class TestKeyFactory < NetSSHTest end def test_load_should_parse_openssh_format_private_ecdsa_sha2_nistp521_key + return if ENV['NET_SSH_NO_ED25519'] + File.expects(:read).with(@key_file).returns(ecdsa_sha2_nistp521_key_openssh) - assert_equal ecdsa_sha2_nistp521_key.to_blob, - Net::SSH::KeyFactory.load_private_key('/key-file').to_blob + assert_equal ecdsa_sha2_nistp521_key.to_blob, Net::SSH::KeyFactory.load_private_key('/key-file').to_blob end def test_load_public_ecdsa_sha2_nistp256_key_should_return_key |