Skip to content

Commit 588f798

Browse files
committed
move the added HMAC tests out of openssl's tests since those are updated from MRI
1 parent 49fdea4 commit 588f798

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/test/ruby/test_hmac.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# coding: US-ASCII
2+
require File.expand_path('test_helper', File.dirname(__FILE__))
3+
require 'jopenssl/load'
4+
5+
class TestHMAC < Test::Unit::TestCase
6+
7+
def setup
8+
@digest = OpenSSL::Digest::MD5
9+
@key = "KEY"
10+
@data = "DATA"
11+
@h1 = OpenSSL::HMAC.new(@key, @digest.new)
12+
@h2 = OpenSSL::HMAC.new(@key, "MD5")
13+
end
14+
15+
def test_to_s
16+
@h1.update(''); @h1.update('1234567890')
17+
assert_equal(@h1.hexdigest, @h1.to_s)
18+
assert_equal(@h2.hexdigest, @h2.to_s)
19+
end
20+
21+
def test_reset
22+
data = 'He is my neighbor Nursultan Tuliagby. He is pain in my assholes.'
23+
@h1.update('4'); @h1.update('2')
24+
@h1.reset
25+
@h1.update(data)
26+
@h2.update(data)
27+
assert_equal(@h2.digest, @h1.digest)
28+
end
29+
30+
def test_correct_digest
31+
assert_equal('c17c7b655b11574fea8d676a1fdc0ca8', @h2.hexdigest) # calculated on MRI
32+
@h2.update('DATA')
33+
assert_equal('9e50596c0fa1197f8587443a942d8afc', @h2.hexdigest) # calculated on MRI
34+
end
35+
36+
end

0 commit comments

Comments
 (0)