diff options
| author | Jamis Buck <jamis@37signals.com> | 2007-08-10 19:17:49 +0000 |
|---|---|---|
| committer | Jamis Buck <jamis@37signals.com> | 2007-08-10 19:17:49 +0000 |
| commit | 8e09a7db8ec4d2a5fa535bfaf348680f64b3ed3d (patch) | |
| tree | 4c0bc2390415680a9c27614be5546823ab216e2d /test/transport | |
| parent | ff99a53ea7c2e8870934667060a07981ecc19692 (diff) | |
| download | net-ssh-8e09a7db8ec4d2a5fa535bfaf348680f64b3ed3d.tar.gz | |
more hmac tests
git-svn-id: http://svn.jamisbuck.org/net-ssh/branches/v2@155 1d2a57f2-1ded-0310-ad52-83097a15a5de
Diffstat (limited to 'test/transport')
| -rw-r--r-- | test/transport/hmac/test_none.rb | 35 | ||||
| -rw-r--r-- | test/transport/hmac/test_sha1.rb | 35 | ||||
| -rw-r--r-- | test/transport/hmac/test_sha1_96.rb | 26 |
3 files changed, 96 insertions, 0 deletions
diff --git a/test/transport/hmac/test_none.rb b/test/transport/hmac/test_none.rb new file mode 100644 index 0000000..6932287 --- /dev/null +++ b/test/transport/hmac/test_none.rb @@ -0,0 +1,35 @@ +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../..").uniq! +require 'common' +require 'net/ssh/transport/hmac/none' + +module Transport; module HMAC + + class TestNone < Test::Unit::TestCase + def test_expected_digest_class + assert_equal nil, subject.digest_class + assert_equal nil, subject.new.digest_class + end + + def test_expected_key_length + assert_equal 0, subject.key_length + assert_equal 0, subject.new.key_length + end + + def test_expected_mac_length + assert_equal 0, subject.mac_length + assert_equal 0, subject.new.mac_length + end + + def test_expected_digest + hmac = subject.new("1234567890123456") + assert_equal "", hmac.digest("hello world") + end + + private + + def subject + Net::SSH::Transport::HMAC::None + end + end + +end; end
\ No newline at end of file diff --git a/test/transport/hmac/test_sha1.rb b/test/transport/hmac/test_sha1.rb new file mode 100644 index 0000000..ef56851 --- /dev/null +++ b/test/transport/hmac/test_sha1.rb @@ -0,0 +1,35 @@ +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../..").uniq! +require 'common' +require 'net/ssh/transport/hmac/sha1' + +module Transport; module HMAC + + class TestSHA1 < Test::Unit::TestCase + def test_expected_digest_class + assert_equal OpenSSL::Digest::SHA1, subject.digest_class + assert_equal OpenSSL::Digest::SHA1, subject.new.digest_class + end + + def test_expected_key_length + assert_equal 20, subject.key_length + assert_equal 20, subject.new.key_length + end + + def test_expected_mac_length + assert_equal 20, subject.mac_length + assert_equal 20, subject.new.mac_length + end + + def test_expected_digest + hmac = subject.new("1234567890123456") + assert_equal "\000\004W\202\204+&\335\311\251P\266\250\214\276\206;\022U\365", hmac.digest("hello world") + end + + private + + def subject + Net::SSH::Transport::HMAC::SHA1 + end + end + +end; end
\ No newline at end of file diff --git a/test/transport/hmac/test_sha1_96.rb b/test/transport/hmac/test_sha1_96.rb new file mode 100644 index 0000000..c4b3cf2 --- /dev/null +++ b/test/transport/hmac/test_sha1_96.rb @@ -0,0 +1,26 @@ +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../..").uniq! +require 'common' +require 'transport/hmac/test_sha1' +require 'net/ssh/transport/hmac/sha1_96' + +module Transport; module HMAC + + class TestSHA1_96 < TestSHA1 + def test_expected_mac_length + assert_equal 12, subject.mac_length + assert_equal 12, subject.new.mac_length + end + + def test_expected_digest + hmac = subject.new("1234567890123456") + assert_equal "\000\004W\202\204+&\335\311\251P\266", hmac.digest("hello world") + end + + private + + def subject + Net::SSH::Transport::HMAC::SHA1_96 + end + end + +end; end
\ No newline at end of file |
