diff options
| author | Jamis Buck <jamis@37signals.com> | 2008-12-19 07:33:09 -0700 |
|---|---|---|
| committer | Jamis Buck <jamis@37signals.com> | 2008-12-19 07:33:09 -0700 |
| commit | 0693d4d882b7d6e35f392d98be4051d7c4dbf0b8 (patch) | |
| tree | 7540cebf33810c8b03fa179ff6c76c8433616088 /test | |
| parent | 690a871ae069a881de9c890fcb2d95ccc05bdde7 (diff) | |
| parent | ad693adc688d9c6075c10af48362f330c46d94c8 (diff) | |
| download | net-ssh-0693d4d882b7d6e35f392d98be4051d7c4dbf0b8.tar.gz | |
Merge branch 'auser/master'
Diffstat (limited to 'test')
| -rw-r--r-- | test/authentication/methods/test_hostbased.rb | 2 | ||||
| -rw-r--r-- | test/authentication/test_key_manager.rb | 8 |
2 files changed, 6 insertions, 4 deletions
diff --git a/test/authentication/methods/test_hostbased.rb b/test/authentication/methods/test_hostbased.rb index 1245e13..0a994fb 100644 --- a/test/authentication/methods/test_hostbased.rb +++ b/test/authentication/methods/test_hostbased.rb @@ -16,6 +16,7 @@ module Authentication; module Methods 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") @@ -37,6 +38,7 @@ module Authentication; module Methods 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| diff --git a/test/authentication/test_key_manager.rb b/test/authentication/test_key_manager.rb index f6486f9..00f5f4a 100644 --- a/test/authentication/test_key_manager.rb +++ b/test/authentication/test_key_manager.rb @@ -32,13 +32,13 @@ module Authentication 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 @@ -75,8 +75,8 @@ module Authentication 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) |
