summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMiklos Fazekas <mfazekas@szemafor.com>2015-02-14 19:43:17 +0100
committerMiklos Fazekas <mfazekas@szemafor.com>2015-02-15 07:36:06 +0100
commit54405ead995e17c77f05f38faa445df378c93157 (patch)
treeebf7d25c7a5548a916e0ece735208c2e8dcce69a /test
parent79d2bea5ed5010704d7644ceee3db04ccfbf7283 (diff)
downloadnet-ssh-54405ead995e17c77f05f38faa445df378c93157.tar.gz
Fixed SHA256 tests
Diffstat (limited to 'test')
-rw-r--r--test/connection/test_session.rb6
-rw-r--r--test/transport/kex/test_diffie_hellman_group1_sha1.rb6
-rw-r--r--test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb6
-rw-r--r--test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb19
4 files changed, 15 insertions, 22 deletions
diff --git a/test/connection/test_session.rb b/test/connection/test_session.rb
index 268afb9..cb20892 100644
--- a/test/connection/test_session.rb
+++ b/test/connection/test_session.rb
@@ -377,13 +377,13 @@ module Connection
options = { :keepalive => true, :keepalive_interval => 300, :keepalive_maxcount => 3 }
expected_packet = P(:byte, Net::SSH::Packet::GLOBAL_REQUEST, :string, "keepalive@openssh.com", :bool, true)
[1,2,3].each do |i|
- Time.stubs(:now).returns(i*300)
+ Time.stubs(:now).returns(Time.at(i*300))
IO.stubs(:select).with([socket],[],nil,timeout).returns(nil)
- transport.expects(:enqueue_message).with{ |msg| msg.content == expected_packet.content }
+ transport.expects(:enqueue_message).with{ |msg| msg.content == expected_packet.content }
session(options).process
end
- Time.stubs(:now).returns(4*300)
+ Time.stubs(:now).returns(Time.at(4*300))
IO.stubs(:select).with([socket],[],nil,timeout).returns(nil)
transport.expects(:enqueue_message).with{ |msg| msg.content == expected_packet.content }
assert_raises(Net::SSH::Timeout) { session(options).process }
diff --git a/test/transport/kex/test_diffie_hellman_group1_sha1.rb b/test/transport/kex/test_diffie_hellman_group1_sha1.rb
index f62dbcb..2acf626 100644
--- a/test/transport/kex/test_diffie_hellman_group1_sha1.rb
+++ b/test/transport/kex/test_diffie_hellman_group1_sha1.rb
@@ -12,12 +12,16 @@ module Transport; module Kex
@packet_data = @shared_secret = nil
end
+ def digest_type
+ OpenSSL::Digest::SHA1
+ end
+
def test_exchange_keys_should_return_expected_results_when_successful
result = exchange!
assert_equal session_id, result[:session_id]
assert_equal server_key.to_blob, result[:server_key].to_blob
assert_equal shared_secret, result[:shared_secret]
- assert_equal OpenSSL::Digest::SHA1, result[:hashing_algorithm]
+ assert_equal digest_type, result[:hashing_algorithm]
end
def test_exchange_keys_with_unverifiable_host_should_raise_exception
diff --git a/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb b/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb
index b19afae..f17a6d0 100644
--- a/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb
+++ b/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb
@@ -69,6 +69,10 @@ module Transport; module Kex
Net::SSH::Transport::Kex::DiffieHellmanGroupExchangeSHA1
end
+ def digest_type
+ OpenSSL::Digest::SHA1
+ end
+
def session_id
@session_id ||= begin
buffer = Net::SSH::Buffer.from(:string, packet_data[:client_version_string],
@@ -84,7 +88,7 @@ module Transport; module Kex
:bignum, dh.dh.pub_key,
:bignum, server_dh_pubkey,
:bignum, shared_secret)
- OpenSSL::Digest::SHA1.digest(buffer.to_s)
+ digest_type.digest(buffer.to_s)
end
end
end
diff --git a/test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb b/test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb
index e09ea96..e6b4d26 100644
--- a/test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb
+++ b/test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb
@@ -11,23 +11,8 @@ module Transport; module Kex
Net::SSH::Transport::Kex::DiffieHellmanGroupExchangeSHA256
end
- def session_id
- @session_id ||= begin
- buffer = Net::SSH::Buffer.from(:string, packet_data[:client_version_string],
- :string, packet_data[:server_version_string],
- :string, packet_data[:client_algorithm_packet],
- :string, packet_data[:server_algorithm_packet],
- :string, Net::SSH::Buffer.from(:key, server_key),
- :long, 1024,
- :long, 1024,
- :long, 8192,
- :bignum, dh.dh.p,
- :bignum, dh.dh.g,
- :bignum, dh.dh.pub_key,
- :bignum, server_dh_pubkey,
- :bignum, shared_secret)
- OpenSSL::Digest::SHA256.digest(buffer.to_s)
- end
+ def digest_type
+ OpenSSL::Digest::SHA256
end
end