From da080c472fc415b0ce918f4dd4a1ab143bb1bca4 Mon Sep 17 00:00:00 2001 From: Philip Hands Date: Mon, 14 Mar 2016 15:36:16 +0100 Subject: rough attempt to grab the good cucumber bits from recent tails --- features/support/helpers/sshd_helper.rb | 67 +++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 features/support/helpers/sshd_helper.rb (limited to 'features/support/helpers/sshd_helper.rb') diff --git a/features/support/helpers/sshd_helper.rb b/features/support/helpers/sshd_helper.rb new file mode 100644 index 00000000..2e0069c0 --- /dev/null +++ b/features/support/helpers/sshd_helper.rb @@ -0,0 +1,67 @@ +require 'tempfile' + +class SSHServer + def initialize(sshd_host, sshd_port, authorized_keys = nil) + @sshd_host = sshd_host + @sshd_port = sshd_port + @authorized_keys = authorized_keys + @pid = nil + end + + def start + @sshd_key_file = Tempfile.new("ssh_host_rsa_key", $config["TMPDIR"]) + # 'hack' to prevent ssh-keygen from prompting to overwrite the file + File.delete(@sshd_key_file.path) + cmd_helper(['ssh-keygen', '-t', 'rsa', '-N', "", '-f', "#{@sshd_key_file.path}"]) + @sshd_key_file.close + + sshd_config =< e + if e.message == "No such process" + return false + else + raise e + end + end + assert_equal(1, ret, "This shouldn't happen") + return true + end +end -- cgit v1.2.3-70-g09d2