Skip to content

Commit

Permalink
chore(CI): fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach committed Sep 18, 2021
1 parent 6e270a8 commit a4a279a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -39,4 +37,4 @@ jobs:
- name: Run tests
run: crystal spec -v --error-trace
env:
SPEC_SSH_HOST: sshdev
SPEC_SSH_HOST: sshtest
11 changes: 6 additions & 5 deletions spec/ssh2_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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|
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit a4a279a

Please sign in to comment.