diff options
author | Florian Wininger <florian@cyberwatch.fr> | 2021-07-01 22:17:46 +0200 |
---|---|---|
committer | Florian Wininger <florian@cyberwatch.fr> | 2021-07-01 22:17:46 +0200 |
commit | b11dc6e755bbc03058bb12c623961a0695538fb0 (patch) | |
tree | 567f524185abc09ec6bb2a6a593b5a4abb78393d | |
parent | 093a84100e51365db9680d8ebd0755a4f1ebb455 (diff) | |
download | net-ssh-b11dc6e755bbc03058bb12c623961a0695538fb0.tar.gz |
Fix empty line for code clarity
109 files changed, 73 insertions, 193 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f716dcb..1483c6f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -31,26 +31,6 @@ Layout/AssignmentIndentation: - 'test/transport/kex/test_ecdh_sha2_nistp384.rb' - 'test/transport/kex/test_ecdh_sha2_nistp521.rb' -# Offense count: 71 -# Cop supports --auto-correct. -Layout/EmptyLineAfterGuardClause: - Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines. -Layout/EmptyLineBetweenDefs: - Exclude: - - 'lib/net/ssh/authentication/agent.rb' - - 'test/integration/test_proxy.rb' - -# Offense count: 172 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines -Layout/EmptyLinesAroundModuleBody: - Enabled: false - # Offense count: 63 # Cop supports --auto-correct. # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. @@ -48,6 +48,7 @@ namespace :cert do raw = File.read "net-ssh-public_cert.pem" certificate = OpenSSL::X509::Certificate.new raw raise Exception, "Not yet expired: #{certificate.not_after}" unless certificate.not_after < Time.now + sh "gem cert --build netssh@solutious.com --days 365*5 --private-key /mnt/gem/net-ssh-private_key.pem" sh "mv gem-public_cert.pem net-ssh-public_cert.pem" sh "gem cert --add net-ssh-public_cert.pem" diff --git a/lib/net/ssh.rb b/lib/net/ssh.rb index 292d6c6..8b8b7b9 100644 --- a/lib/net/ssh.rb +++ b/lib/net/ssh.rb @@ -15,7 +15,6 @@ require 'net/ssh/connection/session' require 'net/ssh/prompt' module Net - # Net::SSH is a library for interacting, programmatically, with remote # processes via the SSH2 protocol. Sessions are always initiated via # Net::SSH.start. From there, a program interacts with the new SSH session diff --git a/lib/net/ssh/authentication/agent.rb b/lib/net/ssh/authentication/agent.rb index 59912a8..7ff0096 100644 --- a/lib/net/ssh/authentication/agent.rb +++ b/lib/net/ssh/authentication/agent.rb @@ -13,6 +13,7 @@ module Net module Authentication # Class for representing agent-specific errors. class AgentError < Net::SSH::Exception; end + # An exception for indicating that the SSH agent is not available. class AgentNotAvailable < AgentError; end @@ -107,6 +108,7 @@ module Net type, body = send_and_wait(SSH2_AGENT_REQUEST_VERSION, :string, Transport::ServerVersion::PROTO_VERSION) raise AgentNotAvailable, "SSH2 agents are not yet supported" if type == SSH2_AGENT_VERSION_RESPONSE + if type == SSH2_AGENT_FAILURE debug { "Unexpected response type==#{type}, this will be ignored" } elsif type != SSH_AGENT_RSA_IDENTITIES_ANSWER1 && type != SSH_AGENT_RSA_IDENTITIES_ANSWER2 diff --git a/lib/net/ssh/authentication/certificate.rb b/lib/net/ssh/authentication/certificate.rb index 310ad7d..28fbe71 100644 --- a/lib/net/ssh/authentication/certificate.rb +++ b/lib/net/ssh/authentication/certificate.rb @@ -125,6 +125,7 @@ module Net def self.type_symbol(type) types = { 1 => :user, 2 => :host } raise ArgumentError("unsupported type: #{type}") unless types.include?(type) + types.fetch(type) end private_class_method :type_symbol @@ -134,6 +135,7 @@ module Net def type_value(type) types = { user: 1, host: 2 } raise ArgumentError("unsupported type: #{type}") unless types.include?(type) + types.fetch(type) end diff --git a/lib/net/ssh/authentication/constants.rb b/lib/net/ssh/authentication/constants.rb index d0b88b0..8976aed 100644 --- a/lib/net/ssh/authentication/constants.rb +++ b/lib/net/ssh/authentication/constants.rb @@ -1,7 +1,6 @@ module Net module SSH module Authentication - # Describes the constants used by the Net::SSH::Authentication components # of the Net::SSH library. Individual authentication method implemenations # may define yet more constants that are specific to their implementation. diff --git a/lib/net/ssh/authentication/ed25519.rb b/lib/net/ssh/authentication/ed25519.rb index 5e047ec..1da9389 100644 --- a/lib/net/ssh/authentication/ed25519.rb +++ b/lib/net/ssh/authentication/ed25519.rb @@ -44,9 +44,11 @@ module Net datafull = datafull.strip raise ArgumentError.new("Expected #{MBEGIN} at start of private key") unless datafull.start_with?(MBEGIN) raise ArgumentError.new("Expected #{MEND} at end of private key") unless datafull.end_with?(MEND) + datab64 = datafull[MBEGIN.size...-MEND.size] data = Base64.decode64(datab64) raise ArgumentError.new("Expected #{MAGIC} at start of decoded private key") unless data.start_with?(MAGIC) + buffer = Net::SSH::Buffer.new(data[MAGIC.size + 1..-1]) ciphername = buffer.read_string @@ -59,6 +61,7 @@ module Net kdfopts = Net::SSH::Buffer.new(buffer.read_string) num_keys = buffer.read_long raise ArgumentError.new("Only 1 key is supported in ssh keys #{num_keys} was in private key") unless num_keys == 1 + _pubkey = buffer.read_string len = buffer.read_long @@ -72,6 +75,7 @@ module Net rounds = kdfopts.read_long raise "BCryptPbkdf is not implemented for jruby" if RUBY_PLATFORM == "java" + key = BCryptPbkdf::key(password, salt, keylen + ivlen, rounds) else key = '\x00' * (keylen + ivlen) diff --git a/lib/net/ssh/authentication/ed25519_loader.rb b/lib/net/ssh/authentication/ed25519_loader.rb index bcf920d..08ccd94 100644 --- a/lib/net/ssh/authentication/ed25519_loader.rb +++ b/lib/net/ssh/authentication/ed25519_loader.rb @@ -1,7 +1,6 @@ module Net module SSH module Authentication - # Loads ED25519 support which requires optinal dependecies like # ed25519, bcrypt_pbkdf module ED25519Loader diff --git a/lib/net/ssh/authentication/key_manager.rb b/lib/net/ssh/authentication/key_manager.rb index 8113ee3..d41eed8 100644 --- a/lib/net/ssh/authentication/key_manager.rb +++ b/lib/net/ssh/authentication/key_manager.rb @@ -6,7 +6,6 @@ require 'net/ssh/authentication/agent' module Net module SSH module Authentication - # A trivial exception class used to report errors in the key manager. class KeyManagerError < Net::SSH::Exception; end @@ -177,6 +176,7 @@ module Net if info[:from] == :agent raise KeyManagerError, "the agent is no longer available" unless agent + return agent.sign(info[:identity], data.to_s) end @@ -201,6 +201,7 @@ module Net # or if the agent is otherwise not available. def agent return unless use_agent? + @agent ||= Agent.connect(logger, options[:agent_socket_factory], options[:identity_agent]) rescue AgentNotAvailable @use_agent = false diff --git a/lib/net/ssh/authentication/methods/abstract.rb b/lib/net/ssh/authentication/methods/abstract.rb index bcddd4f..ec35043 100644 --- a/lib/net/ssh/authentication/methods/abstract.rb +++ b/lib/net/ssh/authentication/methods/abstract.rb @@ -7,7 +7,6 @@ module Net module SSH module Authentication module Methods - # The base class of all user authentication methods. It provides a few # bits of common functionality. class Abstract diff --git a/lib/net/ssh/authentication/methods/hostbased.rb b/lib/net/ssh/authentication/methods/hostbased.rb index a4afbb4..c4cd4cb 100644 --- a/lib/net/ssh/authentication/methods/hostbased.rb +++ b/lib/net/ssh/authentication/methods/hostbased.rb @@ -4,7 +4,6 @@ module Net module SSH module Authentication module Methods - # Implements the host-based SSH authentication method. class Hostbased < Abstract include Constants @@ -67,7 +66,6 @@ module Net Buffer.from(:key, identity).to_s, hostname, client_username).to_s end end - end end end diff --git a/lib/net/ssh/authentication/methods/keyboard_interactive.rb b/lib/net/ssh/authentication/methods/keyboard_interactive.rb index 7652b21..c241eda 100644 --- a/lib/net/ssh/authentication/methods/keyboard_interactive.rb +++ b/lib/net/ssh/authentication/methods/keyboard_interactive.rb @@ -5,7 +5,6 @@ module Net module SSH module Authentication module Methods - # Implements the "keyboard-interactive" SSH authentication method. class KeyboardInteractive < Abstract USERAUTH_INFO_REQUEST = 60 @@ -32,6 +31,7 @@ module Net message[:authentications].split(/,/).include? 'keyboard-interactive' return false unless interactive? + password = nil debug { "retrying keyboard-interactive" } send_message(userauth_request(username, next_service, "keyboard-interactive", "", "")) diff --git a/lib/net/ssh/authentication/methods/none.rb b/lib/net/ssh/authentication/methods/none.rb index d583b7d..c1184e1 100644 --- a/lib/net/ssh/authentication/methods/none.rb +++ b/lib/net/ssh/authentication/methods/none.rb @@ -5,7 +5,6 @@ module Net module SSH module Authentication module Methods - # Implements the "none" SSH authentication method. class None < Abstract # Attempt to authenticate as "none" @@ -30,7 +29,6 @@ module Net end end - end end end diff --git a/lib/net/ssh/authentication/methods/password.rb b/lib/net/ssh/authentication/methods/password.rb index e18edee..9cb1828 100644 --- a/lib/net/ssh/authentication/methods/password.rb +++ b/lib/net/ssh/authentication/methods/password.rb @@ -6,7 +6,6 @@ module Net module SSH module Authentication module Methods - # Implements the "password" SSH authentication method. class Password < Abstract # Attempt to authenticate the given user for the given service. If @@ -29,6 +28,7 @@ module Net raise Net::SSH::Authentication::DisallowedMethod unless message[:authentications].split(/,/).include? 'password' + password = nil end end until (message.type != USERAUTH_FAILURE || retries >= max_retries) @@ -74,7 +74,6 @@ module Net options[:non_interactive] ? 0 : result end end - end end end diff --git a/lib/net/ssh/authentication/methods/publickey.rb b/lib/net/ssh/authentication/methods/publickey.rb index bff9ffd..65e5dca 100644 --- a/lib/net/ssh/authentication/methods/publickey.rb +++ b/lib/net/ssh/authentication/methods/publickey.rb @@ -6,7 +6,6 @@ module Net module SSH module Authentication module Methods - # Implements the "publickey" SSH authentication method. class Publickey < Abstract # Attempts to perform public-key authentication for the given @@ -90,7 +89,6 @@ module Net end end end - end end end diff --git a/lib/net/ssh/authentication/pageant.rb b/lib/net/ssh/authentication/pageant.rb index a79802b..f3de568 100644 --- a/lib/net/ssh/authentication/pageant.rb +++ b/lib/net/ssh/authentication/pageant.rb @@ -24,7 +24,6 @@ require 'net/ssh/errors' module Net module SSH module Authentication - # This module encapsulates the implementation of a socket factory that # uses the PuTTY "pageant" utility to obtain information about SSH # identities. @@ -285,6 +284,7 @@ module Net first = ptr.ptr.to_i second = ptr_to_s(ptr,Win::SIZEOF_DWORD).unpack('L')[0] raise "Error" unless first == second + first end @@ -421,10 +421,12 @@ module Net while true return ret if @input_buffer.length < 4 + msg_length = @input_buffer.read_long + 4 @input_buffer.reset! return ret if @input_buffer.length < msg_length + msg = @input_buffer.read!(msg_length) @output_buffer.append(send_query(msg)) end @@ -491,7 +493,6 @@ module Net end end end - end end end diff --git a/lib/net/ssh/authentication/session.rb b/lib/net/ssh/authentication/session.rb index 95f4d95..4451cde 100644 --- a/lib/net/ssh/authentication/session.rb +++ b/lib/net/ssh/authentication/session.rb @@ -11,7 +11,6 @@ require 'net/ssh/authentication/methods/keyboard_interactive' module Net module SSH module Authentication - # Raised if the current authentication method is not allowed class DisallowedMethod < Net::SSH::Exception end @@ -71,6 +70,7 @@ module Net @auth_methods.each do |name| next unless @allowed_auth_methods.include?(name) + attempted << name debug { "trying #{name}" } @@ -127,6 +127,7 @@ module Net def expect_message(type) message = next_message raise Net::SSH::Exception, "expected #{type}, got #{message.type} (#{message})" unless message.type == type + message end diff --git a/lib/net/ssh/buffer.rb b/lib/net/ssh/buffer.rb index 0fe4e56..b27fc5d 100644 --- a/lib/net/ssh/buffer.rb +++ b/lib/net/ssh/buffer.rb @@ -5,7 +5,6 @@ require 'net/ssh/authentication/ed25519_loader' module Net module SSH - # Net::SSH::Buffer is a flexible class for building and parsing binary # data packets. It provides a stream-like interface for sequentially # reading data items from the buffer, as well as a useful helper method @@ -237,6 +236,7 @@ module Net def read_bignum data = read_string return unless data + OpenSSL::BN.new(data, 2) end diff --git a/lib/net/ssh/buffered_io.rb b/lib/net/ssh/buffered_io.rb index 54a4889..d974a1d 100644 --- a/lib/net/ssh/buffered_io.rb +++ b/lib/net/ssh/buffered_io.rb @@ -3,7 +3,6 @@ require 'net/ssh/loggable' module Net module SSH - # This module is used to extend sockets and other IO objects, to allow # them to be buffered for both read and write. This abstraction makes it # quite easy to write a select-based event loop @@ -115,6 +114,7 @@ module Net while output.length > 0 result = IO.select(nil, [self]) or next next unless result[1].any? + send_pending end end @@ -198,6 +198,5 @@ module Net end end end - end end diff --git a/lib/net/ssh/config.rb b/lib/net/ssh/config.rb index f333ee8..6aac71a 100644 --- a/lib/net/ssh/config.rb +++ b/lib/net/ssh/config.rb @@ -1,6 +1,5 @@ module Net module SSH - # The Net::SSH::Config class is used to parse OpenSSH configuration files, # and translates that syntax into the configuration syntax that Net::SSH # understands. This lets Net::SSH scripts read their configuration (to diff --git a/lib/net/ssh/connection/channel.rb b/lib/net/ssh/connection/channel.rb index 9a408b2..835d72f 100644 --- a/lib/net/ssh/connection/channel.rb +++ b/lib/net/ssh/connection/channel.rb @@ -5,7 +5,6 @@ require 'net/ssh/connection/term' module Net module SSH module Connection - # The channel abstraction. Multiple "channels" can be multiplexed onto a # single SSH channel, each operating independently and seemingly in parallel. # This class represents a single such channel. Most operations performed @@ -251,6 +250,7 @@ module Net # channel.send_data("the password\n") def send_data(data) raise EOFError, "cannot send data if channel has declared eof" if eof? + output.append(data.to_s) end @@ -298,6 +298,7 @@ module Net # the CHANNEL_CLOSE message will be sent from event loop def close return if @closing + @closing = true end @@ -313,6 +314,7 @@ module Net # The CHANNEL_EOF packet will be sent once the output buffer is empty. def eof! return if eof? + @eof = true end @@ -486,6 +488,7 @@ module Net def send_channel_request(request_name, *data, &callback) info { "sending channel request #{request_name.inspect}" } fail "Channel open not yet confirmed, please call send_channel_request(or exec) from block of open_channel" unless remote_id + msg = Buffer.from(:byte, CHANNEL_REQUEST, :long, remote_id, :string, request_name, :bool, !callback.nil?, *data) @@ -687,7 +690,6 @@ module Net env.each { |key, value| self.env(key, value) } end end - end end end diff --git a/lib/net/ssh/connection/constants.rb b/lib/net/ssh/connection/constants.rb index a2b0257..5370fa8 100644 --- a/lib/net/ssh/connection/constants.rb +++ b/lib/net/ssh/connection/constants.rb @@ -1,11 +1,9 @@ module Net module SSH module Connection - # Definitions of constants that are specific to the connection layer of the # SSH protocol. module Constants - #-- # Connection protocol generic messages #++ @@ -29,9 +27,7 @@ module Net CHANNEL_REQUEST = 98 CHANNEL_SUCCESS = 99 CHANNEL_FAILURE = 100 - end - end end end diff --git a/lib/net/ssh/connection/event_loop.rb b/lib/net/ssh/connection/event_loop.rb index cd9d3f1..56085cf 100644 --- a/lib/net/ssh/connection/event_loop.rb +++ b/lib/net/ssh/connection/event_loop.rb @@ -36,6 +36,7 @@ module Net begin @sessions = [session] return false unless ev_preprocess + ev_select_and_postprocess(wait) ensure @sessions = orig_sessions @@ -46,8 +47,10 @@ module Net # block retuns false then we exit the processing def ev_preprocess(&block) return false if block_given? && !yield(self) + @sessions.each(&:ev_preprocess) return false if block_given? && !yield(self) + return true end @@ -97,13 +100,16 @@ module Net # we call block with session as argument def ev_preprocess(&block) return false if block_given? && !yield(@sessions.first) + @sessions.each(&:ev_preprocess) return false if block_given? && !yield(@sessions.first) + return true end def ev_select_and_postprocess(wait) raise "Only one session expected" unless @sessions.count == 1 + session = @sessions.first sr,sw,actwait = session.ev_do_calculate_rw_wait(wait) readers, writers, = IO.select(sr, sw, nil, actwait) diff --git a/lib/net/ssh/connection/keepalive.rb b/lib/net/ssh/connection/keepalive.rb index fb9be05..8926ba5 100644 --- a/lib/net/ssh/connection/keepalive.rb +++ b/lib/net/ssh/connection/keepalive.rb @@ -2,7 +2,6 @@ require 'net/ssh/loggable' module Net module SSH module Connection - class Keepalive include Loggable @@ -28,6 +27,7 @@ module Net def should_send? return false unless enabled? return true unless @last_keepalive_sent_at + Time.now - @last_keepalive_sent_at >= interval end @@ -38,6 +38,7 @@ module Net def send_as_needed(was_events) return if was_events return unless should_send? + info { "sending keepalive #{@unresponded_keepalive_count}" } @unresponded_keepalive_count += 1 @@ -53,7 +54,6 @@ module Net end end end - end end end diff --git a/lib/net/ssh/connection/session.rb b/lib/net/ssh/connection/session.rb index 61abd76..874b23f 100644 --- a/lib/net/ssh/connection/session.rb +++ b/lib/net/ssh/connection/session.rb @@ -8,7 +8,6 @@ require 'net/ssh/connection/event_loop' module Net module SSH module Connection - # A session class representing the connection service running on top of # the SSH transport layer. It manages the creation of channels (see # #open_channel), and the dispatching of messages to the various channels. @@ -237,8 +236,10 @@ module Net # false, this method returns false. Otherwise, it returns true. def preprocess(&block) return false if block_given? && !yield(self) + ev_preprocess(&block) return false if block_given? && !yield(self) + return true end @@ -702,10 +703,10 @@ module Net MAP = Constants.constants.each_with_object({}) do |name, memo| value = const_get(name) next unless Integer === value + memo[value] = name.downcase.to_sym end end - end end end diff --git a/lib/net/ssh/connection/term.rb b/lib/net/ssh/connection/term.rb index 5b5a7de..ef32910 100644 --- a/lib/net/ssh/connection/term.rb +++ b/lib/net/ssh/connection/term.rb @@ -176,7 +176,6 @@ module Net # Specifies the output baud rate in bits per second. TTY_OP_OSPEED = 129 end - end end end diff --git a/lib/net/ssh/key_factory.rb b/lib/net/ssh/key_factory.rb index 04dac98..c8df306 100644 --- a/lib/net/ssh/key_factory.rb +++ b/lib/net/ssh/key_factory.rb @@ -5,7 +5,6 @@ require 'net/ssh/authentication/ed25519_loader' module Net module SSH - # A factory class for returning new Key classes. It is used for obtaining # OpenSSL key instances via their SSH names, and for loading both public and # private keys. It used used primarily by Net::SSH itself, internally, and diff --git a/lib/net/ssh/known_hosts.rb b/lib/net/ssh/known_hosts.rb index 166e208..f3d773a 100644 --- a/lib/net/ssh/known_hosts.rb +++ b/lib/net/ssh/known_hosts.rb @@ -6,7 +6,6 @@ require 'net/ssh/authentication/ed25519_loader' module Net module SSH - # Represents the result of a search in known hosts # see search_for class HostKeys diff --git a/lib/net/ssh/loggable.rb b/lib/net/ssh/loggable.rb index b9df4d5..15ea750 100644 --- a/lib/net/ssh/loggable.rb +++ b/lib/net/ssh/loggable.rb @@ -1,6 +1,5 @@ module Net module SSH - # A simple module to make logging easier to deal with. It assumes that the # logger instance (if not nil) quacks like a Logger object (in Ruby's # standard library). Although used primarily internally by Net::SSH, it diff --git a/lib/net/ssh/packet.rb b/lib/net/ssh/packet.rb index a379586..cc762ca 100644 --- a/lib/net/ssh/packet.rb +++ b/lib/net/ssh/packet.rb @@ -5,7 +5,6 @@ require 'net/ssh/connection/constants' module Net module SSH - # A specialization of Buffer that knows the format of certain common # packet types. It auto-parses those packet types, and allows them to # be accessed via the #[] accessor. @@ -85,6 +84,7 @@ module Net def [](name) name = name.to_sym raise ArgumentError, "no such element #{name}" unless @named_elements.key?(name) + @named_elements[name] end diff --git a/lib/net/ssh/prompt.rb b/lib/net/ssh/prompt.rb index 3b9fdac..98715c5 100644 --- a/lib/net/ssh/prompt.rb +++ b/lib/net/ssh/prompt.rb @@ -2,7 +2,6 @@ require 'io/console' module Net module SSH - # Default prompt implementation, called for asking password from user. # It will never be instantiated directly, but will instead be created for # you automatically. @@ -59,6 +58,5 @@ module Net Prompter.new(info) end end - end end diff --git a/lib/net/ssh/proxy/command.rb b/lib/net/ssh/proxy/command.rb index 1bb2423..d6a89dd 100644 --- a/lib/net/ssh/proxy/command.rb +++ b/lib/net/ssh/proxy/command.rb @@ -5,7 +5,6 @@ require 'net/ssh/proxy/errors' module Net module SSH module Proxy - # An implementation of a command proxy. To use it, instantiate it, # then pass the instantiated object via the :proxy key to # Net::SSH.start: @@ -105,6 +104,7 @@ module Net if IO.select([self], nil, [self], timeout_in_seconds) == nil raise "Unexpected spurious read wakeup" end + retry end result diff --git a/lib/net/ssh/proxy/errors.rb b/lib/net/ssh/proxy/errors.rb index bbaf5dd..d7e5458 100644 --- a/lib/net/ssh/proxy/errors.rb +++ b/lib/net/ssh/proxy/errors.rb @@ -3,7 +3,6 @@ require 'net/ssh/errors' module Net module SSH module Proxy - # A general exception class for all Proxy errors. class Error < Net::SSH::Exception; end @@ -12,7 +11,6 @@ module Net # Used when the server doesn't recognize the user's credentials. class UnauthorizedError < Error; end - end end end diff --git a/lib/net/ssh/proxy/http.rb b/lib/net/ssh/proxy/http.rb index 1cfaa62..cf94634 100644 --- a/lib/net/ssh/proxy/http.rb +++ b/lib/net/ssh/proxy/http.rb @@ -4,7 +4,6 @@ require 'net/ssh/proxy/errors' module Net module SSH module Proxy - # An implementation of an HTTP proxy. To use it, instantiate it, then # pass the instantiated object via the :proxy key to Net::SSH.start: # @@ -94,7 +93,6 @@ module Net body: body } end end - end end end diff --git a/lib/net/ssh/proxy/https.rb b/lib/net/ssh/proxy/https.rb index 298d537..a0da2a4 100644 --- a/lib/net/ssh/proxy/https.rb +++ b/lib/net/ssh/proxy/https.rb @@ -6,7 +6,6 @@ require 'net/ssh/proxy/http' module Net module SSH module Proxy - # A specialization of the HTTP proxy which encrypts the whole connection # using OpenSSL. This has the advantage that proxy authentication # information is not sent in plaintext. @@ -46,7 +45,6 @@ module Net end end end - end end end diff --git a/lib/net/ssh/proxy/jump.rb b/lib/net/ssh/proxy/jump.rb index ab67e84..b92dcdc 100644 --- a/lib/net/ssh/proxy/jump.rb +++ b/lib/net/ssh/proxy/jump.rb @@ -4,7 +4,6 @@ require 'net/ssh/proxy/command' module Net module SSH module Proxy - # An implementation of a jump proxy. To use it, instantiate it, # then pass the instantiated object via the :proxy key to # Net::SSH.start: @@ -50,7 +49,6 @@ module Net @command_line_template = template end end - end end end diff --git a/lib/net/ssh/proxy/socks4.rb b/lib/net/ssh/proxy/socks4.rb index eac35b0..ddd95b0 100644 --- a/lib/net/ssh/proxy/socks4.rb +++ b/lib/net/ssh/proxy/socks4.rb @@ -6,7 +6,6 @@ require 'net/ssh/proxy/errors' module Net module SSH module Proxy - # An implementation of a SOCKS4 proxy. To use it, instantiate it, then # pass the instantiated object via the :proxy key to Net::SSH.start: # @@ -63,7 +62,6 @@ module Net return socket end end - end end end diff --git a/lib/net/ssh/proxy/socks5.rb b/lib/net/ssh/proxy/socks5.rb index 08f2a3c..77300cd 100644 --- a/lib/net/ssh/proxy/socks5.rb +++ b/lib/net/ssh/proxy/socks5.rb @@ -4,7 +4,6 @@ require 'net/ssh/proxy/errors' module Net module SSH module Proxy - # An implementation of a SOCKS5 proxy. To use it, instantiate it, then # pass the instantiated object via the :proxy key to Net::SSH.start: # @@ -136,7 +135,6 @@ module Net end end end - end end end diff --git a/lib/net/ssh/service/forward.rb b/lib/net/ssh/service/forward.rb index 4bb3ae6..bcffc67 100644 --- a/lib/net/ssh/service/forward.rb +++ b/lib/net/ssh/service/forward.rb @@ -3,7 +3,6 @@ require 'net/ssh/loggable' module Net module SSH module Service - # This class implements various port forwarding services for use by # Net::SSH clients. The Forward class should never need to be instantiated # directly; instead, it should be accessed via the singleton instance @@ -290,6 +289,7 @@ module Net # end def agent(channel) return if @agent_forwarded + @agent_forwarded = true channel.send_channel_request("auth-agent-req@openssh.com") do |achannel, success| @@ -420,7 +420,6 @@ module Net end end end - end end end diff --git a/lib/net/ssh/test.rb b/lib/net/ssh/test.rb index 47b5db4..d97eebf 100644 --- a/lib/net/ssh/test.rb +++ b/lib/net/ssh/test.rb @@ -5,7 +5,6 @@ require 'net/ssh/test/socket' module Net module SSH - # This module may be used in unit tests, for when you want to test that your # SSH state machines are really doing what you expect they are doing. You will # typically include this module in your unit test class, and then build a @@ -85,11 +84,11 @@ module Net # the block passed to this assertion. def assert_scripted raise "there is no script to be processed" if socket.script.events.empty? + Net::SSH::Test::Extensions::IO.with_test_extension { yield } assert socket.script.events.empty?, "there should not be any remaining scripted events, but there are still" \ "#{socket.script.events.length} pending" end end - end end diff --git a/lib/net/ssh/test/channel.rb b/lib/net/ssh/test/channel.rb index 7cebb9a..9a46ab3 100644 --- a/lib/net/ssh/test/channel.rb +++ b/lib/net/ssh/test/channel.rb @@ -1,7 +1,6 @@ module Net module SSH module Test - # A mock channel, used for scripting actions in tests. It wraps a # Net::SSH::Test::Script instance, and delegates to it for the most part. # This class has little real functionality on its own, but rather acts as @@ -143,7 +142,6 @@ module Net script.gets_channel_close(self) end end - end end end diff --git a/lib/net/ssh/test/extensions.rb b/lib/net/ssh/test/extensions.rb index 5090f6c..91bb2d6 100644 --- a/lib/net/ssh/test/extensions.rb +++ b/lib/net/ssh/test/extensions.rb @@ -9,7 +9,6 @@ require 'net/ssh/transport/packet_stream' module Net module SSH module Test - # A collection of modules used to extend/override the default behavior of # Net::SSH internals for ease of testing. As a consumer of Net::SSH, you'll # never need to use this directly--they're all used under the covers by @@ -70,6 +69,7 @@ module Net # Returns true if there is data pending to be read. Otherwise calls #idle!. def test_available_for_read? return true if select_for_read? + idle! false end @@ -85,6 +85,7 @@ module Net # Reads the next available packet from the IO object and returns it. def test_poll_next_packet return nil if available <= 0 + packet = Net::SSH::Buffer.new(read_available(4)) length = packet.read_long Net::SSH::Packet.new(read_available(length)) @@ -144,6 +145,7 @@ module Net # that mix in Net::SSH::Test::Extensions::BufferedIo. def select_for_test(readers=nil, writers=nil, errors=nil, wait=nil) return select_for_real(readers, writers, errors, wait) unless Net::SSH::Test::Extensions::IO.extension_enabled? + ready_readers = Array(readers).select { |r| r.select_for_read? } ready_writers = Array(writers).select { |r| r.select_for_write? } ready_errors = Array(errors).select { |r| r.select_for_error? } @@ -162,7 +164,6 @@ module Net end end end - end end end diff --git a/lib/net/ssh/test/kex.rb b/lib/net/ssh/test/kex.rb index 415f841..e8a0392 100644 --- a/lib/net/ssh/test/kex.rb +++ b/lib/net/ssh/test/kex.rb @@ -8,7 +8,6 @@ require 'net/ssh/transport/kex' module Net module SSH module Test - # An implementation of a key-exchange strategy specifically for unit tests. # (This strategy would never really work against a real SSH server--it makes # too many assumptions about the server's response.) @@ -39,7 +38,6 @@ module Net hashing_algorithm: OpenSSL::Digest::SHA1 } end end - end end end diff --git a/lib/net/ssh/test/local_packet.rb b/lib/net/ssh/test/local_packet.rb index 998edb7..edcdd48 100644 --- a/lib/net/ssh/test/local_packet.rb +++ b/lib/net/ssh/test/local_packet.rb @@ -4,7 +4,6 @@ require 'net/ssh/test/packet' module Net module SSH module Test - # This is a specialization of Net::SSH::Test::Packet for representing mock # packets that are sent from the local (client) host. These are created # automatically by Net::SSH::Test::Script and Net::SSH::Test::Channel by any @@ -49,7 +48,6 @@ module Net end end end - end end end diff --git a/lib/net/ssh/test/packet.rb b/lib/net/ssh/test/packet.rb index d2d6f27..e604b98 100644 --- a/lib/net/ssh/test/packet.rb +++ b/lib/net/ssh/test/packet.rb @@ -4,7 +4,6 @@ require 'net/ssh/transport/constants' module Net module SSH module Test - # This is an abstract class, not to be instantiated directly, subclassed by # Net::SSH::Test::LocalPacket and Net::SSH::Test::RemotePacket. It implements # functionality common to those subclasses. @@ -90,6 +89,7 @@ module Net else request = Packet.registered_channel_requests(@data[1]) raise "don't know what to do about #{@data[1]} channel request" unless request + parts.concat(request[:extra_parts]) end else raise "don't know how to parse packet type #{@type}" diff --git a/lib/net/ssh/test/remote_packet.rb b/lib/net/ssh/test/remote_packet.rb index e2c6903..34051f1 100644 --- a/lib/net/ssh/test/remote_packet.rb +++ b/lib/net/ssh/test/remote_packet.rb @@ -4,7 +4,6 @@ require 'net/ssh/test/packet' module Net module SSH module Test - # This is a specialization of Net::SSH::Test::Packet for representing mock # packets that are received by the local (client) host. These are created # automatically by Net::SSH::Test::Script and Net::SSH::Test::Channel by any @@ -36,7 +35,6 @@ module Net end end end - end end end diff --git a/lib/net/ssh/test/script.rb b/lib/net/ssh/test/script.rb index 6200bf1..e7cef09 100644 --- a/lib/net/ssh/test/script.rb +++ b/lib/net/ssh/test/script.rb @@ -5,7 +5,6 @@ require 'net/ssh/test/remote_packet' module Net module SSH module Test - # Represents a sequence of scripted events that identify the behavior that # a test expects. Methods named "sends_*" create events for packets being # sent from the local to the remote host, and methods named "gets_*" create @@ -176,7 +175,6 @@ module Net event.process(packet) end end - end end end diff --git a/lib/net/ssh/test/socket.rb b/lib/net/ssh/test/socket.rb index 57fe8f6..c5e781f 100644 --- a/lib/net/ssh/test/socket.rb +++ b/lib/net/ssh/test/socket.rb @@ -6,7 +6,6 @@ require 'net/ssh/test/script' module Net module SSH module Test - # A mock socket implementation for use in testing. It implements the minimum # necessary interface for interacting with the rest of the Net::SSH::Test # system. @@ -62,7 +61,6 @@ module Net end end - end end end diff --git a/lib/net/ssh/transport/cipher_factory.rb b/lib/net/ssh/transport/cipher_factory.rb index 8adc851..da3317f 100644 --- a/lib/net/ssh/transport/cipher_factory.rb +++ b/lib/net/ssh/transport/cipher_factory.rb @@ -6,7 +6,6 @@ require 'net/ssh/transport/identity_cipher' module Net module SSH module Transport - # Implements a factory of OpenSSL cipher algorithms. class CipherFactory # Maps the SSH name of a cipher to it's corresponding OpenSSL name @@ -35,6 +34,7 @@ module Net def self.supported?(name) ossl_name = SSH_TO_OSSL[name] or raise NotImplementedError, "unimplemented cipher `#{name}'" return true if ossl_name == "none" + return OpenSSL::Cipher.ciphers.include?(ossl_name) end @@ -46,6 +46,7 @@ module Net def self.get(name, options={}) ossl_name = SSH_TO_OSSL[name] or raise NotImplementedError, "unimplemented cipher `#{name}'" return IdentityCipher if ossl_name == "none" + cipher = OpenSSL::Cipher.new(ossl_name) cipher.send(options[:encrypt] ? :encrypt : :decrypt) @@ -97,7 +98,6 @@ module Net result end end - end end end diff --git a/lib/net/ssh/transport/hmac/abstract.rb b/lib/net/ssh/transport/hmac/abstract.rb index f8efa3e..575b03b 100644 --- a/lib/net/ssh/transport/hmac/abstract.rb +++ b/lib/net/ssh/transport/hmac/abstract.rb @@ -5,7 +5,6 @@ module Net module SSH module Transport module HMAC - # The base class of all OpenSSL-based HMAC algorithm wrappers. class Abstract class <<self diff --git a/lib/net/ssh/transport/hmac/md5.rb b/lib/net/ssh/transport/hmac/md5.rb index 66b78ca..549b1aa 100644 --- a/lib/net/ssh/transport/hmac/md5.rb +++ b/lib/net/ssh/transport/hmac/md5.rb @@ -1,12 +1,10 @@ require 'net/ssh/transport/hmac/abstract' module Net::SSH::Transport::HMAC - # The MD5 HMAC algorithm. class MD5 < Abstract mac_length 16 key_length 16 digest_class OpenSSL::Digest::MD5 end - end diff --git a/lib/net/ssh/transport/hmac/md5_96.rb b/lib/net/ssh/transport/hmac/md5_96.rb index 826b70a..6dbebc1 100644 --- a/lib/net/ssh/transport/hmac/md5_96.rb +++ b/lib/net/ssh/transport/hmac/md5_96.rb @@ -1,11 +1,9 @@ require 'net/ssh/transport/hmac/md5' module Net::SSH::Transport::HMAC - # The MD5-96 HMAC algorithm. This returns only the first 12 bytes of # the digest. class MD5_96 < MD5 mac_length 12 end - end diff --git a/lib/net/ssh/transport/hmac/none.rb b/lib/net/ssh/transport/hmac/none.rb index 191373e..a5e3af4 100644 --- a/lib/net/ssh/transport/hmac/none.rb +++ b/lib/net/ssh/transport/hmac/none.rb @@ -1,7 +1,6 @@ require 'net/ssh/transport/hmac/abstract' module Net::SSH::Transport::HMAC - # The "none" algorithm. This has a key and mac length of 0. class None < Abstract key_length 0 @@ -11,5 +10,4 @@ module Net::SSH::Transport::HMAC "" end end - end diff --git a/lib/net/ssh/transport/hmac/ripemd160.rb b/lib/net/ssh/transport/hmac/ripemd160.rb index a77e4cd..4c9cdd7 100644 --- a/lib/net/ssh/transport/hmac/ripemd160.rb +++ b/lib/net/ssh/transport/hmac/ripemd160.rb @@ -1,7 +1,6 @@ require 'net/ssh/transport/hmac/abstract' module Net::SSH::Transport::HMAC - # The RIPEMD-160 HMAC algorithm. This has a mac and key length of 20, and # uses the RIPEMD-160 digest algorithm. class RIPEMD160 < Abstract @@ -9,5 +8,4 @@ module Net::SSH::Transport::HMAC key_length 20 digest_class OpenSSL::Digest::RIPEMD160 end - end diff --git a/lib/net/ssh/transport/hmac/sha1.rb b/lib/net/ssh/transport/hmac/sha1.rb index b40d32f..9208392 100644 --- a/lib/net/ssh/transport/hmac/sha1.rb +++ b/lib/net/ssh/transport/hmac/sha1.rb @@ -1,7 +1,6 @@ require 'net/ssh/transport/hmac/abstract' module Net::SSH::Transport::HMAC - # The SHA1 HMAC algorithm. This has a mac and key length of 20, and # uses the SHA1 digest algorithm. class SHA1 < Abstract @@ -9,5 +8,4 @@ module Net::SSH::Transport::HMAC key_length 20 digest_class OpenSSL::Digest::SHA1 end - end diff --git a/lib/net/ssh/transport/hmac/sha1_96.rb b/lib/net/ssh/transport/hmac/sha1_96.rb index 6b0b3c2..e1631e7 100644 --- a/lib/net/ssh/transport/hmac/sha1_96.rb +++ b/lib/net/ssh/transport/hmac/sha1_96.rb @@ -1,11 +1,9 @@ require 'net/ssh/transport/hmac/sha1' module Net::SSH::Transport::HMAC - # The SHA1-96 HMAC algorithm. This returns only the first 12 bytes of # the digest. class SHA1_96 < SHA1 mac_length 12 end - end diff --git a/lib/net/ssh/transport/identity_cipher.rb b/lib/net/ssh/transport/identity_cipher.rb index c690e9f..a23c85c 100644 --- a/lib/net/ssh/transport/identity_cipher.rb +++ b/lib/net/ssh/transport/identity_cipher.rb @@ -1,7 +1,6 @@ module Net module SSH module Transport - # A cipher that does nothing but pass the data through, unchanged. This # keeps things in the code nice and clean when a cipher has not yet been # determined (i.e., during key exchange). @@ -53,7 +52,6 @@ module Net end end end - end end end diff --git a/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb b/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb index bd5e4a9..e081669 100644 --- a/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +++ b/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb @@ -69,5 +69,4 @@ module Net::SSH::Transport::Kex response end end - end diff --git a/lib/net/ssh/transport/openssl.rb b/lib/net/ssh/transport/openssl.rb index 7b16c3d..e10792c 100644 --- a/lib/net/ssh/transport/openssl.rb +++ b/lib/net/ssh/transport/openssl.rb @@ -2,7 +2,6 @@ require 'openssl' require 'net/ssh/authentication/pub_key_fingerprint' module OpenSSL - # This class is originally defined in the OpenSSL module. As needed, methods # have been added to it by the Net::SSH module for convenience in dealing with # SSH functionality. @@ -24,7 +23,6 @@ module OpenSSL end module PKey - class PKey include Net::SSH::Authentication::PubKeyFingerprint end @@ -37,6 +35,7 @@ module OpenSSL # lifted more-or-less directly from OpenSSH, dh.c, dh_pub_is_valid.) def valid? return false if pub_key.nil? || pub_key < 0 + bits_set = 0 pub_key.num_bits.times { |i| bits_set += 1 if pub_key.bit_set?(i) } return (bits_set > 1 && pub_key < p) diff --git a/lib/net/ssh/transport/packet_stream.rb b/lib/net/ssh/transport/packet_stream.rb index 8b4032e..fc07ea1 100644 --- a/lib/net/ssh/transport/packet_stream.rb +++ b/lib/net/ssh/transport/packet_stream.rb @@ -8,7 +8,6 @@ require 'net/ssh/transport/state' module Net module SSH module Transport - # A module that builds additional functionality onto the Net::SSH::BufferedIo # module. It adds SSH encryption, compression, and packet validation, as # per the SSH2 protocol. It also adds an abstraction for polling packets, @@ -222,6 +221,7 @@ module Net if @packet.nil? minimum = server.block_size < 4 ? 4 : server.block_size return nil if available < minimum + aad_length + data = read_available(minimum + aad_length) # decipher it @@ -275,7 +275,6 @@ module Net end end # rubocop:enable Metrics/AbcSize - end end end diff --git a/lib/net/ssh/transport/server_version.rb b/lib/net/ssh/transport/server_version.rb index 1012685..ba37beb 100644 --- a/lib/net/ssh/transport/server_version.rb +++ b/lib/net/ssh/transport/server_version.rb @@ -5,7 +5,6 @@ require 'net/ssh/version' module Net module SSH module Transport - # Negotiates the SSH protocol version and trades information about server # and client. This is never used directly--it is always called by the # transport layer as part of the initialization process of the transport @@ -47,6 +46,7 @@ module Net socket.flush raise Net::SSH::ConnectionTimeout, "timeout during server version negotiating" if timeout && !IO.select([socket], nil, nil, timeout) + loop do @version = "" loop do @@ -60,6 +60,7 @@ module Net break if b == "\n" end break if @version.match(/^SSH-/) + @header << @version end diff --git a/lib/net/ssh/transport/session.rb b/lib/net/ssh/transport/session.rb index ce55a32..261e5c2 100644 --- a/lib/net/ssh/transport/session.rb +++ b/lib/net/ssh/transport/session.rb @@ -15,7 +15,6 @@ require 'net/ssh/verifiers/never' module Net module SSH module Transport - # The transport layer represents the lowest level of the SSH protocol, and # implements basic message exchanging and protocol initialization. It will # never be instantiated directly (unless you really know what you're about), @@ -160,6 +159,7 @@ module Net # one is performed, causing this method to block until it completes. def rekey_as_needed return if algorithms.pending? + socket.if_needs_rekey? { rekey! } end @@ -211,6 +211,7 @@ module Net else return packet if algorithms.allow?(packet) + push(packet) end end @@ -222,6 +223,7 @@ module Net def wait loop do break if block_given? && yield + message = poll_message(:nonblock, false) push(message) if message break if !block_given? diff --git a/lib/net/ssh/transport/state.rb b/lib/net/ssh/transport/state.rb index 07c509a..0eaa78a 100644 --- a/lib/net/ssh/transport/state.rb +++ b/lib/net/ssh/transport/state.rb @@ -5,7 +5,6 @@ require 'net/ssh/transport/hmac' module Net module SSH module Transport - # Encapsulates state information about one end of an SSH connection. Such # state includes the packet sequence number, the algorithms in use, how # many packets and blocks have been processed since the last reset, and so @@ -122,6 +121,7 @@ module Net def compress(data) data = data.to_s return data unless compression? + compressor.deflate(data, Zlib::SYNC_FLUSH) end @@ -130,6 +130,7 @@ module Net def decompress(data) data = data.to_s return data unless compression? + decompressor.inflate(data) end @@ -202,7 +203,6 @@ module Net return data end end - end end end diff --git a/lib/net/ssh/verifiers/accept_new.rb b/lib/net/ssh/verifiers/accept_new.rb index 677ee75..aa68ff2 100644 --- a/lib/net/ssh/verifiers/accept_new.rb +++ b/lib/net/ssh/verifiers/accept_new.rb @@ -5,7 +5,6 @@ require 'net/ssh/verifiers/always' module Net module SSH module Verifiers - # Does a strict host verification, looking the server up in the known # host files to see if a key has already been seen for this server. If this # server does not appear in any host file, this will silently add the @@ -29,7 +28,6 @@ module Net return true end end - end end end diff --git a/lib/net/ssh/verifiers/accept_new_or_local_tunnel.rb b/lib/net/ssh/verifiers/accept_new_or_local_tunnel.rb index d9f8589..198782d 100644 --- a/lib/net/ssh/verifiers/accept_new_or_local_tunnel.rb +++ b/lib/net/ssh/verifiers/accept_new_or_local_tunnel.rb @@ -3,7 +3,6 @@ require 'net/ssh/verifiers/accept_new' module Net module SSH module Verifiers - # Basically the same as the AcceptNew verifier, but does not try to actually # verify a connection if the server is the localhost and the port is a # nonstandard port number. Those two conditions will typically mean the @@ -14,6 +13,7 @@ module Net # returns true. Otherwise, performs the standard strict verification. def verify(arguments) return true if tunnelled?(arguments) + super end @@ -28,7 +28,6 @@ module Net return ip == "127.0.0.1" || ip == "::1" end end - end end end diff --git a/lib/net/ssh/verifiers/always.rb b/lib/net/ssh/verifiers/always.rb index b3ce944..0f52a29 100644 --- a/lib/net/ssh/verifiers/always.rb +++ b/lib/net/ssh/verifiers/always.rb @@ -4,7 +4,6 @@ require 'net/ssh/known_hosts' module Net module SSH module Verifiers - # Does a strict host verification, looking the server up in the known # host files to see if a key has already been seen for this server. If this # server does not appear in any host file, an exception will be raised @@ -50,7 +49,6 @@ module Net raise exception end end - end end end diff --git a/lib/net/ssh/verifiers/never.rb b/lib/net/ssh/verifiers/never.rb index 11fac1f..43ec072 100644 --- a/lib/net/ssh/verifiers/never.rb +++ b/lib/net/ssh/verifiers/never.rb @@ -1,7 +1,6 @@ module Net module SSH module Verifiers - # This host key verifier simply allows every key it sees, without # any verification. This is simple, but very insecure because it # exposes you to MiTM attacks. @@ -15,7 +14,6 @@ module Net true end end - end end end diff --git a/test/authentication/methods/common.rb b/test/authentication/methods/common.rb index 8cf2ca2..5546e1c 100644 --- a/test/authentication/methods/common.rb +++ b/test/authentication/methods/common.rb @@ -1,6 +1,5 @@ module Authentication module Methods - module Common include Net::SSH::Authentication::Constants @@ -31,6 +30,5 @@ module Authentication end end - end end diff --git a/test/authentication/methods/test_abstract.rb b/test/authentication/methods/test_abstract.rb index a839699..4f930a9 100644 --- a/test/authentication/methods/test_abstract.rb +++ b/test/authentication/methods/test_abstract.rb @@ -4,7 +4,6 @@ require 'net/ssh/authentication/methods/abstract' module Authentication module Methods - class TestAbstract < NetSSHTest include Common diff --git a/test/authentication/methods/test_hostbased.rb b/test/authentication/methods/test_hostbased.rb index 4fbd37a..5e4eb0f 100644 --- a/test/authentication/methods/test_hostbased.rb +++ b/test/authentication/methods/test_hostbased.rb @@ -4,7 +4,6 @@ require 'authentication/methods/common' module Authentication module Methods - class TestHostbased < NetSSHTest include Common @@ -57,6 +56,7 @@ module Authentication def signature_parameters(key) Proc.new do |given_key, data| next false unless given_key.to_blob == key.to_blob + buffer = Net::SSH::Buffer.new(data) buffer.read_string == "abcxyz123" && # session-id buffer.read_byte == USERAUTH_REQUEST && # type diff --git a/test/authentication/methods/test_keyboard_interactive.rb b/test/authentication/methods/test_keyboard_interactive.rb index 9fad914..e18f02c 100644 --- a/test/authentication/methods/test_keyboard_interactive.rb +++ b/test/authentication/methods/test_keyboard_interactive.rb @@ -4,7 +4,6 @@ require_relative 'common' module Authentication module Methods - class TestKeyboardInteractive < NetSSHTest include Common @@ -128,6 +127,5 @@ module Authentication subject(options) end end - end end diff --git a/test/authentication/methods/test_none.rb b/test/authentication/methods/test_none.rb index 8e31c08..223b33c 100644 --- a/test/authentication/methods/test_none.rb +++ b/test/authentication/methods/test_none.rb @@ -4,7 +4,6 @@ require 'authentication/methods/common' module Authentication module Methods - class TestNone < NetSSHTest include Common @@ -38,6 +37,5 @@ module Authentication @subject ||= Net::SSH::Authentication::Methods::None.new(session(options), options) end end - end end diff --git a/test/authentication/methods/test_password.rb b/test/authentication/methods/test_password.rb index d119fae..a5ddf85 100644 --- a/test/authentication/methods/test_password.rb +++ b/test/authentication/methods/test_password.rb @@ -5,7 +5,6 @@ require 'authentication/methods/common' module Authentication module Methods - class TestPassword < NetSSHTest include Common @@ -93,6 +92,5 @@ module Authentication @subject ||= Net::SSH::Authentication::Methods::Password.new(session(options), options) end end - end end diff --git a/test/authentication/methods/test_publickey.rb b/test/authentication/methods/test_publickey.rb index 8f2cc73..4f5765d 100644 --- a/test/authentication/methods/test_publickey.rb +++ b/test/authentication/methods/test_publickey.rb @@ -4,7 +4,6 @@ require 'authentication/methods/common' module Authentication module Methods - class TestPublickey < NetSSHTest include Common @@ -110,6 +109,7 @@ module Authentication def signature_parameters(key) Proc.new do |given_key, data| next false unless given_key.to_blob == key.to_blob + buffer = Net::SSH::Buffer.new(data) buffer.read_string == "abcxyz123" && # session-id buffer.read_byte == USERAUTH_REQUEST && # type diff --git a/test/authentication/test_agent.rb b/test/authentication/test_agent.rb index 9dea16e..3b4ef37 100644 --- a/test/authentication/test_agent.rb +++ b/test/authentication/test_agent.rb @@ -2,7 +2,6 @@ require_relative '../common' require 'net/ssh/authentication/agent' module Authentication - class TestAgent < NetSSHTest SSH2_AGENT_REQUEST_VERSION = 1 SSH2_AGENT_REQUEST_IDENTITIES = 11 @@ -322,6 +321,7 @@ module Authentication def test_add_ed25519_identity return unless Net::SSH::Authentication::ED25519Loader::LOADED + ed25519 = Net::SSH::Authentication::ED25519::PrivKey.read(ED25519, nil) socket.expect do |s,type,buffer| assert_equal SSH2_AGENT_ADD_IDENTITY, type @@ -339,6 +339,7 @@ module Authentication def test_add_ed25519_cert_identity return unless Net::SSH::Authentication::ED25519Loader::LOADED + cert = make_cert(Net::SSH::Authentication::ED25519::PrivKey.read(ED25519, nil)) socket.expect do |s,type,buffer| assert_equal SSH2_AGENT_ADD_IDENTITY, type @@ -433,6 +434,7 @@ module Authentication def send(data, flags) raise "got #{data.inspect} but no packet was expected" unless @expectation + buffer = Net::SSH::Buffer.new(data) buffer.read_long # skip the length type = buffer.read_byte @@ -470,5 +472,4 @@ module Authentication @agent_socket_factory ||= -> {"/foo/bar.sock"} end end - end diff --git a/test/authentication/test_ed25519.rb b/test/authentication/test_ed25519.rb index 7430541..279aa85 100644 --- a/test/authentication/test_ed25519.rb +++ b/test/authentication/test_ed25519.rb @@ -6,7 +6,6 @@ unless ENV['NET_SSH_NO_ED25519'] require 'base64' module Authentication - class TestED25519 < NetSSHTest def setup raise "No ED25519 set NET_SSH_NO_ED25519 to ignore this test" unless Net::SSH::Authentication::ED25519Loader::LOADED @@ -158,7 +157,6 @@ unless ENV['NET_SSH_NO_ED25519'] 'SHA256:u6mXnY8P1b0FODGp8mckqOB33u8+jvkSCtJbD5Q9klg' end end - end end diff --git a/test/authentication/test_key_manager.rb b/test/authentication/test_key_manager.rb index c40779f..79900a8 100644 --- a/test/authentication/test_key_manager.rb +++ b/test/authentication/test_key_manager.rb @@ -2,7 +2,6 @@ require_relative '../common' require 'net/ssh/authentication/key_manager' module Authentication - class TestKeyManager < NetSSHTest def test_key_files_and_known_identities_are_empty_by_default assert manager.key_files.empty? @@ -381,5 +380,4 @@ module Authentication @manager ||= Net::SSH::Authentication::KeyManager.new(nil, { password_prompt: prompt }.merge(options)) end end - end diff --git a/test/authentication/test_session.rb b/test/authentication/test_session.rb index db37467..3e46def 100644 --- a/test/authentication/test_session.rb +++ b/test/authentication/test_session.rb @@ -2,7 +2,6 @@ require_relative '../common' require 'net/ssh/authentication/session' module Authentication - class TestSession < NetSSHTest include Net::SSH::Transport::Constants include Net::SSH::Authentication::Constants @@ -292,5 +291,4 @@ module Authentication EOF end end - end diff --git a/test/connection/test_channel.rb b/test/connection/test_channel.rb index abda254..75ea309 100644 --- a/test/connection/test_channel.rb +++ b/test/connection/test_channel.rb @@ -2,7 +2,6 @@ require 'common' require 'net/ssh/connection/channel' module Connection - class TestChannel < NetSSHTest include Net::SSH::Connection::Constants @@ -457,6 +456,7 @@ module Connection def send_message(msg) raise "#{msg.to_s.inspect} received but no message was expected" unless @expectation + packet = Net::SSH::Packet.new(msg.to_s) callback, @expectation = @expectation, nil callback.call(self, packet) @@ -483,5 +483,4 @@ module Connection &block) end end - end diff --git a/test/connection/test_session.rb b/test/connection/test_session.rb index 91e3ea9..47255e4 100644 --- a/test/connection/test_session.rb +++ b/test/connection/test_session.rb @@ -2,7 +2,6 @@ require_relative '../common' require 'net/ssh/connection/session' module Connection - class TestSession < NetSSHTest include Net::SSH::Connection::Constants @@ -536,6 +535,7 @@ module Connection data.each_slice(2) do |type, datum| next if datum.empty? + if type == :stdout t2.return(CHANNEL_DATA, :long, p[:remote_id], :string, datum) else @@ -583,5 +583,4 @@ module Connection session.process { (i += 1) < n } end end - end diff --git a/test/integration/common.rb b/test/integration/common.rb index e9d2546..ada7cad 100644 --- a/test/integration/common.rb +++ b/test/integration/common.rb @@ -64,11 +64,13 @@ module IntegrationTestHelpers pid, status = Process.wait2 pid end raise "Command: #{command} failed:#{status.exitstatus}" unless status + status.exitstatus end def with_sshd_config(sshd_config, &block) raise "Failed to copy config" unless system("sudo cp -f /etc/ssh/sshd_config /etc/ssh/sshd_config.original") + begin Tempfile.open('sshd_config') do |f| f.write(sshd_config) @@ -77,6 +79,7 @@ module IntegrationTestHelpers end system("sudo chmod 0644 /etc/ssh/sshd_config") raise "Failed to restart sshd" unless system("sudo service ssh restart") + yield ensure system("sudo cp -f /etc/ssh/sshd_config.original /etc/ssh/sshd_config") @@ -110,6 +113,7 @@ module IntegrationTestHelpers with_lines_as_tempfile(config) do |path, pidpath| # puts "DEBUG - SSH LOG: #{path}-log.txt" raise "A leftover sshd is already running" if is_port_open?(port) + pid = spawn('sudo', '/opt/net-ssh-openssh/sbin/sshd', '-D', '-f', path, '-p', port) # '-E', "#{path}-log.txt") sshpidfile = pidpath yield pid, port diff --git a/test/integration/test_channel.rb b/test/integration/test_channel.rb index 84c09d4..46f5fd5 100644 --- a/test/integration/test_channel.rb +++ b/test/integration/test_channel.rb @@ -34,6 +34,7 @@ class TestChannel < NetSSHTest ssh.open_channel do |channel| channel.exec(command) do |_ch, success| raise "could not execute command: #{command.inspect}" unless success + channel_success_handler.call channel.on_data do |ch2, data| yield(ch2, :stdout, data) diff --git a/test/integration/test_proxy.rb b/test/integration/test_proxy.rb index d73b7ba..64809bb 100644 --- a/test/integration/test_proxy.rb +++ b/test/integration/test_proxy.rb @@ -137,6 +137,7 @@ class TestProxy < NetSSHTest @io end end + def test_does_close_proxy_on_proxy_failure setup_ssh_env do proxy = DbgProxy.new(Net::SSH::Proxy::Command.new('sleep 2 && ssh -W %h:%p -o "PreferredAuthentications none" user@localhost')) diff --git a/test/manual/test_pageant.rb b/test/manual/test_pageant.rb index 0f8b591..e9a72da 100644 --- a/test/manual/test_pageant.rb +++ b/test/manual/test_pageant.rb @@ -15,7 +15,6 @@ require_relative '../common' require 'net/ssh/authentication/agent' module Authentication - class TestPageapnt < NetSSHTest def test_agent_should_be_able_to_negotiate begin @@ -37,5 +36,4 @@ module Authentication end end end - end diff --git a/test/transport/hmac/test_md5.rb b/test/transport/hmac/test_md5.rb index 16ee10f..714eee0 100644 --- a/test/transport/hmac/test_md5.rb +++ b/test/transport/hmac/test_md5.rb @@ -5,7 +5,6 @@ require 'net/ssh/transport/hmac/md5' module Transport module HMAC - class TestMD5 < NetSSHTest def test_expected_digest_class assert_equal OpenSSL::Digest::MD5, subject.digest_class @@ -38,6 +37,5 @@ module Transport Net::SSH::Transport::HMAC::MD5 end end - end end diff --git a/test/transport/hmac/test_md5_96.rb b/test/transport/hmac/test_md5_96.rb index b45d505..13f4a8a 100644 --- a/test/transport/hmac/test_md5_96.rb +++ b/test/transport/hmac/test_md5_96.rb @@ -6,7 +6,6 @@ require 'net/ssh/transport/hmac/md5_96' module Transport module HMAC - class TestMD5_96 < TestMD5 def test_expected_mac_length assert_equal 12, subject.mac_length @@ -24,6 +23,5 @@ module Transport Net::SSH::Transport::HMAC::MD5_96 end end - end end diff --git a/test/transport/hmac/test_none.rb b/test/transport/hmac/test_none.rb index ae8fe7e..c2661f8 100644 --- a/test/transport/hmac/test_none.rb +++ b/test/transport/hmac/test_none.rb @@ -3,7 +3,6 @@ require 'net/ssh/transport/hmac/none' module Transport module HMAC - class TestNone < NetSSHTest def test_expected_digest_class assert_nil subject.digest_class @@ -31,6 +30,5 @@ module Transport Net::SSH::Transport::HMAC::None end end - end end diff --git a/test/transport/hmac/test_ripemd160.rb b/test/transport/hmac/test_ripemd160.rb index bcc14f8..63ebbbd 100644 --- a/test/transport/hmac/test_ripemd160.rb +++ b/test/transport/hmac/test_ripemd160.rb @@ -5,7 +5,6 @@ require 'net/ssh/transport/hmac/ripemd160' module Transport module HMAC - class TestRipemd160 < NetSSHTest def test_expected_digest_class assert_equal OpenSSL::Digest::RIPEMD160, subject.digest_class @@ -33,6 +32,5 @@ module Transport Net::SSH::Transport::HMAC::RIPEMD160 end end - end end diff --git a/test/transport/hmac/test_sha1.rb b/test/transport/hmac/test_sha1.rb index 468da6d..efb9f4e 100644 --- a/test/transport/hmac/test_sha1.rb +++ b/test/transport/hmac/test_sha1.rb @@ -5,7 +5,6 @@ require 'net/ssh/transport/hmac/sha1' module Transport module HMAC - class TestSHA1 < NetSSHTest def test_expected_digest_class assert_equal OpenSSL::Digest::SHA1, subject.digest_class @@ -33,6 +32,5 @@ module Transport Net::SSH::Transport::HMAC::SHA1 end end - end end diff --git a/test/transport/hmac/test_sha1_96.rb b/test/transport/hmac/test_sha1_96.rb index 72cb6ca..1dcf0cd 100644 --- a/test/transport/hmac/test_sha1_96.rb +++ b/test/transport/hmac/test_sha1_96.rb @@ -6,7 +6,6 @@ require 'net/ssh/transport/hmac/sha1_96' module Transport module HMAC - class TestSHA1_96 < TestSHA1 def test_expected_mac_length assert_equal 12, subject.mac_length @@ -24,6 +23,5 @@ module Transport Net::SSH::Transport::HMAC::SHA1_96 end end - end end diff --git a/test/transport/hmac/test_sha2_256.rb b/test/transport/hmac/test_sha2_256.rb index 8a2e07d..834967b 100644 --- a/test/transport/hmac/test_sha2_256.rb +++ b/test/transport/hmac/test_sha2_256.rb @@ -5,7 +5,6 @@ require 'net/ssh/transport/hmac/sha2_256' module Transport module HMAC - class TestSHA2_256 < NetSSHTest def test_expected_digest_class assert_equal OpenSSL::Digest::SHA256, subject.digest_class diff --git a/test/transport/hmac/test_sha2_256_96.rb b/test/transport/hmac/test_sha2_256_96.rb index 07799fe..3a659fc 100644 --- a/test/transport/hmac/test_sha2_256_96.rb +++ b/test/transport/hmac/test_sha2_256_96.rb @@ -6,7 +6,6 @@ require 'net/ssh/transport/hmac/sha2_256_96' module Transport module HMAC - class TestSHA2_256_96 < TestSHA2_256 def test_expected_mac_length assert_equal 12, subject.mac_length @@ -24,6 +23,5 @@ module Transport Net::SSH::Transport::HMAC::SHA2_256_96 end end - end end diff --git a/test/transport/hmac/test_sha2_256_etm.rb b/test/transport/hmac/test_sha2_256_etm.rb index f66afda..5a50cef 100644 --- a/test/transport/hmac/test_sha2_256_etm.rb +++ b/test/transport/hmac/test_sha2_256_etm.rb @@ -5,7 +5,6 @@ require 'net/ssh/transport/hmac/sha2_256_etm' module Transport module HMAC - class TestSHA2_256_Etm < NetSSHTest def test_expected_digest_class assert_equal OpenSSL::Digest::SHA256, subject.digest_class diff --git a/test/transport/hmac/test_sha2_512.rb b/test/transport/hmac/test_sha2_512.rb index 886c683..a1b7048 100644 --- a/test/transport/hmac/test_sha2_512.rb +++ b/test/transport/hmac/test_sha2_512.rb @@ -5,7 +5,6 @@ require 'net/ssh/transport/hmac/sha2_512' module Transport module HMAC - class TestSHA2_512 < NetSSHTest def test_expected_digest_class assert_equal OpenSSL::Digest::SHA512, subject.digest_class diff --git a/test/transport/hmac/test_sha2_512_96.rb b/test/transport/hmac/test_sha2_512_96.rb index 955da06..16732bf 100644 --- a/test/transport/hmac/test_sha2_512_96.rb +++ b/test/transport/hmac/test_sha2_512_96.rb @@ -6,7 +6,6 @@ require 'net/ssh/transport/hmac/sha2_512_96' module Transport module HMAC - class TestSHA2_512_96 < TestSHA2_512 def test_expected_mac_length assert_equal 12, subject.mac_length @@ -24,6 +23,5 @@ module Transport Net::SSH::Transport::HMAC::SHA2_512_96 end end - end end diff --git a/test/transport/hmac/test_sha2_512_etm.rb b/test/transport/hmac/test_sha2_512_etm.rb index 364905e..0805b97 100644 --- a/test/transport/hmac/test_sha2_512_etm.rb +++ b/test/transport/hmac/test_sha2_512_etm.rb @@ -5,7 +5,6 @@ require 'net/ssh/transport/hmac/sha2_512_etm' module Transport module HMAC - class TestSHA2_512_Etm < NetSSHTest def test_expected_digest_class assert_equal OpenSSL::Digest::SHA512, subject.digest_class diff --git a/test/transport/kex/test_diffie_hellman_group14_sha1.rb b/test/transport/kex/test_diffie_hellman_group14_sha1.rb index 6d5f8f8..ac15266 100644 --- a/test/transport/kex/test_diffie_hellman_group14_sha1.rb +++ b/test/transport/kex/test_diffie_hellman_group14_sha1.rb @@ -5,7 +5,6 @@ require 'ostruct' module Transport module Kex - class TestDiffieHellmanGroup14SHA1 < TestDiffieHellmanGroup1SHA1 def subject Net::SSH::Transport::Kex::DiffieHellmanGroup14SHA1 diff --git a/test/transport/kex/test_diffie_hellman_group14_sha256.rb b/test/transport/kex/test_diffie_hellman_group14_sha256.rb index a64f2f1..db15d5b 100644 --- a/test/transport/kex/test_diffie_hellman_group14_sha256.rb +++ b/test/transport/kex/test_diffie_hellman_group14_sha256.rb @@ -3,7 +3,6 @@ require_relative './test_diffie_hellman_group14_sha1' module Transport module Kex - class TestDiffieHellmanGroup14SHA256 < TestDiffieHellmanGroup14SHA1 def subject Net::SSH::Transport::Kex::DiffieHellmanGroup14SHA256 diff --git a/test/transport/kex/test_diffie_hellman_group1_sha1.rb b/test/transport/kex/test_diffie_hellman_group1_sha1.rb index 60042c2..ddde23c 100644 --- a/test/transport/kex/test_diffie_hellman_group1_sha1.rb +++ b/test/transport/kex/test_diffie_hellman_group1_sha1.rb @@ -4,7 +4,6 @@ require 'ostruct' module Transport module Kex - class TestDiffieHellmanGroup1SHA1 < NetSSHTest include Net::SSH::Transport::Constants @@ -167,6 +166,5 @@ module Transport Net::SSH::Buffer.from(*args) end end - end end diff --git a/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb b/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb index 800a8c6..b709dda 100644 --- a/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +++ b/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb @@ -4,7 +4,6 @@ require 'net/ssh/transport/kex/diffie_hellman_group_exchange_sha1' module Transport module Kex - class TestDiffieHellmanGroupExchangeSHA1 < TestDiffieHellmanGroup1SHA1 KEXDH_GEX_GROUP = 31 KEXDH_GEX_INIT = 32 @@ -49,6 +48,7 @@ module Transport def need_minimum(bits=1024) return @dh_options[:minimum_dh_bits] if @dh_options && @dh_options[:minimum_dh_bits] + bits end @@ -104,6 +104,5 @@ module Transport end end end - end end diff --git a/test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb b/test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb index 6355c18..95f4152 100644 --- a/test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb +++ b/test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb @@ -4,7 +4,6 @@ require 'transport/kex/test_diffie_hellman_group_exchange_sha1' module Transport module Kex - class TestDiffieHellmanGroupExchangeSHA256 < TestDiffieHellmanGroupExchangeSHA1 private @@ -16,6 +15,5 @@ module Transport OpenSSL::Digest::SHA256 end end - end end diff --git a/test/transport/test_algorithms.rb b/test/transport/test_algorithms.rb index 53262a1..6928737 100644 --- a/test/transport/test_algorithms.rb +++ b/test/transport/test_algorithms.rb @@ -3,7 +3,6 @@ require 'logger' require 'net/ssh/transport/algorithms' module Transport - class TestAlgorithms < NetSSHTest include Net::SSH::Transport::Constants @@ -338,6 +337,7 @@ module Transport Net::SSH::Transport::Kex::MAP.each do |name, klass| next if klass == kex + klass.expects(:new).never end @@ -441,5 +441,4 @@ module Transport @transport ||= MockTransport.new(transport_options) end end - end diff --git a/test/transport/test_cipher_factory.rb b/test/transport/test_cipher_factory.rb index 49ff2cd..768fbf8 100644 --- a/test/transport/test_cipher_factory.rb +++ b/test/transport/test_cipher_factory.rb @@ -4,7 +4,6 @@ require 'common' require 'net/ssh/transport/cipher_factory' module Transport - class TestCipherFactory < NetSSHTest def self.if_supported?(name) yield if Net::SSH::Transport::CipherFactory.supported?(name) @@ -308,5 +307,4 @@ module Transport [first, second] end end - end diff --git a/test/transport/test_hmac.rb b/test/transport/test_hmac.rb index 4e2238b..3672204 100644 --- a/test/transport/test_hmac.rb +++ b/test/transport/test_hmac.rb @@ -2,7 +2,6 @@ require 'common' require 'net/ssh/transport/hmac' module Transport - class TestHMAC < NetSSHTest Net::SSH::Transport::HMAC::MAP.each do |name, value| method = name.tr("-", "_") @@ -30,5 +29,4 @@ module Transport end end end - end diff --git a/test/transport/test_identity_cipher.rb b/test/transport/test_identity_cipher.rb index a8f87d6..3f332db 100644 --- a/test/transport/test_identity_cipher.rb +++ b/test/transport/test_identity_cipher.rb @@ -2,7 +2,6 @@ require 'common' require 'net/ssh/transport/identity_cipher' module Transport - class TestIdentityCipher < NetSSHTest def test_block_size_should_be_8 assert_equal 8, cipher.block_size @@ -34,5 +33,4 @@ module Transport Net::SSH::Transport::IdentityCipher end end - end diff --git a/test/transport/test_packet_stream.rb b/test/transport/test_packet_stream.rb index 25c6b32..2cb47e1 100644 --- a/test/transport/test_packet_stream.rb +++ b/test/transport/test_packet_stream.rb @@ -5,7 +5,6 @@ require 'timeout' require 'net/ssh/transport/packet_stream' module Transport - class TestPacketStream < NetSSHTest # rubocop:disable Metrics/ClassLength include Net::SSH::Transport::Constants @@ -1129,5 +1128,4 @@ module Transport end end end - end diff --git a/test/transport/test_session.rb b/test/transport/test_session.rb index 1b3747a..117fb89 100644 --- a/test/transport/test_session.rb +++ b/test/transport/test_session.rb @@ -10,7 +10,6 @@ require 'logger' Object.send(:undef_method, :verify) if Object.instance_methods.any? { |v| v.to_sym == :verify } module Transport - class TestSession < NetSSHTest include Net::SSH::Transport::Constants @@ -421,5 +420,4 @@ module Transport # version makes it look more like the session is being instantiated alias session! session end - end diff --git a/test/transport/test_state.rb b/test/transport/test_state.rb index 1f9b9ce..b08fda7 100644 --- a/test/transport/test_state.rb +++ b/test/transport/test_state.rb @@ -4,7 +4,6 @@ require 'common' require 'net/ssh/transport/state' module Transport - class TestState < NetSSHTest def setup @socket = @state = @deflater = @inflater = nil @@ -119,6 +118,7 @@ module Transport # JRuby Zlib implementation (1.4 & 1.5) does not have byte-to-byte compatibility with MRI's. # skip this test under JRuby. return if defined?(JRUBY_VERSION) + assert_equal "x\234\312H\315\311\311WH-K-\252L\312O\251\004\000\000\000\377\377", state.compress("hello everybody") end @@ -127,6 +127,7 @@ module Transport # JRuby Zlib implementation (1.4 & 1.5) does not have byte-to-byte compatibility with MRI's. # skip this test under JRuby. return if defined?(JRUBY_VERSION) + assert_equal "hello everybody", state.decompress("x\234\312H\315\311\311WH-K-\252L\312O\251\004\000\000\000\377\377") end @@ -176,5 +177,4 @@ module Transport @state ||= Net::SSH::Transport::State.new(socket, :test) end end - end diff --git a/test/win_integration/test_pageant.rb b/test/win_integration/test_pageant.rb index 374433f..f87fe59 100644 --- a/test/win_integration/test_pageant.rb +++ b/test/win_integration/test_pageant.rb @@ -2,13 +2,13 @@ require_relative '../common' require 'net/ssh/authentication/agent' module Authentication - unless RUBY_PLATFORM == "java" class TestPageapnt < NetSSHTest def with_pagent pageant_path = 'C:\ProgramData\chocolatey\lib\putty.portable\tools\pageant.exe' raise "No pageant found at:#{pageant_path}" unless File.executable?(pageant_path) + pageant_pid = Process.spawn(pageant_path) sleep 4 yield @@ -40,5 +40,4 @@ module Authentication end end - end |