diff options
author | Willem van Bergen <willem@vanbergen.org> | 2011-09-15 14:27:12 -0400 |
---|---|---|
committer | Willem van Bergen <willem@vanbergen.org> | 2011-09-15 14:27:12 -0400 |
commit | 41fea0334232824d5d509a6924e8c8487d53494b (patch) | |
tree | 429ec14cdbd47d7f497b08fd2cade404c3395bc9 /activesupport/test | |
parent | 2d30d4cb888e2da7c1f0a8828b467d2e21c90cfa (diff) | |
download | rails-41fea0334232824d5d509a6924e8c8487d53494b.tar.gz rails-41fea0334232824d5d509a6924e8c8487d53494b.tar.bz2 rails-41fea0334232824d5d509a6924e8c8487d53494b.zip |
Use an options hash to specify digest/cipher algorithm and a serializer for MessageVerifier and MessageEncryptor.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/message_encryptor_test.rb | 6 | ||||
-rw-r--r-- | activesupport/test/message_verifier_test.rb | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/activesupport/test/message_encryptor_test.rb b/activesupport/test/message_encryptor_test.rb index 9c89512b42..58f94a7400 100644 --- a/activesupport/test/message_encryptor_test.rb +++ b/activesupport/test/message_encryptor_test.rb @@ -52,9 +52,9 @@ class MessageEncryptorTest < Test::Unit::TestCase end def test_alternative_serialization_method - @encryptor.serializer = JSONSerializer.new - message = @encryptor.encrypt_and_sign({ :foo => 123, 'bar' => Time.utc(2010) }) - assert_equal @encryptor.decrypt_and_verify(message), { "foo" => 123, "bar" => "2010-01-01T00:00:00Z" } + encryptor = ActiveSupport::MessageEncryptor.new(SecureRandom.hex(64), :serializer => JSONSerializer.new) + message = encryptor.encrypt_and_sign({ :foo => 123, 'bar' => Time.utc(2010) }) + assert_equal encryptor.decrypt_and_verify(message), { "foo" => 123, "bar" => "2010-01-01T00:00:00Z" } end private diff --git a/activesupport/test/message_verifier_test.rb b/activesupport/test/message_verifier_test.rb index 10a1738786..3dc047c126 100644 --- a/activesupport/test/message_verifier_test.rb +++ b/activesupport/test/message_verifier_test.rb @@ -45,9 +45,9 @@ class MessageVerifierTest < Test::Unit::TestCase end def test_alternative_serialization_method - @verifier.serializer = JSONSerializer.new - message = @verifier.generate({ :foo => 123, 'bar' => Time.utc(2010) }) - assert_equal @verifier.verify(message), { "foo" => 123, "bar" => "2010-01-01T00:00:00Z" } + verifier = ActiveSupport::MessageVerifier.new("Hey, I'm a secret!", :serializer => JSONSerializer.new) + message = verifier.generate({ :foo => 123, 'bar' => Time.utc(2010) }) + assert_equal verifier.verify(message), { "foo" => 123, "bar" => "2010-01-01T00:00:00Z" } end def assert_not_verified(message) |