-
-
Save headius/9bf14142e174891db0dc to your computer and use it in GitHub Desktop.
Test for HMAC signing with UTF-8 String
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From f16ebf16dc9ad0353a85e39cc23d20e2d31ffcf0 Mon Sep 17 00:00:00 2001 | |
From: Charles Oliver Nutter <headius@headius.com> | |
Date: Tue, 4 Dec 2012 18:52:37 -0600 | |
Subject: [PATCH] Add test for HMAC signing a UTF-8 String. From JRUBY-7017. | |
--- | |
test/openssl/test_hmac.rb | 9 +++++++++ | |
1 file changed, 9 insertions(+) | |
diff --git a/test/openssl/test_hmac.rb b/test/openssl/test_hmac.rb | |
index ba158d2..f1e4536 100644 | |
--- a/test/openssl/test_hmac.rb | |
+++ b/test/openssl/test_hmac.rb | |
@@ -1,3 +1,5 @@ | |
+# coding: UTF-8 | |
+ | |
require_relative 'utils' | |
class OpenSSL::TestHMAC < Test::Unit::TestCase | |
@@ -29,4 +31,11 @@ class OpenSSL::TestHMAC < Test::Unit::TestCase | |
h = @h1.dup | |
assert_equal(@h1.digest, h.digest, "dup digest") | |
end | |
+ | |
+ def test_binary_update | |
+ data = "Lücíllé: Bût... yøü sáîd hé wås âlrîght.\nDr. Físhmån: Yés. Hé's løst hîs léft hånd, sø hé's gøîng tø bé åll rîght" | |
+ hmac = OpenSSL::HMAC.new("qShkcwN92rsM9nHfdnP4ugcVU2iI7iM/trovs01ZWok", "SHA256") | |
+ result = hmac.update(data).hexdigest | |
+ assert_equal "a13984b929a07912e4e21c5720876a8e150d6f67f854437206e7f86547248396", result | |
+ end | |
end if defined?(OpenSSL) | |
-- | |
1.7.10.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment