Sha256: c3de76d22ab98541f6a0f970f81f3b9a6f90a50cf8cc15c1b96012363761fab5
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
require 'abstract_unit' class SymmetricSentryTest < Test::Unit::TestCase def setup @str = 'sentry' @key = 'secret' @encrypted = "td9jRyjyv0A=\n" @sentry = Sentry::SymmetricSentry.new Sentry::SymmetricSentry.default_key = nil end def test_should_encrypt assert_equal @encrypted, @sentry.encrypt_to_base64(@str, @key) end def test_should_decrypt assert_equal @str, @sentry.decrypt_from_base64(@encrypted, @key) end def test_should_encrypt_with_default_key Sentry::SymmetricSentry.default_key = @key assert_equal @encrypted, @sentry.encrypt_to_base64(@str) end def test_should_decrypt_with_default_key Sentry::SymmetricSentry.default_key = @key assert_equal @str, @sentry.decrypt_from_base64(@encrypted) end def test_should_raise_error_when_encrypt_with_no_key assert_raises(Sentry::NoKeyError) { @sentry.encrypt_to_base64(@str) } end def test_should_raise_error_when_decrypt_with_no_key assert_raises(Sentry::NoKeyError) { @sentry.decrypt_from_base64(@str) } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shipstar-sentry-0.5.2.1 | test/symmetric_sentry_test.rb |