Sha256: 3e471cf2ad9a088eff6207a8dab0d3869a4ed3c07ccf22a8b64ea214a0ee9f9b
Contents?: true
Size: 1.03 KB
Versions: 12
Compression:
Stored size: 1.03 KB
Contents
require 'abstract_unit' class SymmetricSentryTest < Test::Unit::TestCase def setup @str = 'sentry' @key = 'secret' @encrypted = "0XlmUuNpE2k=\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
12 entries across 12 versions & 4 rubygems