Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'auser/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jamis committed Dec 19, 2008
2 parents 690a871 + ad693ad commit 0693d4d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rdoc
@@ -1,5 +1,9 @@
=== (unreleased)

* Make key manager use private keys instead of requiring public key to exist [arilerner@mac.com]

* Fix failing tests [arilerner@mac.com]

* Don't include pageant when running under JRuby [Angel N. Sciortino]


Expand Down
2 changes: 1 addition & 1 deletion Manifest
Expand Up @@ -62,6 +62,7 @@ lib/net/ssh/verifiers/strict.rb
lib/net/ssh/version.rb
lib/net/ssh.rb
Manifest
net-ssh.gemspec
Rakefile
README.rdoc
setup.rb
Expand Down Expand Up @@ -101,4 +102,3 @@ test/transport/test_server_version.rb
test/transport/test_session.rb
test/transport/test_state.rb
THANKS.rdoc
TODO
8 changes: 4 additions & 4 deletions lib/net/ssh/authentication/key_manager.rb
Expand Up @@ -87,12 +87,12 @@ def identities
known_identities[key] = { :from => :agent }
end
end

key_files.each do |file|
public_key_file = file + '.pub'
if File.readable?(public_key_file)
if File.readable?(file)
begin
key = KeyFactory.load_public_key(public_key_file)
private_key = KeyFactory.load_private_key(file)
key = private_key.send :public_key
identities.push key
known_identities[key] = { :from => :file, :file => file }
rescue Exception => e
Expand Down
2 changes: 2 additions & 0 deletions test/authentication/methods/test_hostbased.rb
Expand Up @@ -16,6 +16,7 @@ def test_authenticate_should_return_false_when_key_manager_has_no_keys
end

def test_authenticate_should_return_false_if_no_keys_can_authenticate
ENV.stubs(:[]).with('USER').returns(nil)
key_manager.expects(:sign).with(&signature_parameters(keys.first)).returns("sig-one")
key_manager.expects(:sign).with(&signature_parameters(keys.last)).returns("sig-two")

Expand All @@ -37,6 +38,7 @@ def test_authenticate_should_return_false_if_no_keys_can_authenticate
end

def test_authenticate_should_return_true_if_any_key_can_authenticate
ENV.stubs(:[]).with('USER').returns(nil)
key_manager.expects(:sign).with(&signature_parameters(keys.first)).returns("sig-one")

transport.expect do |t, packet|
Expand Down
8 changes: 4 additions & 4 deletions test/authentication/test_key_manager.rb
Expand Up @@ -32,13 +32,13 @@ def test_identities_should_load_from_key_files
manager.stubs(:agent).returns(nil)

stub_file_key "/first", rsa
stub_file_key "/second", dsa
stub_file_key "/second", dsa

identities = manager.identities
assert_equal 2, identities.length
assert_equal rsa.to_blob, identities.first.to_blob
assert_equal dsa.to_blob, identities.last.to_blob

assert_equal({:from => :file, :file => "/first"}, manager.known_identities[rsa])
assert_equal({:from => :file, :file => "/second"}, manager.known_identities[dsa])
end
Expand Down Expand Up @@ -75,8 +75,8 @@ def test_sign_with_file_originated_key_should_load_private_key_and_sign_with_it
def stub_file_key(name, key, also_private=false)
manager.add(name)
File.expects(:readable?).returns(true)
Net::SSH::KeyFactory.expects(:load_public_key).with("#{name}.pub").returns(key)
Net::SSH::KeyFactory.expects(:load_private_key).with(name, nil).returns(key) if also_private
Net::SSH::KeyFactory.expects(:load_private_key).with(name, nil).returns(key).at_least_once
key.expects(:public_key).returns(key)
end

def rsa(size=32)
Expand Down

0 comments on commit 0693d4d

Please sign in to comment.