diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0a3a2cd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: CI +on: + pull_request: + push: { branches: master } +permissions: + contents: read +jobs: + test: + # setup-ruby has no builds of Ruby 3.1 and older for ubuntu-latest (26.04). + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '4.0', 'ruby-head', 'jruby'] + continue-on-error: ${{ contains(fromJSON('["ruby-head", "jruby"]'), matrix.ruby-version) }} + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby ${{ matrix.ruby-version }} + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + - name: Run Tests + run: bundle exec rake test diff --git a/.gitignore b/.gitignore index 7715783..53e229a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ doc pkg *.swp +.bundle/ +Gemfile.lock .DS_Store diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b520c8f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: ruby -sudo: false -rvm: - - 2.0.0 - - 2.1.0 - - 2.2.0 - - 2.3.0 - - jruby-head - - rbx-2 - -install: gem install test-unit mocha net-ssh net-ssh-gateway - -script: rake test - -matrix: - allow_failures: - - rvm: jruby-head diff --git a/CHANGES.txt b/CHANGES.txt index 92be5cd..da78210 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,9 @@ +=== Unreleased + +* Require net-ssh >= 4.0 [mfazekas] +* Replace Jeweler and Travis with a hand-written gemspec, a Gemfile and GitHub Actions for Ruby 2.6 to 4.0 [mfazekas] +* Fix the gemspec homepage, and ship the renewed net-ssh-public_cert.pem used to sign releases [mfazekas] + === 1.3.0.rc1 / 12 Mar 2016 * Make sure we wait no more than keeepalive in select [Eugene Kenny] diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..6c8d19b --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source 'https://rubygems.org' + +# Specify your gem's dependencies in net-ssh-multi.gemspec +gemspec diff --git a/README.rdoc b/README.rdoc index 1187637..0d0c2cb 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,6 +1,6 @@ = Net::SSH::Multi -* Docs: http://net-ssh.github.com/net-ssh-multi +* Docs: https://net-ssh.github.io/net-ssh-multi * Issues: https://github.com/net-ssh/net-ssh-multi/issues * Codes: https://github.com/net-ssh/net-ssh-multi * Email: net-ssh@solutious.com @@ -66,12 +66,12 @@ If you want to run the tests or use any of the Rake tasks, you'll need: * gem install net-ssh-multi -However, in order to be sure the code you're installing hasn't been tampered with, it's recommended that you verify the signature[http://docs.rubygems.org/read/chapter/21]. To do this, you need to add my public key as a trusted certificate (you only need to do this once): +However, in order to be sure the code you're installing hasn't been tampered with, it's recommended that you verify the signature[https://guides.rubygems.org/security/]. To do this, you need to add my public key as a trusted certificate (you only need to do this once): # Add the public key as a trusted certificate # (You only need to do this once) - $ curl -O https://raw.github.com/net-ssh/net-ssh/master/gem-public_cert.pem - $ gem cert --add gem-public_cert.pem + $ curl -O https://raw.githubusercontent.com/net-ssh/net-ssh-multi/master/net-ssh-public_cert.pem + $ gem cert --add net-ssh-public_cert.pem Then, when install the gem, do so with high security: diff --git a/Rakefile b/Rakefile index 3420250..2a2cd36 100644 --- a/Rakefile +++ b/Rakefile @@ -1,65 +1,9 @@ -require "rubygems" -require "rake" -require "rake/clean" -require "rdoc/task" +require "bundler/gem_tasks" +require "rake/testtask" -task :default => ["build"] -CLEAN.include [ 'pkg', 'rdoc' ] -name = "net-ssh-multi" - -$:.unshift File.join(File.dirname(__FILE__), 'lib') -require './lib/net/ssh/multi/version' -version = Net::SSH::Multi::Version::STRING.dup - -begin - require "jeweler" - Jeweler::Tasks.new do |s| - s.version = version - s.name = name - s.rubyforge_project = s.name - s.summary = "Control multiple Net::SSH connections via a single interface." - s.description = s.summary - s.email = "net-ssh@solutious.com" - s.homepage = "https://github.com/net-ssh/net-scp" - s.authors = ["Jamis Buck", "Delano Mandelbaum"] - - s.add_dependency 'net-ssh', ">=2.6.5" - s.add_dependency 'net-ssh-gateway', ">=1.2.0" - - s.add_development_dependency 'minitest' - s.add_development_dependency 'mocha' - - s.license = "MIT" - - unless ENV['NET_SSH_NOKEY'] - signing_key = File.join('/mnt/gem/', 'net-ssh-private_key.pem') - s.signing_key = signing_key - s.cert_chain = ['gem-public_cert.pem'] - unless (Rake.application.top_level_tasks & ['build','install']).empty? - raise "No key found at #{signing_key} for signing, use rake NET_SSH_NOKEY=1 to build without key" unless File.exist?(signing_key) - end - end - end - Jeweler::GemcutterTasks.new -rescue LoadError - puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler" -end - -require 'rake/testtask' Rake::TestTask.new do |t| t.libs = ["lib", "test"] + t.pattern = "test/**/*_test.rb" end -extra_files = %w[LICENSE.txt THANKS.txt CHANGES.txt ] -RDoc::Task.new do |rdoc| - rdoc.rdoc_dir = "rdoc" - rdoc.title = "#{name} #{version}" - rdoc.generator = 'hanna' # gem install hanna-nouveau - rdoc.main = 'README.rdoc' - rdoc.rdoc_files.include("README*") - rdoc.rdoc_files.include("bin/*.rb") - rdoc.rdoc_files.include("lib/**/*.rb") - extra_files.each { |file| - rdoc.rdoc_files.include(file) if File.exists?(file) - } -end +task :default => :test diff --git a/gem-public_cert.pem b/gem-public_cert.pem deleted file mode 100644 index ffa10de..0000000 --- a/gem-public_cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDODCCAiCgAwIBAgIBADANBgkqhkiG9w0BAQUFADBCMRAwDgYDVQQDDAduZXQt -c3NoMRkwFwYKCZImiZPyLGQBGRYJc29sdXRpb3VzMRMwEQYKCZImiZPyLGQBGRYD -Y29tMB4XDTE1MTIwNjIxMDYyNFoXDTE2MTIwNTIxMDYyNFowQjEQMA4GA1UEAwwH -bmV0LXNzaDEZMBcGCgmSJomT8ixkARkWCXNvbHV0aW91czETMBEGCgmSJomT8ixk -ARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMYnhNtn0f6p -nTylB8mE8lMdoMLJC8KwpMWsvk73Pe2WVDsH/OSwwwz6oUGk1i70cJyDjIEBNpwT -88GpVXJSumvqVsf9fCg3mWNeb5t0J+aeNm9MIvYVMTqj5tydoXQiwnILRDYHV9tZ -1c3o59/VlahSTpZ7YEgzVufpAkvEGkbJiG849exiipK7MN/ZIkMOxYVnyRXk43Xc -6GYlsHOfSgPwcXwW5g57DCwLQLWrjDsTka28dxDmO7B5Lv5EqzINxVxWsu43OgZG -21Io/jIyf5PNpeKPKNGDuAQJ8mvdMYBJoDhtCwgsUYbl0BZzA7g4ytl51HtIeP+j -Qp/eAvs/RrECAwEAAaM5MDcwCQYDVR0TBAIwADAdBgNVHQ4EFgQUBfKiwO2eM4NE -iRrVG793qEPLYyMwCwYDVR0PBAQDAgSwMA0GCSqGSIb3DQEBBQUAA4IBAQCfZFdb -p4jzkfIzGDbiOxd0R8sdqJoC4nMLEgnQ7dLulawwA3IXe3sHAKgA5kmH3prsKc5H -zVmM5NlH2P1nRbegIkQTYiIod1hZQCNxdmVG/fprMqPq0ybpUOjjrP5pj0OtszE1 -F2dQia1hOEstMR+n0nAtWII9HJAEyeZjVV0s2Cl7Pt85XJ3hxFcCKwzqsK5xRI7a -B3vwh3/JJYrFonIohQ//Lg9qTZASEkoKLlq1/hFeICoCGGIGLq45ZB7CzXLooCKi -s/ZUKye79ELwFYKJOhjW5g725OL3hy+llhEleytwKRwgXFQBPTC4f5UkdxZVVWGH -e2C9M1m/2odPZo8h ------END CERTIFICATE----- diff --git a/net-ssh-multi.gemspec b/net-ssh-multi.gemspec index fb7ade3..f69c8a3 100644 --- a/net-ssh-multi.gemspec +++ b/net-ssh-multi.gemspec @@ -1,77 +1,34 @@ -# Generated by jeweler -# DO NOT EDIT THIS FILE DIRECTLY -# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' -# -*- encoding: utf-8 -*- -# stub: net-ssh-multi 1.3.0.rc1 ruby lib +# coding: utf-8 -Gem::Specification.new do |s| - s.name = "net-ssh-multi" - s.version = "1.3.0.rc1" +# version.rb requires net-ssh, which isn't installed yet when bundler first evaluates this file. +version_rb = File.read(File.expand_path('../lib/net/ssh/multi/version.rb', __FILE__)) +version = %w[MAJOR MINOR TINY PRE].map { |part| version_rb[/^\s*#{part}\s*=\s*"?(\w+)"?/, 1] } +version = version.reject { |part| part.nil? || part == "nil" }.join(".") - s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version= - s.require_paths = ["lib"] - s.authors = ["Jamis Buck", "Delano Mandelbaum"] - s.cert_chain = ["gem-public_cert.pem"] - s.date = "2016-03-24" - s.description = "Control multiple Net::SSH connections via a single interface." - s.email = "net-ssh@solutious.com" - s.extra_rdoc_files = [ - "LICENSE.txt", - "README.rdoc" - ] - s.files = [ - ".travis.yml", - "CHANGES.txt", - "LICENSE.txt", - "README.rdoc", - "Rakefile", - "gem-public_cert.pem", - "lib/net/ssh/multi.rb", - "lib/net/ssh/multi/channel.rb", - "lib/net/ssh/multi/channel_proxy.rb", - "lib/net/ssh/multi/dynamic_server.rb", - "lib/net/ssh/multi/pending_connection.rb", - "lib/net/ssh/multi/server.rb", - "lib/net/ssh/multi/server_list.rb", - "lib/net/ssh/multi/session.rb", - "lib/net/ssh/multi/session_actions.rb", - "lib/net/ssh/multi/subsession.rb", - "lib/net/ssh/multi/version.rb", - "net-ssh-multi.gemspec", - "test/channel_test.rb", - "test/common.rb", - "test/multi_test.rb", - "test/server_test.rb", - "test/session_actions_test.rb", - "test/session_test.rb", - "test/test_all.rb" - ] - s.homepage = "https://github.com/net-ssh/net-scp" - s.licenses = ["MIT"] - s.rubyforge_project = "net-ssh-multi" - s.rubygems_version = "2.4.6" - s.signing_key = "/mnt/gem/net-ssh-private_key.pem" - s.summary = "Control multiple Net::SSH connections via a single interface." +Gem::Specification.new do |spec| + spec.name = "net-ssh-multi" + spec.version = version + spec.authors = ["Jamis Buck", "Delano Mandelbaum", "Mikl\u{f3}s Fazekas"] + spec.email = ["net-ssh@solutious.com"] - if s.respond_to? :specification_version then - s.specification_version = 4 - - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q, [">= 2.6.5"]) - s.add_runtime_dependency(%q, [">= 1.2.0"]) - s.add_development_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 0"]) - else - s.add_dependency(%q, [">= 2.6.5"]) - s.add_dependency(%q, [">= 1.2.0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - end - else - s.add_dependency(%q, [">= 2.6.5"]) - s.add_dependency(%q, [">= 1.2.0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) + if ENV['NET_SSH_BUILDGEM_SIGNED'] + spec.cert_chain = ["net-ssh-public_cert.pem"] + spec.signing_key = "/mnt/gem/net-ssh-private_key.pem" end -end + spec.summary = %q{Control multiple Net::SSH connections via a single interface.} + spec.description = %q{Control multiple Net::SSH connections via a single interface.} + spec.homepage = "https://github.com/net-ssh/net-ssh-multi" + spec.license = "MIT" + + spec.files = Dir["lib/**/*.rb"] + %w[CHANGES.txt LICENSE.txt README.rdoc] + spec.extra_rdoc_files = %w[LICENSE.txt README.rdoc] + spec.require_paths = ["lib"] + + spec.add_development_dependency "rake", ">= 12.0" + spec.add_development_dependency "minitest", ">= 5.10" + spec.add_development_dependency "mocha", ">= 1.4" + + spec.add_runtime_dependency "net-ssh", ">= 4.0.0" + spec.add_runtime_dependency "net-ssh-gateway", ">= 1.2.0" +end diff --git a/net-ssh-public_cert.pem b/net-ssh-public_cert.pem new file mode 100644 index 0000000..f0fdba5 --- /dev/null +++ b/net-ssh-public_cert.pem @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDeDCCAmC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jpXCYvH86KtpaxF66mwaynfdjzxQAVycV/ilKtL+sHH8zxlg +vNiMFH5yLu/tlav4xh+HlYscWVdFQIvd7f/Uxa+Vip1Pi16wmhnrE15z/vDX921v +hukBRIoCEAuUgNVBh+L/C8aETzbf/77WU3Si/w== +-----END CERTIFICATE----- diff --git a/test/channel_test.rb b/test/channel_test.rb index 475c59b..b479267 100644 --- a/test/channel_test.rb +++ b/test/channel_test.rb @@ -31,8 +31,8 @@ def test_exec_should_delegate_to_component_channels def test_request_pty_should_delegate_to_component_channels c1, c2, results = mock('channel'), mock('channel'), [] - c1.expects(:request_pty).with(:foo => 5).yields(c1) - c2.expects(:request_pty).with(:foo => 5).yields(c2) + c1.expects(:request_pty).with({:foo => 5}).yields(c1) + c2.expects(:request_pty).with({:foo => 5}).yields(c2) channel = Net::SSH::Multi::Channel.new(mock('session'), [c1, c2]) assert_equal channel, channel.request_pty(:foo => 5) { |c| results << c } assert_equal [c1, c2], results diff --git a/test/common.rb b/test/common.rb index ef6ef4f..240ce1b 100644 --- a/test/common.rb +++ b/test/common.rb @@ -1,9 +1,2 @@ require 'minitest/autorun' -require 'mocha/setup' - -if Minitest.const_defined?('Test') - # We're on Minitest 5+. Nothing to do here. -else - # Minitest 4 doesn't have Minitest::Test yet. - Minitest::Test = MiniTest::Unit::TestCase -end +require 'mocha/minitest' diff --git a/test/session_actions_test.rb b/test/session_actions_test.rb index c9e29d6..1f4587c 100644 --- a/test/session_actions_test.rb +++ b/test/session_actions_test.rb @@ -27,6 +27,11 @@ def setup @session = SessionActionsContainer.new end + # Mocha keeps the visibility of the method it stubs, and Kernel#exec is private. + def channel_hash + { :host => "host" }.tap { |c| c.singleton_class.send(:public, :exec) } + end + def test_busy_should_be_true_if_any_server_is_busy srv1, srv2, srv3 = @session.use('h1'), @session.use('h2'), @session.use('h3') srv1.stubs(:busy?).returns(false) @@ -80,14 +85,14 @@ def test_open_channel_should_delegate_to_sessions_and_set_accessors_on_each_chan end def test_exec_should_raise_exception_if_channel_cannot_exec_command - c = { :host => "host" } + c = channel_hash @session.expects(:open_channel).yields(c).returns(c) c.expects(:exec).with('something').yields(c, false) assert_raises(RuntimeError) { @session.exec("something") } end def test_exec_with_block_should_pass_data_and_extended_data_to_block - c = { :host => "host" } + c = channel_hash @session.expects(:open_channel).yields(c).returns(c) c.expects(:exec).with('something').yields(c, true) c.expects(:on_data).yields(c, "stdout") @@ -101,7 +106,7 @@ def test_exec_with_block_should_pass_data_and_extended_data_to_block end def test_exec_without_block_should_write_data_and_extended_data_lines_to_stdout_and_stderr - c = { :host => "host" } + c = channel_hash @session.expects(:open_channel).yields(c).returns(c) c.expects(:exec).with('something').yields(c, true) c.expects(:on_data).yields(c, "stdout 1\nstdout 2\n") @@ -115,7 +120,7 @@ def test_exec_without_block_should_write_data_and_extended_data_lines_to_stdout_ end def test_exec_should_capture_exit_status_of_process - c = { :host => "host" } + c = channel_hash @session.expects(:open_channel).yields(c).returns(c) c.expects(:exec).with('something').yields(c, true) c.expects(:on_data) diff --git a/test/session_test.rb b/test/session_test.rb index c027db9..afca8ee 100644 --- a/test/session_test.rb +++ b/test/session_test.rb @@ -38,7 +38,7 @@ def test_group_with_mapping_should_append_new_servers_to_specified_and_open_grou end def test_via_should_instantiate_and_set_default_gateway - Net::SSH::Gateway.expects(:new).with('host', 'user', :a => :b).returns(:gateway) + Net::SSH::Gateway.expects(:new).with('host', 'user', {:a => :b}).returns(:gateway) assert_equal @session, @session.via('host', 'user', :a => :b) assert_equal :gateway, @session.default_gateway end