net-ssh 4.0.0.alpha1 → 4.0.0.alpha2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.gitignore +6 -0
- data/.travis.yml +10 -7
- data/CHANGES.txt +4 -0
- data/Gemfile +2 -15
- data/README.rdoc +6 -37
- data/Rakefile +5 -57
- data/lib/net/ssh/connection/session.rb +13 -0
- data/lib/net/ssh/ruby_compat.rb +2 -24
- data/lib/net/ssh/version.rb +1 -1
- data/net-ssh.gemspec +34 -225
- metadata +26 -100
- metadata.gz.sig +0 -0
- 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 -224
- data/test/authentication/test_ed25519.rb +0 -77
- data/test/authentication/test_key_manager.rb +0 -240
- data/test/authentication/test_session.rb +0 -107
- data/test/common.rb +0 -109
- 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 -563
- data/test/integration/README.md +0 -18
- data/test/integration/Vagrantfile +0 -12
- data/test/integration/common.rb +0 -65
- data/test/integration/playbook.yml +0 -57
- data/test/integration/test_ed25519_pkeys.rb +0 -70
- data/test/integration/test_forward.rb +0 -532
- 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 -324
- 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 -1186
- 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
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.
|
4
|
+
version: 4.0.0.alpha2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamis Buck
|
8
8
|
- Delano Mandelbaum
|
9
9
|
- Miklós Fazekas
|
10
10
|
autorequire:
|
11
|
-
bindir:
|
11
|
+
bindir: exe
|
12
12
|
cert_chain:
|
13
13
|
- |
|
14
14
|
-----BEGIN CERTIFICATE-----
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
s/ZUKye79ELwFYKJOhjW5g725OL3hy+llhEleytwKRwgXFQBPTC4f5UkdxZVVWGH
|
32
32
|
e2C9M1m/2odPZo8h
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2016-03-
|
34
|
+
date: 2016-03-26 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rbnacl-libsodium
|
@@ -76,71 +76,73 @@ dependencies:
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 1.0.0.alpha1
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
79
|
+
name: bundler
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- - "
|
82
|
+
- - "~>"
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: '
|
84
|
+
version: '1.11'
|
85
85
|
type: :development
|
86
86
|
prerelease: false
|
87
87
|
version_requirements: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- - "
|
89
|
+
- - "~>"
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: '
|
91
|
+
version: '1.11'
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
|
-
name:
|
93
|
+
name: rake
|
94
94
|
requirement: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
|
-
- - "
|
96
|
+
- - "~>"
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version:
|
98
|
+
version: '11.1'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
101
|
version_requirements: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- - "
|
103
|
+
- - "~>"
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version:
|
105
|
+
version: '11.1'
|
106
106
|
- !ruby/object:Gem::Dependency
|
107
|
-
name:
|
107
|
+
name: minitest
|
108
108
|
requirement: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
|
-
- - "
|
110
|
+
- - "~>"
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version: '0'
|
112
|
+
version: '5.0'
|
113
113
|
type: :development
|
114
114
|
prerelease: false
|
115
115
|
version_requirements: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- - "
|
117
|
+
- - "~>"
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version: '0'
|
119
|
+
version: '5.0'
|
120
120
|
- !ruby/object:Gem::Dependency
|
121
|
-
name:
|
121
|
+
name: mocha
|
122
122
|
requirement: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
124
|
- - ">="
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
version:
|
126
|
+
version: 1.1.0
|
127
127
|
type: :development
|
128
128
|
prerelease: false
|
129
129
|
version_requirements: !ruby/object:Gem::Requirement
|
130
130
|
requirements:
|
131
131
|
- - ">="
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
133
|
+
version: 1.1.0
|
134
134
|
description: 'Net::SSH: a pure-Ruby implementation of the SSH2 client protocol. It
|
135
135
|
allows you to write programs that invoke and interact with processes on remote servers,
|
136
136
|
via SSH2.'
|
137
|
-
email:
|
137
|
+
email:
|
138
|
+
- net-ssh@solutious.com
|
138
139
|
executables: []
|
139
140
|
extensions: []
|
140
141
|
extra_rdoc_files:
|
141
142
|
- LICENSE.txt
|
142
143
|
- README.rdoc
|
143
144
|
files:
|
145
|
+
- ".gitignore"
|
144
146
|
- ".travis.yml"
|
145
147
|
- CHANGES.txt
|
146
148
|
- Gemfile
|
@@ -235,82 +237,6 @@ files:
|
|
235
237
|
- setup.rb
|
236
238
|
- support/arcfour_check.rb
|
237
239
|
- support/ssh_tunnel_bug.rb
|
238
|
-
- test/README.txt
|
239
|
-
- test/authentication/methods/common.rb
|
240
|
-
- test/authentication/methods/test_abstract.rb
|
241
|
-
- test/authentication/methods/test_hostbased.rb
|
242
|
-
- test/authentication/methods/test_keyboard_interactive.rb
|
243
|
-
- test/authentication/methods/test_none.rb
|
244
|
-
- test/authentication/methods/test_password.rb
|
245
|
-
- test/authentication/methods/test_publickey.rb
|
246
|
-
- test/authentication/test_agent.rb
|
247
|
-
- test/authentication/test_ed25519.rb
|
248
|
-
- test/authentication/test_key_manager.rb
|
249
|
-
- test/authentication/test_session.rb
|
250
|
-
- test/common.rb
|
251
|
-
- test/configs/auth_off
|
252
|
-
- test/configs/auth_on
|
253
|
-
- test/configs/empty
|
254
|
-
- test/configs/eqsign
|
255
|
-
- test/configs/exact_match
|
256
|
-
- test/configs/host_plus
|
257
|
-
- test/configs/multihost
|
258
|
-
- test/configs/negative_match
|
259
|
-
- test/configs/nohost
|
260
|
-
- test/configs/numeric_host
|
261
|
-
- test/configs/proxy_remote_user
|
262
|
-
- test/configs/send_env
|
263
|
-
- test/configs/substitutes
|
264
|
-
- test/configs/wild_cards
|
265
|
-
- test/connection/test_channel.rb
|
266
|
-
- test/connection/test_session.rb
|
267
|
-
- test/integration/README.md
|
268
|
-
- test/integration/Vagrantfile
|
269
|
-
- test/integration/common.rb
|
270
|
-
- test/integration/playbook.yml
|
271
|
-
- test/integration/test_ed25519_pkeys.rb
|
272
|
-
- test/integration/test_forward.rb
|
273
|
-
- test/integration/test_id_rsa_keys.rb
|
274
|
-
- test/integration/test_proxy.rb
|
275
|
-
- test/known_hosts/github
|
276
|
-
- test/known_hosts/github_hash
|
277
|
-
- test/manual/test_pageant.rb
|
278
|
-
- test/start/test_connection.rb
|
279
|
-
- test/start/test_options.rb
|
280
|
-
- test/start/test_transport.rb
|
281
|
-
- test/start/test_user_nil.rb
|
282
|
-
- test/test_all.rb
|
283
|
-
- test/test_buffer.rb
|
284
|
-
- test/test_buffered_io.rb
|
285
|
-
- test/test_config.rb
|
286
|
-
- test/test_key_factory.rb
|
287
|
-
- test/test_known_hosts.rb
|
288
|
-
- test/transport/hmac/test_md5.rb
|
289
|
-
- test/transport/hmac/test_md5_96.rb
|
290
|
-
- test/transport/hmac/test_none.rb
|
291
|
-
- test/transport/hmac/test_ripemd160.rb
|
292
|
-
- test/transport/hmac/test_sha1.rb
|
293
|
-
- test/transport/hmac/test_sha1_96.rb
|
294
|
-
- test/transport/hmac/test_sha2_256.rb
|
295
|
-
- test/transport/hmac/test_sha2_256_96.rb
|
296
|
-
- test/transport/hmac/test_sha2_512.rb
|
297
|
-
- test/transport/hmac/test_sha2_512_96.rb
|
298
|
-
- test/transport/kex/test_diffie_hellman_group14_sha1.rb
|
299
|
-
- test/transport/kex/test_diffie_hellman_group1_sha1.rb
|
300
|
-
- test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb
|
301
|
-
- test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb
|
302
|
-
- test/transport/kex/test_ecdh_sha2_nistp256.rb
|
303
|
-
- test/transport/kex/test_ecdh_sha2_nistp384.rb
|
304
|
-
- test/transport/kex/test_ecdh_sha2_nistp521.rb
|
305
|
-
- test/transport/test_algorithms.rb
|
306
|
-
- test/transport/test_cipher_factory.rb
|
307
|
-
- test/transport/test_hmac.rb
|
308
|
-
- test/transport/test_identity_cipher.rb
|
309
|
-
- test/transport/test_packet_stream.rb
|
310
|
-
- test/transport/test_server_version.rb
|
311
|
-
- test/transport/test_session.rb
|
312
|
-
- test/transport/test_state.rb
|
313
|
-
- test/verifiers/test_secure.rb
|
314
240
|
homepage: https://github.com/net-ssh/net-ssh
|
315
241
|
licenses:
|
316
242
|
- MIT
|
@@ -330,8 +256,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
330
256
|
- !ruby/object:Gem::Version
|
331
257
|
version: 1.3.1
|
332
258
|
requirements: []
|
333
|
-
rubyforge_project:
|
334
|
-
rubygems_version: 2.
|
259
|
+
rubyforge_project:
|
260
|
+
rubygems_version: 2.5.1
|
335
261
|
signing_key:
|
336
262
|
specification_version: 4
|
337
263
|
summary: 'Net::SSH: a pure-Ruby implementation of the SSH2 client protocol.'
|
metadata.gz.sig
CHANGED
Binary file
|
data/test/README.txt
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
RUNNING TESTS
|
2
|
-
|
3
|
-
Run the test suite from the net-ssh directory with the following command:
|
4
|
-
|
5
|
-
ruby -Ilib -Itest test/test_all.rb
|
6
|
-
|
7
|
-
Run a single test file like this:
|
8
|
-
|
9
|
-
ruby -Ilib -Itest test/transport/test_server_version.rb
|
10
|
-
|
11
|
-
EXPECTED RESULTS
|
12
|
-
|
13
|
-
https://travis-ci.org/net-ssh/net-ssh/
|
14
|
-
|
15
|
-
INTEGRATION TESTS
|
16
|
-
|
17
|
-
brew install ansible ; ansible-galaxy install rvm_io.rvm1-ruby ; vagrant up ; vagrant ssh
|
18
|
-
cd /net-ssh ; rake integration-test
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Authentication; module Methods
|
2
|
-
|
3
|
-
module Common
|
4
|
-
include Net::SSH::Authentication::Constants
|
5
|
-
|
6
|
-
private
|
7
|
-
|
8
|
-
def socket(options={})
|
9
|
-
@socket ||= stub("socket", :client_name => "me.ssh.test")
|
10
|
-
end
|
11
|
-
|
12
|
-
def transport(options={})
|
13
|
-
@transport ||= MockTransport.new(options.merge(:socket => socket))
|
14
|
-
end
|
15
|
-
|
16
|
-
def session(options={})
|
17
|
-
@session ||= begin
|
18
|
-
sess = stub("auth-session", :logger => nil, :transport => transport(options))
|
19
|
-
def sess.next_message
|
20
|
-
transport.next_message
|
21
|
-
end
|
22
|
-
sess
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
end; end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'common'
|
2
|
-
require 'authentication/methods/common'
|
3
|
-
require 'net/ssh/authentication/methods/abstract'
|
4
|
-
|
5
|
-
module Authentication; module Methods
|
6
|
-
|
7
|
-
class TestAbstract < Test::Unit::TestCase
|
8
|
-
include Common
|
9
|
-
|
10
|
-
def test_constructor_should_set_defaults
|
11
|
-
assert_nil subject.key_manager
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_constructor_should_honor_options
|
15
|
-
assert_equal :manager, subject(:key_manager => :manager).key_manager
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_session_id_should_query_session_id_from_key_exchange
|
19
|
-
transport.stubs(:algorithms).returns(stub("algorithms", :session_id => "abcxyz123"))
|
20
|
-
assert_equal "abcxyz123", subject.session_id
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_send_message_should_delegate_to_transport
|
24
|
-
transport.expects(:send_message).with("abcxyz123")
|
25
|
-
subject.send_message("abcxyz123")
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_userauth_request_should_build_well_formed_userauth_packet
|
29
|
-
packet = subject.userauth_request("jamis", "ssh-connection", "password")
|
30
|
-
assert_equal "\062\0\0\0\005jamis\0\0\0\016ssh-connection\0\0\0\010password", packet.to_s
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_userauth_request_should_translate_extra_booleans_onto_end
|
34
|
-
packet = subject.userauth_request("jamis", "ssh-connection", "password", true, false)
|
35
|
-
assert_equal "\062\0\0\0\005jamis\0\0\0\016ssh-connection\0\0\0\010password\1\0", packet.to_s
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_userauth_request_should_translate_extra_strings_onto_end
|
39
|
-
packet = subject.userauth_request("jamis", "ssh-connection", "password", "foo", "bar")
|
40
|
-
assert_equal "\062\0\0\0\005jamis\0\0\0\016ssh-connection\0\0\0\010password\0\0\0\3foo\0\0\0\3bar", packet.to_s
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def subject(options={})
|
46
|
-
@subject ||= Net::SSH::Authentication::Methods::Abstract.new(session(options), options)
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
end; end
|
@@ -1,114 +0,0 @@
|
|
1
|
-
require 'common'
|
2
|
-
require 'net/ssh/authentication/methods/hostbased'
|
3
|
-
require 'authentication/methods/common'
|
4
|
-
|
5
|
-
module Authentication; module Methods
|
6
|
-
|
7
|
-
class TestHostbased < Test::Unit::TestCase
|
8
|
-
include Common
|
9
|
-
|
10
|
-
def test_authenticate_should_return_false_when_no_key_manager_has_been_set
|
11
|
-
assert_equal false, subject(:key_manager => nil).authenticate("ssh-connection", "jamis")
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_authenticate_should_return_false_when_key_manager_has_no_keys
|
15
|
-
assert_equal false, subject(:keys => []).authenticate("ssh-connection", "jamis")
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_authenticate_should_return_false_if_no_keys_can_authenticate
|
19
|
-
ENV.stubs(:[]).with('USER').returns(nil)
|
20
|
-
key_manager.expects(:sign).with(&signature_parameters(keys.first)).returns("sig-one")
|
21
|
-
key_manager.expects(:sign).with(&signature_parameters(keys.last)).returns("sig-two")
|
22
|
-
|
23
|
-
transport.expect do |t, packet|
|
24
|
-
assert_equal USERAUTH_REQUEST, packet.type
|
25
|
-
assert verify_userauth_request_packet(packet, keys.first)
|
26
|
-
assert_equal "sig-one", packet.read_string
|
27
|
-
t.return(USERAUTH_FAILURE, :string, "hostbased,password")
|
28
|
-
|
29
|
-
t.expect do |t2, packet2|
|
30
|
-
assert_equal USERAUTH_REQUEST, packet2.type
|
31
|
-
assert verify_userauth_request_packet(packet2, keys.last)
|
32
|
-
assert_equal "sig-two", packet2.read_string
|
33
|
-
t2.return(USERAUTH_FAILURE, :string, "hostbased,password")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
assert_equal false, subject.authenticate("ssh-connection", "jamis")
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_authenticate_should_return_true_if_any_key_can_authenticate
|
41
|
-
ENV.stubs(:[]).with('USER').returns(nil)
|
42
|
-
key_manager.expects(:sign).with(&signature_parameters(keys.first)).returns("sig-one")
|
43
|
-
|
44
|
-
transport.expect do |t, packet|
|
45
|
-
assert_equal USERAUTH_REQUEST, packet.type
|
46
|
-
assert verify_userauth_request_packet(packet, keys.first)
|
47
|
-
assert_equal "sig-one", packet.read_string
|
48
|
-
t.return(USERAUTH_SUCCESS)
|
49
|
-
end
|
50
|
-
|
51
|
-
assert subject.authenticate("ssh-connection", "jamis")
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
def signature_parameters(key)
|
57
|
-
Proc.new do |given_key, data|
|
58
|
-
next false unless given_key.to_blob == key.to_blob
|
59
|
-
buffer = Net::SSH::Buffer.new(data)
|
60
|
-
buffer.read_string == "abcxyz123" && # session-id
|
61
|
-
buffer.read_byte == USERAUTH_REQUEST && # type
|
62
|
-
verify_userauth_request_packet(buffer, key)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def verify_userauth_request_packet(packet, key)
|
67
|
-
packet.read_string == "jamis" && # user-name
|
68
|
-
packet.read_string == "ssh-connection" && # next service
|
69
|
-
packet.read_string == "hostbased" && # auth-method
|
70
|
-
packet.read_string == key.ssh_type && # key type
|
71
|
-
packet.read_buffer.read_key.to_blob == key.to_blob && # key
|
72
|
-
packet.read_string == "me.ssh.test." && # client hostname
|
73
|
-
packet.read_string == "jamis" # client username
|
74
|
-
end
|
75
|
-
|
76
|
-
@@keys = nil
|
77
|
-
def keys
|
78
|
-
@@keys ||= [OpenSSL::PKey::RSA.new(512), OpenSSL::PKey::DSA.new(512)]
|
79
|
-
end
|
80
|
-
|
81
|
-
def key_manager(options={})
|
82
|
-
@key_manager ||= begin
|
83
|
-
manager = stub("key_manager")
|
84
|
-
manager.stubs(:each_identity).multiple_yields(*(options[:keys] || keys))
|
85
|
-
manager
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def subject(options={})
|
90
|
-
options[:key_manager] = key_manager(options) unless options.key?(:key_manager)
|
91
|
-
@subject ||= Net::SSH::Authentication::Methods::Hostbased.new(session(options), options)
|
92
|
-
end
|
93
|
-
|
94
|
-
def socket(options={})
|
95
|
-
@socket ||= stub("socket", :client_name => "me.ssh.test")
|
96
|
-
end
|
97
|
-
|
98
|
-
def transport(options={})
|
99
|
-
@transport ||= MockTransport.new(options.merge(:socket => socket))
|
100
|
-
end
|
101
|
-
|
102
|
-
def session(options={})
|
103
|
-
@session ||= begin
|
104
|
-
sess = stub("auth-session", :logger => nil, :transport => transport(options))
|
105
|
-
def sess.next_message
|
106
|
-
transport.next_message
|
107
|
-
end
|
108
|
-
sess
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
end; end
|
@@ -1,121 +0,0 @@
|
|
1
|
-
require 'common'
|
2
|
-
require 'net/ssh/authentication/methods/keyboard_interactive'
|
3
|
-
require 'authentication/methods/common'
|
4
|
-
|
5
|
-
module Authentication; module Methods
|
6
|
-
|
7
|
-
class TestKeyboardInteractive < Test::Unit::TestCase
|
8
|
-
include Common
|
9
|
-
|
10
|
-
USERAUTH_INFO_REQUEST = 60
|
11
|
-
USERAUTH_INFO_RESPONSE = 61
|
12
|
-
|
13
|
-
def test_authenticate_should_raise_if_keyboard_interactive_disallowed
|
14
|
-
transport.expect do |t,packet|
|
15
|
-
assert_equal USERAUTH_REQUEST, packet.type
|
16
|
-
assert_equal "jamis", packet.read_string
|
17
|
-
assert_equal "ssh-connection", packet.read_string
|
18
|
-
assert_equal "keyboard-interactive", packet.read_string
|
19
|
-
assert_equal "", packet.read_string # language tags
|
20
|
-
assert_equal "", packet.read_string # submethods
|
21
|
-
|
22
|
-
t.return(USERAUTH_FAILURE, :string, "password")
|
23
|
-
end
|
24
|
-
|
25
|
-
assert_raises Net::SSH::Authentication::DisallowedMethod do
|
26
|
-
subject.authenticate("ssh-connection", "jamis")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_authenticate_should_be_false_if_given_password_is_not_accepted
|
31
|
-
transport.expect do |t,packet|
|
32
|
-
assert_equal USERAUTH_REQUEST, packet.type
|
33
|
-
t.return(USERAUTH_INFO_REQUEST, :string, "", :string, "", :string, "", :long, 1, :string, "Password:", :bool, false)
|
34
|
-
t.expect do |t2,packet2|
|
35
|
-
assert_equal USERAUTH_INFO_RESPONSE, packet2.type
|
36
|
-
assert_equal 1, packet2.read_long
|
37
|
-
assert_equal "the-password", packet2.read_string
|
38
|
-
t2.return(USERAUTH_FAILURE, :string, "keyboard-interactive")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
assert_equal false, subject.authenticate("ssh-connection", "jamis", "the-password")
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_authenticate_should_be_true_if_given_password_is_accepted
|
46
|
-
transport.expect do |t,packet|
|
47
|
-
assert_equal USERAUTH_REQUEST, packet.type
|
48
|
-
t.return(USERAUTH_INFO_REQUEST, :string, "", :string, "", :string, "", :long, 1, :string, "Password:", :bool, false)
|
49
|
-
t.expect do |t2,packet2|
|
50
|
-
assert_equal USERAUTH_INFO_RESPONSE, packet2.type
|
51
|
-
t2.return(USERAUTH_SUCCESS)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
assert subject.authenticate("ssh-connection", "jamis", "the-password")
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_authenticate_should_duplicate_password_as_needed_to_fill_request
|
59
|
-
transport.expect do |t,packet|
|
60
|
-
assert_equal USERAUTH_REQUEST, packet.type
|
61
|
-
t.return(USERAUTH_INFO_REQUEST, :string, "", :string, "", :string, "", :long, 2, :string, "Password:", :bool, false, :string, "Again:", :bool, false)
|
62
|
-
t.expect do |t2,packet2|
|
63
|
-
assert_equal USERAUTH_INFO_RESPONSE, packet2.type
|
64
|
-
assert_equal 2, packet2.read_long
|
65
|
-
assert_equal "the-password", packet2.read_string
|
66
|
-
assert_equal "the-password", packet2.read_string
|
67
|
-
t2.return(USERAUTH_SUCCESS)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
assert subject.authenticate("ssh-connection", "jamis", "the-password")
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_authenticate_should_not_prompt_for_input_when_in_non_interactive_mode
|
75
|
-
|
76
|
-
def transport.options
|
77
|
-
{non_interactive: true}
|
78
|
-
end
|
79
|
-
transport.expect do |t,packet|
|
80
|
-
assert_equal USERAUTH_REQUEST, packet.type
|
81
|
-
t.return(USERAUTH_INFO_REQUEST, :string, "", :string, "", :string, "", :long, 2, :string, "Name:", :bool, true, :string, "Password:", :bool, false)
|
82
|
-
t.expect do |t2,packet2|
|
83
|
-
assert_equal USERAUTH_INFO_RESPONSE, packet2.type
|
84
|
-
assert_equal 2, packet2.read_long
|
85
|
-
assert_equal "", packet2.read_string
|
86
|
-
assert_equal "", packet2.read_string
|
87
|
-
t2.return(USERAUTH_SUCCESS)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
assert subject.authenticate("ssh-connection", "jamis", nil)
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
def test_authenticate_should_prompt_for_input_when_password_is_not_given
|
96
|
-
subject.expects(:prompt).with("Name:", true).returns("name")
|
97
|
-
subject.expects(:prompt).with("Password:", false).returns("password")
|
98
|
-
|
99
|
-
transport.expect do |t,packet|
|
100
|
-
assert_equal USERAUTH_REQUEST, packet.type
|
101
|
-
t.return(USERAUTH_INFO_REQUEST, :string, "", :string, "", :string, "", :long, 2, :string, "Name:", :bool, true, :string, "Password:", :bool, false)
|
102
|
-
t.expect do |t2,packet2|
|
103
|
-
assert_equal USERAUTH_INFO_RESPONSE, packet2.type
|
104
|
-
assert_equal 2, packet2.read_long
|
105
|
-
assert_equal "name", packet2.read_string
|
106
|
-
assert_equal "password", packet2.read_string
|
107
|
-
t2.return(USERAUTH_SUCCESS)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
assert subject.authenticate("ssh-connection", "jamis", nil)
|
112
|
-
end
|
113
|
-
|
114
|
-
private
|
115
|
-
|
116
|
-
def subject(options={})
|
117
|
-
@subject ||= Net::SSH::Authentication::Methods::KeyboardInteractive.new(session(options), options)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
end; end
|