diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5f15f8..b5b0076 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,12 +19,10 @@ jobs: services: # Label used to access the service container - sshdev: - # Docker Hub image - image: placeos/ssh-test - options: >- - -p 2222:22 - -e ROOT_PASS="somepassword" + sshtest: + image: placeos/ssh-test:latest + env: + ROOT_PASS: somepassword steps: - uses: actions/checkout@v2 @@ -39,4 +37,4 @@ jobs: - name: Run tests run: crystal spec -v --error-trace env: - SPEC_SSH_HOST: sshdev + SPEC_SSH_HOST: sshtest diff --git a/spec/ssh2_spec.cr b/spec/ssh2_spec.cr index 96aeca6..163d3ab 100644 --- a/spec/ssh2_spec.cr +++ b/spec/ssh2_spec.cr @@ -2,10 +2,11 @@ require "../src/ssh2" require "spec" SPEC_SSH_HOST = ENV["SPEC_SSH_HOST"]? || "localhost" +SPEC_SSH_PORT = ENV["CI"]? ? 22 : 2222 def connect_ssh - SSH2::Session.open(SPEC_SSH_HOST, 2222) do |session| - if ENV["TRAVIS"]? + SSH2::Session.open(SPEC_SSH_HOST, SPEC_SSH_PORT) do |session| + if ENV["CI"]? session.login("root", "somepassword") else session.login_with_pubkey("root", "./spec/keys/id_rsa", "./spec/keys/id_rsa.pub") @@ -28,7 +29,7 @@ describe SSH2 do end it "should be able to connect in interactive mode" do - SSH2::Session.open(SPEC_SSH_HOST, 2222) do |session| + SSH2::Session.open(SPEC_SSH_HOST, SPEC_SSH_PORT) do |session| session.interactive_login("root") { "somepassword" } session.open_session do |channel| @@ -41,7 +42,7 @@ describe SSH2 do end it "should obtain a list of supported auth methods" do - SSH2::Session.open(SPEC_SSH_HOST, 2222) do |session| + SSH2::Session.open(SPEC_SSH_HOST, SPEC_SSH_PORT) do |session| methods = session.login_with_noauth("root") methods.should eq(["publickey", "password", "keyboard-interactive"]) end @@ -105,7 +106,7 @@ describe SSH2::KnownHosts do known_hosts = session.knownhosts known_hosts.read_file("known_hosts") key, _ = session.hostkey - host = known_hosts.check(SPEC_SSH_HOST, 2222, key, LibSSH2::TypeMask::PLAIN | LibSSH2::TypeMask::KEYENC_RAW) + host = known_hosts.check(SPEC_SSH_HOST, SPEC_SSH_PORT, key, LibSSH2::TypeMask::PLAIN | LibSSH2::TypeMask::KEYENC_RAW) host.should eq(LibSSH2::KnownHostCheck::MATCH) end File.delete("known_hosts")