cucumber-sshd 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cucumber/sshd/server.rb +14 -17
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d1490ecfcce254e9252d001b2d5230a4b9d5a80c8fc8d75cfc181552d1776be
4
- data.tar.gz: 563447c5cc35e66a6a01d36e59f551af08cf6202b6a97f48372e7e154861609d
3
+ metadata.gz: bdf66c3017c8748e8500c2afd205d4933a6e4620effbb8a52c1016fad5e81371
4
+ data.tar.gz: 46a7249f56a23a5c22a6803edc2ed721bd09795b2d13e26ee94236113baa74a2
5
5
  SHA512:
6
- metadata.gz: 03bec6dd3ece7de26b87dd1511c15311b4940366d1fe6e40dd56c9373e11e79e35f36490c0c060bee97b5a5c0a9219c17b4650dbb4e6b7b9ea318ec866d60389
7
- data.tar.gz: ee7046516b62d961fb02490e58107f885c35e28d8b363143cae78449b427909e4b68b84233a2e6b482802219de67ec6759d32338e8089cbd9182a8c32cfacbac
6
+ metadata.gz: ae3978de0a18792dfb0fe0721e967eff7b30064eae2ea945e2b0c642999e15a5c992a54e8777b28a664d6a56a8f2d7679a06015da17d65e793e7429d78b243f8
7
+ data.tar.gz: 4f4389002a3ab1378595397e77c1b1c015334f505653284f596f55809c0423629bdf510ee4fabd96fbd23972644ece6c0deb906da2e6a423a9ed0c3cf2b66b42
@@ -4,8 +4,10 @@ module Cucumber
4
4
  HOST = 'some_host.test'.freeze
5
5
  HOSTNAME = 'localhost'.freeze
6
6
  COMMAND = '/usr/sbin/sshd'.freeze
7
- COMMAND_ARGS = '-Deq'.freeze
8
- COMMAND_ARGS_DEBUG = '-De'.freeze
7
+ COMMAND_ARGS = '-De'.freeze
8
+ TMP_FILE_PREFIX = 'cucumber_sshd_'.freeze
9
+ WAIT_READY_DELAY = 0.005
10
+ WAIT_READY_TRIGGER = 'Server listening'.freeze
9
11
  KEY_PATH = 'etc/ssh_host_rsa_key'.freeze
10
12
  KEY_PUB_PATH = [KEY_PATH, '.pub'].join.freeze
11
13
  SSHD_CONFIG_PATH = 'etc/sshd_config'.freeze
@@ -47,6 +49,7 @@ module Cucumber
47
49
  @port = port
48
50
  @debug = debug
49
51
  @persist = persist
52
+ @stderr = Tempfile.new TMP_FILE_PREFIX
50
53
  end
51
54
 
52
55
  def configure
@@ -56,17 +59,10 @@ module Cucumber
56
59
  end
57
60
 
58
61
  def start
62
+ print_server_info if debug?
59
63
  Dir.chdir home do
60
- @pid = fork do
61
- $stderr.reopen '/dev/null' unless debug?
62
- exec command
63
- end
64
- if debug?
65
- sleep 0.05
66
- fail "`#{command}` failed" if Process.waitpid pid, Process::WNOHANG
67
- end
64
+ @pid = spawn *command, err: @stderr
68
65
  end
69
- print_server_info if debug?
70
66
  wait_ready
71
67
  end
72
68
 
@@ -84,8 +80,8 @@ module Cucumber
84
80
  COMMAND,
85
81
  '-f',
86
82
  SSHD_CONFIG_PATH,
87
- (debug? ? COMMAND_ARGS_DEBUG : COMMAND_ARGS)
88
- ].join ' '
83
+ COMMAND_ARGS
84
+ ]
89
85
  end
90
86
 
91
87
  def configure_client
@@ -130,6 +126,7 @@ CUCUMBER SSHD STARTING ---------------------------------------------------------
130
126
  HOME: #{home}
131
127
  LISTEN: #{addr}:#{port}
132
128
  PERSIST: #{persist}
129
+ COMMAND: #{command.join ' '}
133
130
  --------------------------------------------------------------------------------
134
131
  eoh
135
132
  end
@@ -139,10 +136,10 @@ PERSIST: #{persist}
139
136
  end
140
137
 
141
138
  def wait_ready
142
- TCPSocket.new HOSTNAME, port
143
- rescue Errno::ECONNREFUSED
144
- sleep 0.005
145
- retry
139
+ loop do
140
+ break if (IO.read @stderr.path).include? WAIT_READY_TRIGGER
141
+ sleep WAIT_READY_DELAY
142
+ end
146
143
  end
147
144
 
148
145
  def write_file_secure path, 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.1.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: 2022-04-29 00:00:00.000000000 Z
11
+ date: 2022-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  requirements: []
83
- rubygems_version: 3.3.11
83
+ rubygems_version: 3.3.14
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: Cucumber sshd helpers