cucumber-sshd 2.0.0.pre5 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cucumber/sshd/cucumber.rb +5 -6
- data/lib/cucumber/sshd/server.rb +31 -38
- metadata +5 -6
- data/lib/cucumber/sshd/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d1490ecfcce254e9252d001b2d5230a4b9d5a80c8fc8d75cfc181552d1776be
|
4
|
+
data.tar.gz: 563447c5cc35e66a6a01d36e59f551af08cf6202b6a97f48372e7e154861609d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03bec6dd3ece7de26b87dd1511c15311b4940366d1fe6e40dd56c9373e11e79e35f36490c0c060bee97b5a5c0a9219c17b4650dbb4e6b7b9ea318ec866d60389
|
7
|
+
data.tar.gz: ee7046516b62d961fb02490e58107f885c35e28d8b363143cae78449b427909e4b68b84233a2e6b482802219de67ec6759d32338e8089cbd9182a8c32cfacbac
|
@@ -3,12 +3,11 @@ require 'cucumber/sshd/server'
|
|
3
3
|
Before '@sshd' do
|
4
4
|
start_server = -> do
|
5
5
|
Cucumber::SSHD::Server.start \
|
6
|
-
home:
|
7
|
-
addr:
|
8
|
-
port:
|
9
|
-
debug:
|
10
|
-
persist:
|
11
|
-
wait_ready: ENV.key?('CUCUMBER_SSHD_WAIT_READY')
|
6
|
+
home: ENV.fetch('CUCUMBER_SSHD_HOME', 'tmp/home'),
|
7
|
+
addr: ENV.fetch('CUCUMBER_SSHD_LISTEN', '::1'),
|
8
|
+
port: ENV.fetch('CUCUMBER_SSHD_PORT', 2222),
|
9
|
+
debug: ENV.key?('CUCUMBER_SSHD_DEBUG'),
|
10
|
+
persist: ENV.key?('CUCUMBER_SSHD_PERSIST')
|
12
11
|
end
|
13
12
|
|
14
13
|
if !$_sshd && ENV.key?('CUCUMBER_SSHD_PERSIST')
|
data/lib/cucumber/sshd/server.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
module Cucumber
|
2
2
|
module SSHD
|
3
3
|
class Server
|
4
|
-
HOST
|
5
|
-
HOSTNAME
|
6
|
-
COMMAND
|
7
|
-
COMMAND_ARGS
|
8
|
-
COMMAND_ARGS_DEBUG
|
9
|
-
KEY_PATH
|
10
|
-
KEY_PUB_PATH
|
11
|
-
SSHD_CONFIG_PATH
|
12
|
-
SSH_CONFIG_PATH
|
13
|
-
SSH_KNOWN_HOSTS_PATH
|
14
|
-
SFTP_SERVER_PATHS
|
4
|
+
HOST = 'some_host.test'.freeze
|
5
|
+
HOSTNAME = 'localhost'.freeze
|
6
|
+
COMMAND = '/usr/sbin/sshd'.freeze
|
7
|
+
COMMAND_ARGS = '-Deq'.freeze
|
8
|
+
COMMAND_ARGS_DEBUG = '-De'.freeze
|
9
|
+
KEY_PATH = 'etc/ssh_host_rsa_key'.freeze
|
10
|
+
KEY_PUB_PATH = [KEY_PATH, '.pub'].join.freeze
|
11
|
+
SSHD_CONFIG_PATH = 'etc/sshd_config'.freeze
|
12
|
+
SSH_CONFIG_PATH = '.ssh/config'.freeze
|
13
|
+
SSH_KNOWN_HOSTS_PATH = '.ssh/known_hosts'.freeze
|
14
|
+
SFTP_SERVER_PATHS = %w[
|
15
15
|
/usr/libexec/sftp-server
|
16
16
|
/usr/lib/openssh/sftp-server
|
17
17
|
].freeze
|
18
18
|
|
19
|
-
KEY =
|
20
|
-
-----BEGIN EC PRIVATE KEY-----
|
21
|
-
MHcCAQEEIJbQy3yg9iU4xFvia9DWKWuhMzI5QGncR6OUldAOSIe7oAoGCCqGSM49
|
22
|
-
AwEHoUQDQgAEJpS8Sknl2X6PNurToQCNu5lX/scaJLr3FkiufD+p67epbwIjiyzo
|
23
|
-
qnLMVQddVitzQP7LEhXbNUuUAzEMfA6rAA==
|
24
|
-
-----END EC PRIVATE KEY-----
|
19
|
+
KEY = <<~eoh.freeze
|
20
|
+
-----BEGIN EC PRIVATE KEY-----
|
21
|
+
MHcCAQEEIJbQy3yg9iU4xFvia9DWKWuhMzI5QGncR6OUldAOSIe7oAoGCCqGSM49
|
22
|
+
AwEHoUQDQgAEJpS8Sknl2X6PNurToQCNu5lX/scaJLr3FkiufD+p67epbwIjiyzo
|
23
|
+
qnLMVQddVitzQP7LEhXbNUuUAzEMfA6rAA==
|
24
|
+
-----END EC PRIVATE KEY-----
|
25
25
|
eoh
|
26
26
|
KEY_PUB =
|
27
27
|
'ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNT' \
|
@@ -40,14 +40,13 @@ qnLMVQddVitzQP7LEhXbNUuUAzEMfA6rAA==
|
|
40
40
|
attr_reader :home
|
41
41
|
|
42
42
|
def initialize(
|
43
|
-
home:, addr:, port:, debug: false, persist: false
|
43
|
+
home:, addr:, port:, debug: false, persist: false
|
44
44
|
)
|
45
|
-
@home
|
46
|
-
@addr
|
47
|
-
@port
|
48
|
-
@debug
|
49
|
-
@persist
|
50
|
-
@wait_ready = wait_ready
|
45
|
+
@home = home
|
46
|
+
@addr = addr
|
47
|
+
@port = port
|
48
|
+
@debug = debug
|
49
|
+
@persist = persist
|
51
50
|
end
|
52
51
|
|
53
52
|
def configure
|
@@ -68,7 +67,7 @@ qnLMVQddVitzQP7LEhXbNUuUAzEMfA6rAA==
|
|
68
67
|
end
|
69
68
|
end
|
70
69
|
print_server_info if debug?
|
71
|
-
wait_ready
|
70
|
+
wait_ready
|
72
71
|
end
|
73
72
|
|
74
73
|
def stop
|
@@ -78,7 +77,7 @@ qnLMVQddVitzQP7LEhXbNUuUAzEMfA6rAA==
|
|
78
77
|
|
79
78
|
private
|
80
79
|
|
81
|
-
attr_reader :addr, :port, :debug, :persist, :
|
80
|
+
attr_reader :addr, :port, :debug, :persist, :pid
|
82
81
|
|
83
82
|
def command
|
84
83
|
[
|
@@ -91,10 +90,10 @@ qnLMVQddVitzQP7LEhXbNUuUAzEMfA6rAA==
|
|
91
90
|
|
92
91
|
def configure_client
|
93
92
|
write_file_secure SSH_CONFIG_PATH, <<-eoh
|
94
|
-
Host
|
95
|
-
HostName
|
96
|
-
Port
|
97
|
-
UserKnownHostsFile
|
93
|
+
Host #{HOST}
|
94
|
+
HostName #{HOSTNAME}
|
95
|
+
Port #{port}
|
96
|
+
UserKnownHostsFile #{File.expand_path home}/#{SSH_KNOWN_HOSTS_PATH}
|
98
97
|
eoh
|
99
98
|
write_file_secure SSH_KNOWN_HOSTS_PATH, "[#{HOSTNAME}]:2222 #{KEY_PUB}"
|
100
99
|
end
|
@@ -108,7 +107,6 @@ ListenAddress #{addr}
|
|
108
107
|
Protocol 2
|
109
108
|
HostKey #{File.expand_path home}/#{KEY_PATH}
|
110
109
|
PidFile /dev/null
|
111
|
-
UsePrivilegeSeparation no
|
112
110
|
Subsystem sftp #{sftp_server_path}
|
113
111
|
ForceCommand HOME=#{File.expand_path home} sh -c "cd ~; [ -f .ssh/rc ] && . .ssh/rc; $SSH_ORIGINAL_COMMAND"
|
114
112
|
eoh
|
@@ -132,7 +130,6 @@ CUCUMBER SSHD STARTING ---------------------------------------------------------
|
|
132
130
|
HOME: #{home}
|
133
131
|
LISTEN: #{addr}:#{port}
|
134
132
|
PERSIST: #{persist}
|
135
|
-
WAIT_READY: #{wait_ready}
|
136
133
|
--------------------------------------------------------------------------------
|
137
134
|
eoh
|
138
135
|
end
|
@@ -141,17 +138,13 @@ WAIT_READY: #{wait_ready}
|
|
141
138
|
SFTP_SERVER_PATHS.detect { |e| File.exist? e }
|
142
139
|
end
|
143
140
|
|
144
|
-
def wait_ready
|
141
|
+
def wait_ready
|
145
142
|
TCPSocket.new HOSTNAME, port
|
146
143
|
rescue Errno::ECONNREFUSED
|
147
|
-
sleep 0.
|
144
|
+
sleep 0.005
|
148
145
|
retry
|
149
146
|
end
|
150
147
|
|
151
|
-
def wait_ready?
|
152
|
-
!!wait_ready
|
153
|
-
end
|
154
|
-
|
155
148
|
def write_file_secure path, content
|
156
149
|
File.open File.join(home, path), ?w, 0600 do |file|
|
157
150
|
file.write content
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-sshd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibault Jouan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -61,7 +61,6 @@ files:
|
|
61
61
|
- lib/cucumber/sshd.rb
|
62
62
|
- lib/cucumber/sshd/cucumber.rb
|
63
63
|
- lib/cucumber/sshd/server.rb
|
64
|
-
- lib/cucumber/sshd/version.rb
|
65
64
|
homepage: https://rubygems.org/gems/cucumber-sshd
|
66
65
|
licenses:
|
67
66
|
- BSD-3-Clause
|
@@ -77,11 +76,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
76
|
version: '0'
|
78
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
78
|
requirements:
|
80
|
-
- - "
|
79
|
+
- - ">="
|
81
80
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
81
|
+
version: '0'
|
83
82
|
requirements: []
|
84
|
-
rubygems_version: 3.
|
83
|
+
rubygems_version: 3.3.11
|
85
84
|
signing_key:
|
86
85
|
specification_version: 4
|
87
86
|
summary: Cucumber sshd helpers
|