net-ssh 3.2.0 → 7.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data/.dockerignore +6 -0
- data/.github/FUNDING.yml +1 -0
- data/.github/config/rubocop_linter_action.yml +4 -0
- data/.github/workflows/ci-with-docker.yml +44 -0
- data/.github/workflows/ci.yml +93 -0
- data/.github/workflows/rubocop.yml +16 -0
- data/.gitignore +13 -0
- data/.rubocop.yml +22 -0
- data/.rubocop_todo.yml +1081 -0
- data/CHANGES.txt +237 -7
- data/DEVELOPMENT.md +23 -0
- data/Dockerfile +27 -0
- data/Dockerfile.openssl3 +17 -0
- data/Gemfile +13 -0
- data/Gemfile.noed25519 +12 -0
- data/Gemfile.norbnacl +12 -0
- data/ISSUE_TEMPLATE.md +30 -0
- data/Manifest +4 -5
- data/README.md +298 -0
- data/Rakefile +125 -74
- data/SECURITY.md +4 -0
- data/appveyor.yml +58 -0
- data/docker-compose.yml +23 -0
- data/lib/net/ssh/authentication/agent.rb +279 -18
- data/lib/net/ssh/authentication/certificate.rb +183 -0
- data/lib/net/ssh/authentication/constants.rb +17 -15
- data/lib/net/ssh/authentication/ed25519.rb +186 -0
- data/lib/net/ssh/authentication/ed25519_loader.rb +31 -0
- data/lib/net/ssh/authentication/key_manager.rb +86 -39
- data/lib/net/ssh/authentication/methods/abstract.rb +67 -48
- data/lib/net/ssh/authentication/methods/hostbased.rb +34 -37
- data/lib/net/ssh/authentication/methods/keyboard_interactive.rb +13 -13
- data/lib/net/ssh/authentication/methods/none.rb +16 -19
- data/lib/net/ssh/authentication/methods/password.rb +27 -17
- data/lib/net/ssh/authentication/methods/publickey.rb +96 -55
- data/lib/net/ssh/authentication/pageant.rb +471 -367
- data/lib/net/ssh/authentication/pub_key_fingerprint.rb +43 -0
- data/lib/net/ssh/authentication/session.rb +131 -121
- data/lib/net/ssh/buffer.rb +399 -300
- data/lib/net/ssh/buffered_io.rb +154 -150
- data/lib/net/ssh/config.rb +308 -185
- data/lib/net/ssh/connection/channel.rb +635 -613
- data/lib/net/ssh/connection/constants.rb +29 -29
- data/lib/net/ssh/connection/event_loop.rb +123 -0
- data/lib/net/ssh/connection/keepalive.rb +55 -51
- data/lib/net/ssh/connection/session.rb +620 -551
- data/lib/net/ssh/connection/term.rb +125 -123
- data/lib/net/ssh/errors.rb +101 -99
- data/lib/net/ssh/key_factory.rb +197 -105
- data/lib/net/ssh/known_hosts.rb +214 -127
- data/lib/net/ssh/loggable.rb +50 -49
- data/lib/net/ssh/packet.rb +83 -79
- data/lib/net/ssh/prompt.rb +50 -81
- data/lib/net/ssh/proxy/command.rb +105 -90
- data/lib/net/ssh/proxy/errors.rb +12 -10
- data/lib/net/ssh/proxy/http.rb +82 -79
- data/lib/net/ssh/proxy/https.rb +50 -0
- data/lib/net/ssh/proxy/jump.rb +54 -0
- data/lib/net/ssh/proxy/socks4.rb +2 -6
- data/lib/net/ssh/proxy/socks5.rb +14 -17
- data/lib/net/ssh/service/forward.rb +370 -317
- data/lib/net/ssh/test/channel.rb +145 -136
- data/lib/net/ssh/test/extensions.rb +131 -110
- data/lib/net/ssh/test/kex.rb +34 -32
- data/lib/net/ssh/test/local_packet.rb +46 -44
- data/lib/net/ssh/test/packet.rb +89 -70
- data/lib/net/ssh/test/remote_packet.rb +32 -30
- data/lib/net/ssh/test/script.rb +156 -142
- data/lib/net/ssh/test/socket.rb +49 -48
- data/lib/net/ssh/test.rb +82 -77
- data/lib/net/ssh/transport/algorithms.rb +462 -359
- data/lib/net/ssh/transport/chacha20_poly1305_cipher.rb +117 -0
- data/lib/net/ssh/transport/chacha20_poly1305_cipher_loader.rb +17 -0
- data/lib/net/ssh/transport/cipher_factory.rb +122 -99
- data/lib/net/ssh/transport/constants.rb +32 -24
- data/lib/net/ssh/transport/ctr.rb +42 -22
- data/lib/net/ssh/transport/hmac/abstract.rb +81 -63
- data/lib/net/ssh/transport/hmac/md5.rb +0 -2
- data/lib/net/ssh/transport/hmac/md5_96.rb +0 -2
- data/lib/net/ssh/transport/hmac/none.rb +0 -2
- data/lib/net/ssh/transport/hmac/ripemd160.rb +0 -2
- data/lib/net/ssh/transport/hmac/sha1.rb +0 -2
- data/lib/net/ssh/transport/hmac/sha1_96.rb +0 -2
- data/lib/net/ssh/transport/hmac/sha2_256.rb +7 -11
- data/lib/net/ssh/transport/hmac/sha2_256_96.rb +4 -8
- data/lib/net/ssh/transport/hmac/sha2_256_etm.rb +12 -0
- data/lib/net/ssh/transport/hmac/sha2_512.rb +6 -9
- data/lib/net/ssh/transport/hmac/sha2_512_96.rb +4 -8
- data/lib/net/ssh/transport/hmac/sha2_512_etm.rb +12 -0
- data/lib/net/ssh/transport/hmac.rb +14 -12
- data/lib/net/ssh/transport/identity_cipher.rb +54 -44
- data/lib/net/ssh/transport/kex/abstract.rb +130 -0
- data/lib/net/ssh/transport/kex/abstract5656.rb +72 -0
- data/lib/net/ssh/transport/kex/curve25519_sha256.rb +39 -0
- data/lib/net/ssh/transport/kex/curve25519_sha256_loader.rb +30 -0
- data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha1.rb +33 -40
- data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha256.rb +11 -0
- data/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +119 -213
- data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +53 -61
- data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha256.rb +5 -9
- data/lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb +36 -90
- data/lib/net/ssh/transport/kex/ecdh_sha2_nistp384.rb +18 -10
- data/lib/net/ssh/transport/kex/ecdh_sha2_nistp521.rb +18 -10
- data/lib/net/ssh/transport/kex.rb +15 -12
- data/lib/net/ssh/transport/key_expander.rb +24 -20
- data/lib/net/ssh/transport/openssl.rb +161 -124
- data/lib/net/ssh/transport/openssl_cipher_extensions.rb +8 -0
- data/lib/net/ssh/transport/packet_stream.rb +246 -185
- data/lib/net/ssh/transport/server_version.rb +55 -56
- data/lib/net/ssh/transport/session.rb +306 -255
- data/lib/net/ssh/transport/state.rb +178 -176
- data/lib/net/ssh/verifiers/accept_new.rb +33 -0
- data/lib/net/ssh/verifiers/accept_new_or_local_tunnel.rb +33 -0
- data/lib/net/ssh/verifiers/always.rb +58 -0
- data/lib/net/ssh/verifiers/never.rb +19 -0
- data/lib/net/ssh/version.rb +55 -53
- data/lib/net/ssh.rb +111 -47
- data/net-ssh-public_cert.pem +18 -18
- data/net-ssh.gemspec +38 -205
- data/support/ssh_tunnel_bug.rb +5 -5
- data.tar.gz.sig +0 -0
- metadata +173 -118
- metadata.gz.sig +0 -0
- data/.travis.yml +0 -18
- data/README.rdoc +0 -182
- data/lib/net/ssh/authentication/agent/java_pageant.rb +0 -85
- data/lib/net/ssh/authentication/agent/socket.rb +0 -178
- data/lib/net/ssh/ruby_compat.rb +0 -46
- data/lib/net/ssh/verifiers/lenient.rb +0 -30
- data/lib/net/ssh/verifiers/null.rb +0 -12
- data/lib/net/ssh/verifiers/secure.rb +0 -52
- data/lib/net/ssh/verifiers/strict.rb +0 -24
- data/setup.rb +0 -1585
- data/support/arcfour_check.rb +0 -20
- data/test/README.txt +0 -18
- data/test/authentication/methods/common.rb +0 -28
- data/test/authentication/methods/test_abstract.rb +0 -51
- data/test/authentication/methods/test_hostbased.rb +0 -114
- data/test/authentication/methods/test_keyboard_interactive.rb +0 -121
- data/test/authentication/methods/test_none.rb +0 -41
- data/test/authentication/methods/test_password.rb +0 -95
- data/test/authentication/methods/test_publickey.rb +0 -148
- data/test/authentication/test_agent.rb +0 -232
- data/test/authentication/test_key_manager.rb +0 -240
- data/test/authentication/test_session.rb +0 -107
- data/test/common.rb +0 -125
- data/test/configs/auth_off +0 -5
- data/test/configs/auth_on +0 -4
- data/test/configs/empty +0 -0
- data/test/configs/eqsign +0 -3
- data/test/configs/exact_match +0 -8
- data/test/configs/host_plus +0 -10
- data/test/configs/multihost +0 -4
- data/test/configs/negative_match +0 -6
- data/test/configs/nohost +0 -19
- data/test/configs/numeric_host +0 -4
- data/test/configs/proxy_remote_user +0 -2
- data/test/configs/send_env +0 -2
- data/test/configs/substitutes +0 -8
- data/test/configs/wild_cards +0 -14
- data/test/connection/test_channel.rb +0 -487
- data/test/connection/test_session.rb +0 -564
- data/test/integration/README.txt +0 -17
- data/test/integration/Vagrantfile +0 -12
- data/test/integration/common.rb +0 -63
- data/test/integration/playbook.yml +0 -56
- data/test/integration/test_forward.rb +0 -637
- data/test/integration/test_id_rsa_keys.rb +0 -96
- data/test/integration/test_proxy.rb +0 -93
- data/test/known_hosts/github +0 -1
- data/test/known_hosts/github_hash +0 -1
- data/test/manual/test_pageant.rb +0 -37
- data/test/start/test_connection.rb +0 -53
- data/test/start/test_options.rb +0 -57
- data/test/start/test_transport.rb +0 -28
- data/test/start/test_user_nil.rb +0 -27
- data/test/test_all.rb +0 -12
- data/test/test_buffer.rb +0 -433
- data/test/test_buffered_io.rb +0 -63
- data/test/test_config.rb +0 -268
- data/test/test_key_factory.rb +0 -191
- data/test/test_known_hosts.rb +0 -66
- data/test/transport/hmac/test_md5.rb +0 -41
- data/test/transport/hmac/test_md5_96.rb +0 -27
- data/test/transport/hmac/test_none.rb +0 -34
- data/test/transport/hmac/test_ripemd160.rb +0 -36
- data/test/transport/hmac/test_sha1.rb +0 -36
- data/test/transport/hmac/test_sha1_96.rb +0 -27
- data/test/transport/hmac/test_sha2_256.rb +0 -37
- data/test/transport/hmac/test_sha2_256_96.rb +0 -27
- data/test/transport/hmac/test_sha2_512.rb +0 -37
- data/test/transport/hmac/test_sha2_512_96.rb +0 -27
- data/test/transport/kex/test_diffie_hellman_group14_sha1.rb +0 -13
- data/test/transport/kex/test_diffie_hellman_group1_sha1.rb +0 -150
- data/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +0 -96
- data/test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb +0 -19
- data/test/transport/kex/test_ecdh_sha2_nistp256.rb +0 -161
- data/test/transport/kex/test_ecdh_sha2_nistp384.rb +0 -38
- data/test/transport/kex/test_ecdh_sha2_nistp521.rb +0 -38
- data/test/transport/test_algorithms.rb +0 -328
- data/test/transport/test_cipher_factory.rb +0 -443
- data/test/transport/test_hmac.rb +0 -34
- data/test/transport/test_identity_cipher.rb +0 -40
- data/test/transport/test_packet_stream.rb +0 -1762
- data/test/transport/test_server_version.rb +0 -74
- data/test/transport/test_session.rb +0 -331
- data/test/transport/test_state.rb +0 -181
- data/test/verifiers/test_secure.rb +0 -40
@@ -1,96 +0,0 @@
|
|
1
|
-
require 'common'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'tmpdir'
|
4
|
-
|
5
|
-
require 'net/ssh'
|
6
|
-
|
7
|
-
# see Vagrantfile,playbook for env.
|
8
|
-
# we're running as net_ssh_1 user password foo
|
9
|
-
# and usually connecting to net_ssh_2 user password foo2pwd
|
10
|
-
class TestIDRSAPKeys < Test::Unit::TestCase
|
11
|
-
include IntegrationTestHelpers
|
12
|
-
|
13
|
-
def test_in_file_no_password
|
14
|
-
tmpdir do |dir|
|
15
|
-
sh "rm -rf #{dir}/id_rsa #{dir}/id_rsa.pub"
|
16
|
-
sh "ssh-keygen -f #{dir}/id_rsa -t rsa -N ''"
|
17
|
-
set_authorized_key('net_ssh_1',"#{dir}/id_rsa.pub")
|
18
|
-
|
19
|
-
sshopts = '-vvvv -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
20
|
-
#sh "ssh -i #{dir}/id_rsa #{sshopts} net_ssh_1@localhost echo 'hello'"
|
21
|
-
|
22
|
-
ret = Net::SSH.start("localhost", "net_ssh_1", {keys: "#{dir}/id_rsa"}) do |ssh|
|
23
|
-
ssh.exec! 'echo "hello from:$USER"'
|
24
|
-
end
|
25
|
-
assert_equal "hello from:net_ssh_1\n", ret
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
def test_ssh_agent
|
31
|
-
tmpdir do |dir|
|
32
|
-
with_agent do
|
33
|
-
sh "rm -rf #{dir}/id_rsa #{dir}/id_rsa.pub"
|
34
|
-
sh "ssh-keygen -f #{dir}/id_rsa -t rsa -N 'pwd123'"
|
35
|
-
set_authorized_key('net_ssh_1',"#{dir}/id_rsa.pub")
|
36
|
-
ssh_add("#{dir}/id_rsa","pwd123")
|
37
|
-
|
38
|
-
ret = Net::SSH.start("localhost", "net_ssh_1",verbose: :debug) do |ssh|
|
39
|
-
ssh.exec! 'echo "hello from:$USER"'
|
40
|
-
end
|
41
|
-
assert_equal "hello from:net_ssh_1\n", ret
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_ssh_agent_ignores_if_already_in_agent
|
47
|
-
tmpdir do |dir|
|
48
|
-
with_agent do
|
49
|
-
sh "rm -rf #{dir}/id_rsa #{dir}/id_rsa.pub"
|
50
|
-
sh "ssh-keygen -f #{dir}/id_rsa -t rsa -N 'pwd123'"
|
51
|
-
set_authorized_key('net_ssh_1',"#{dir}/id_rsa.pub")
|
52
|
-
ssh_add("#{dir}/id_rsa","pwd123")
|
53
|
-
|
54
|
-
ret = Net::SSH.start("localhost", "net_ssh_1",verbose: :debug, keys: ["#{dir}/id_rsa"]) do |ssh|
|
55
|
-
ssh.exec! 'echo "hello from:$USER"'
|
56
|
-
end
|
57
|
-
assert_equal "hello from:net_ssh_1\n", ret
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_in_file_with_password
|
63
|
-
tmpdir do |dir|
|
64
|
-
sh "rm -rf #{dir}/id_rsa #{dir}/id_rsa.pub"
|
65
|
-
sh "ssh-keygen -f #{dir}/id_rsa -t rsa -N 'pwd12'"
|
66
|
-
set_authorized_key('net_ssh_1',"#{dir}/id_rsa.pub")
|
67
|
-
|
68
|
-
sshopts = '-vvvv -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
69
|
-
#sh "ssh -i #{dir}/id_rsa #{sshopts} net_ssh_1@localhost echo 'hello'"
|
70
|
-
|
71
|
-
ret = Net::SSH.start("localhost", "net_ssh_1", {keys: "#{dir}/id_rsa",
|
72
|
-
passphrase: 'pwd12', verbose: :debug}) do |ssh|
|
73
|
-
ssh.exec! 'echo "hello from:$USER"'
|
74
|
-
end
|
75
|
-
assert_equal "hello from:net_ssh_1\n", ret
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_asks_for_passwords_when_read_from_memory
|
80
|
-
tmpdir do |dir|
|
81
|
-
sh "rm -rf #{dir}/id_rsa #{dir}/id_rsa.pub"
|
82
|
-
sh "ssh-keygen -f #{dir}/id_rsa -t rsa -N 'pwd12'"
|
83
|
-
set_authorized_key('net_ssh_1',"#{dir}/id_rsa.pub")
|
84
|
-
private_key = File.read("#{dir}/id_rsa")
|
85
|
-
|
86
|
-
options = {keys: [], key_data: [private_key]}
|
87
|
-
|
88
|
-
key_manager = Net::SSH::Authentication::KeyManager.new(nil, options)
|
89
|
-
|
90
|
-
Net::SSH::KeyFactory.expects(:prompt).with('Enter passphrase for :', false).returns('pwd12')
|
91
|
-
Net::SSH.start("localhost", "net_ssh_1", options) do |ssh|
|
92
|
-
ssh.exec! 'whoami'
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
require_relative './common'
|
2
|
-
require 'net/ssh/buffer'
|
3
|
-
require 'net/ssh'
|
4
|
-
require 'timeout'
|
5
|
-
require 'tempfile'
|
6
|
-
require 'net/ssh/proxy/command'
|
7
|
-
|
8
|
-
class TestProxy < Test::Unit::TestCase
|
9
|
-
include IntegrationTestHelpers
|
10
|
-
|
11
|
-
def localhost
|
12
|
-
'localhost'
|
13
|
-
end
|
14
|
-
|
15
|
-
def user
|
16
|
-
'net_ssh_1'
|
17
|
-
end
|
18
|
-
|
19
|
-
def ssh_start_params(options)
|
20
|
-
[localhost ,user , {:keys => @key_id_rsa, :verbose => :debug}.merge(options)]
|
21
|
-
end
|
22
|
-
|
23
|
-
def setup_ssh_env(&block)
|
24
|
-
tmpdir do |dir|
|
25
|
-
@key_id_rsa = "#{dir}/id_rsa"
|
26
|
-
sh "rm -rf #{@key_id_rsa} #{@key_id_rsa}.pub"
|
27
|
-
sh "ssh-keygen -f #{@key_id_rsa} -t rsa -N ''"
|
28
|
-
set_authorized_key(user,"#{@key_id_rsa}.pub")
|
29
|
-
yield
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_smoke
|
34
|
-
setup_ssh_env do
|
35
|
-
proxy = Net::SSH::Proxy::Command.new("/bin/nc localhost 22")
|
36
|
-
msg = 'echo123'
|
37
|
-
ret = Net::SSH.start(*ssh_start_params(:proxy => proxy)) do |ssh|
|
38
|
-
ssh.exec! "echo \"$USER:#{msg}\""
|
39
|
-
end
|
40
|
-
assert_equal "net_ssh_1:#{msg}\n", ret
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def with_spurious_write_wakeup_emulate(rate=99,&block)
|
45
|
-
orig_io_select = Net::SSH::Compat.method(:io_select)
|
46
|
-
count = 0
|
47
|
-
Net::SSH::Compat.singleton_class.send(:define_method,:io_select) do |*params|
|
48
|
-
count += 1
|
49
|
-
if (count % rate != 0)
|
50
|
-
if params && params[1] && !params[1].empty?
|
51
|
-
return [[],params[1],[]]
|
52
|
-
end
|
53
|
-
#if params && params[0] && !params[0].empty?
|
54
|
-
#return [params[0],[],[]]
|
55
|
-
#end
|
56
|
-
end
|
57
|
-
IO.select(*params)
|
58
|
-
end
|
59
|
-
begin
|
60
|
-
yield
|
61
|
-
ensure
|
62
|
-
Net::SSH::Compat.singleton_class.send(:define_method,:io_select,&orig_io_select)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_with_rate_limit_and_spurious_wakeup
|
67
|
-
system("sudo sh -c 'echo 4096 > /proc/sys/fs/pipe-max-size'")
|
68
|
-
begin
|
69
|
-
setup_ssh_env do
|
70
|
-
proxy = Net::SSH::Proxy::Command.new("/usr/bin/pv --rate-limit 100k | /bin/nc localhost 22")
|
71
|
-
#proxy = Net::SSH::Proxy::Command.new("/bin/nc localhost 22")
|
72
|
-
begin
|
73
|
-
large_msg = 'echo123'*30000
|
74
|
-
ok = Net::SSH.start(*ssh_start_params(:proxy => proxy)) do |ssh|
|
75
|
-
with_spurious_write_wakeup_emulate do
|
76
|
-
ret = ssh.exec! "echo \"$USER:#{large_msg}\""
|
77
|
-
#assert_equal "net_ssh_1:#{large_msg}\n", ret
|
78
|
-
assert_equal "/bin/sh: Argument list too long\n", ret
|
79
|
-
hello_count = 1000
|
80
|
-
ret = ssh.exec! "ruby -e 'puts \"Hello\"*#{hello_count}'"
|
81
|
-
assert_equal "Hello"*hello_count+"\n", ret
|
82
|
-
end
|
83
|
-
:ok
|
84
|
-
end
|
85
|
-
end
|
86
|
-
assert_equal :ok, ok
|
87
|
-
end
|
88
|
-
ensure
|
89
|
-
system("sudo sh -c 'echo 1048576 > /proc/sys/fs/pipe-max-size'")
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
data/test/known_hosts/github
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
|
@@ -1 +0,0 @@
|
|
1
|
-
|1|eKp+6E0rZ3lONgsIziurXEnaIik=|rcQB/rlJMUquUyFta64KugPjX4o= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
|
data/test/manual/test_pageant.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Tests for communication capability with Pageant (or KeeAgent)
|
3
|
-
# process, to include the case where it is running in different UAC
|
4
|
-
# context.
|
5
|
-
#
|
6
|
-
# To run:
|
7
|
-
# - Ensure that Pageant is running (not as administrator).
|
8
|
-
# - Open two command prompts, one as an administrator and one limited
|
9
|
-
# (normal).
|
10
|
-
# - Within each, from the root net/ssh project directory, execute:
|
11
|
-
# ruby -Ilib -Itest -rrubygems test/manual/test_pageant.rb
|
12
|
-
#
|
13
|
-
|
14
|
-
require 'common'
|
15
|
-
require 'net/ssh/authentication/agent'
|
16
|
-
|
17
|
-
module Authentication
|
18
|
-
|
19
|
-
class TestPageant < Test::Unit::TestCase
|
20
|
-
|
21
|
-
def test_agent_should_be_able_to_negotiate
|
22
|
-
assert_nothing_raised(Net::SSH::Authentication::AgentNotAvailable) { agent.negotiate! }
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def agent(auto=:connect)
|
28
|
-
@agent ||= begin
|
29
|
-
agent = Net::SSH::Authentication::Agent.new
|
30
|
-
agent.connect! if auto == :connect
|
31
|
-
agent
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'common'
|
2
|
-
require 'net/ssh'
|
3
|
-
|
4
|
-
module NetSSH
|
5
|
-
class TestConnection < Test::Unit::TestCase
|
6
|
-
attr_reader :connection_session
|
7
|
-
|
8
|
-
def setup
|
9
|
-
authentication_session = mock('authentication_session')
|
10
|
-
authentication_session.stubs(:authenticate).returns(true)
|
11
|
-
Net::SSH::Authentication::Session.stubs(:new).returns(authentication_session)
|
12
|
-
Net::SSH::Transport::Session.stubs(:new).returns(mock('transport_session'))
|
13
|
-
@connection_session = mock('connection_session')
|
14
|
-
Net::SSH::Connection::Session.expects(:new => connection_session)
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_close_connection_on_exception
|
18
|
-
@connection_session.expects(:closed?).returns(false)
|
19
|
-
@connection_session.expects(:close).once
|
20
|
-
|
21
|
-
begin
|
22
|
-
Net::SSH.start('localhost', 'testuser') { raise "error" }
|
23
|
-
rescue RuntimeError
|
24
|
-
# We aren't interested in the exception
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_close_connection_on_exception_only_if_still_open
|
29
|
-
conn_open = states('conn').starts_as(true)
|
30
|
-
@connection_session.expects(:close).then(conn_open.is(false)).once
|
31
|
-
@connection_session.expects(:closed?).when(conn_open.is(false)).returns(true)
|
32
|
-
|
33
|
-
begin
|
34
|
-
Net::SSH.start('localhost', 'testuser') do |ssh|
|
35
|
-
ssh.close
|
36
|
-
raise "error"
|
37
|
-
end
|
38
|
-
rescue RuntimeError
|
39
|
-
# We aren't interested in the exception
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_return_value_is_returned
|
44
|
-
@connection_session.expects(:closed?).returns(false)
|
45
|
-
@connection_session.expects(:close).once
|
46
|
-
|
47
|
-
val = 1
|
48
|
-
retval = Net::SSH.start('localhost', 'testuser') { val }
|
49
|
-
assert_equal(val, retval)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
data/test/start/test_options.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'common'
|
2
|
-
require 'net/ssh'
|
3
|
-
|
4
|
-
module NetSSH
|
5
|
-
class TestStartOptions < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
authentication_session = mock('authentication_session')
|
8
|
-
authentication_session.stubs(:authenticate).returns(true)
|
9
|
-
Net::SSH::Authentication::Session.stubs(:new).returns(authentication_session)
|
10
|
-
Net::SSH::Transport::Session.stubs(:new).returns(mock('transport_session'))
|
11
|
-
Net::SSH::Connection::Session.stubs(:new).returns(mock('connection_session'))
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_start_should_accept_keepalive_option
|
15
|
-
assert_nothing_raised do
|
16
|
-
options = { :keepalive => true }
|
17
|
-
Net::SSH.start('localhost', 'testuser', options)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_start_should_accept_keepalive_interval_option
|
22
|
-
assert_nothing_raised do
|
23
|
-
options = { :keepalive_interval => 10 }
|
24
|
-
Net::SSH.start('localhost', 'testuser', options)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_start_should_accept_send_env_option
|
29
|
-
assert_nothing_raised do
|
30
|
-
options = { :send_env => [ /^LC_.*$/, "LANG" ] }
|
31
|
-
Net::SSH.start('localhost', 'testuser', options)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_start_should_accept_number_of_password_prompts_option
|
36
|
-
assert_nothing_raised do
|
37
|
-
options = { :number_of_password_prompts => 2 }
|
38
|
-
Net::SSH.start('localhost', 'testuser', options)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_start_should_accept_non_interactive_option
|
43
|
-
assert_nothing_raised do
|
44
|
-
options = { :non_interactive => true }
|
45
|
-
Net::SSH.start('localhost', 'testuser', options)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_start_should_accept_remote_user_option
|
50
|
-
assert_nothing_raised do
|
51
|
-
options = { :remote_user => 'foo' }
|
52
|
-
Net::SSH.start('localhost', 'testuser', options)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'common'
|
2
|
-
require 'net/ssh'
|
3
|
-
|
4
|
-
module NetSSH
|
5
|
-
class TestStart < Test::Unit::TestCase
|
6
|
-
attr_reader :transport_session
|
7
|
-
attr_reader :authentication_session
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@transport_session = mock('transport_session')
|
11
|
-
@authentication_session = mock('authentication_session')
|
12
|
-
Net::SSH::Transport::Session.expects(:new => transport_session)
|
13
|
-
Net::SSH::Authentication::Session.expects(:new => authentication_session)
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_close_transport_when_authentication_fails
|
17
|
-
authentication_session.expects(:authenticate => false)
|
18
|
-
|
19
|
-
transport_session.expects(:close).at_least_once
|
20
|
-
|
21
|
-
begin
|
22
|
-
Net::SSH.start('localhost', 'testuser') {}
|
23
|
-
rescue Net::SSH::AuthenticationFailed
|
24
|
-
# Authentication should fail, as it is part of the context
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/test/start/test_user_nil.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'common'
|
2
|
-
require 'net/ssh'
|
3
|
-
|
4
|
-
module NetSSH
|
5
|
-
class TestStartUserNil < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
@authentication_session = mock('authentication_session')
|
8
|
-
Net::SSH::Authentication::Session.stubs(:new).returns(@authentication_session)
|
9
|
-
Net::SSH::Transport::Session.stubs(:new).returns(mock('transport_session'))
|
10
|
-
Net::SSH::Connection::Session.stubs(:new).returns(mock('connection_session'))
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_start_should_accept_nil_user
|
14
|
-
@authentication_session.stubs(:authenticate).returns(true)
|
15
|
-
assert_nothing_raised do
|
16
|
-
Net::SSH.start('localhost')
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_start_should_use_default_user_when_nil
|
21
|
-
@authentication_session.stubs(:authenticate).with() {|_next_service, user, _password| user == Etc.getlogin }.returns(true)
|
22
|
-
assert_nothing_raised do
|
23
|
-
Net::SSH.start('localhost')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/test/test_all.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
$: << '.'
|
2
|
-
|
3
|
-
# $ ruby -Ilib -Itest -rrubygems test/test_all.rb
|
4
|
-
# $ ruby -Ilib -Itest -rrubygems test/transport/test_server_version.rb
|
5
|
-
Dir.chdir(File.dirname(__FILE__)) do
|
6
|
-
test_files = Dir['**/test_*.rb']-['test_all.rb'] # prevent circular require
|
7
|
-
test_files -= Dir['integration/test_*.rb'] unless ENV['NET_SSH_RUN_INTEGRATION_TESTS']
|
8
|
-
test_files = test_files.reject { |f| f =~ /^manual/ }
|
9
|
-
test_files = test_files.select { |f| f =~ Regexp.new(ENV['ONLY']) } if ENV['ONLY']
|
10
|
-
test_files = test_files.reject { |f| f =~ Regexp.new(ENV['EXCEPT']) } if ENV['EXCEPT']
|
11
|
-
test_files.each { |file| require(file) }
|
12
|
-
end
|