~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to test/openssl/test_hmac.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
begin
 
2
  require "openssl"
 
3
rescue LoadError
 
4
end
 
5
require "test/unit"
 
6
 
 
7
if defined?(OpenSSL)
 
8
 
 
9
class OpenSSL::TestHMAC < Test::Unit::TestCase
 
10
  def setup
 
11
    @digest = OpenSSL::Digest::MD5.new
 
12
    @key = "KEY"
 
13
    @data = "DATA"
 
14
    @h1 = OpenSSL::HMAC.new(@key, @digest)
 
15
    @h2 = OpenSSL::HMAC.new(@key, @digest)
 
16
  end
 
17
 
 
18
  def teardown
 
19
  end
 
20
 
 
21
  def test_hmac
 
22
    @h1.update(@data)
 
23
    assert_equal(OpenSSL::HMAC.digest(@digest, @key, @data), @h1.digest, "digest")
 
24
    assert_equal(OpenSSL::HMAC.hexdigest(@digest, @key, @data), @h1.hexdigest, "hexdigest")
 
25
  end
 
26
 
 
27
  def test_dup
 
28
    @h1.update(@data)
 
29
    h = @h1.dup
 
30
    assert_equal(@h1.digest, h.digest, "dup digest")
 
31
  end
 
32
end
 
33
 
 
34
end