diff options
author | Chris Roberts <croberts@hashicorp.com> | 2018-11-06 15:40:35 -0800 |
---|---|---|
committer | Chris Roberts <croberts@hashicorp.com> | 2018-11-06 15:40:35 -0800 |
commit | f93539487031146a26f8c34d273271f0c607a108 (patch) | |
tree | 42aee0f037714505f6f2164559251adf03ee2775 /test | |
parent | 7429a290230b2f31179047a7130b40744e1b0b54 (diff) | |
download | net-ssh-f93539487031146a26f8c34d273271f0c607a108.tar.gz |
Skip identities that provide invalid key
Diffstat (limited to 'test')
-rw-r--r-- | test/authentication/test_agent.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/authentication/test_agent.rb b/test/authentication/test_agent.rb index d7d9411..d5c2290 100644 --- a/test/authentication/test_agent.rb +++ b/test/authentication/test_agent.rb @@ -154,6 +154,24 @@ EOF assert_equal "Okay, but not the best", result.last.comment end + def test_identities_should_ignore_invalid_ones + key1 = key + key2_bad = Net::SSH::Buffer.new("") + key3 = OpenSSL::PKey::DSA.new(512) + + socket.expect do |s, type, buffer| + assert_equal SSH2_AGENT_REQUEST_IDENTITIES, type + s.return(SSH2_AGENT_IDENTITIES_ANSWER, :long, 3, :string, Net::SSH::Buffer.from(:key, key1), :string, "My favorite key", :string, key2_bad, :string, "bad", :string, Net::SSH::Buffer.from(:key, key3), :string, "Okay, but not the best") + end + + result = agent.identities + assert_equal 2,result.size + assert_equal key1.to_blob, result.first.to_blob + assert_equal key3.to_blob, result.last.to_blob + assert_equal "My favorite key", result.first.comment + assert_equal "Okay, but not the best", result.last.comment + end + def test_close_should_close_socket socket.expects(:close) agent.close |