test/cipher_test.rb in symmetric-encryption-0.4.0 vs test/cipher_test.rb in symmetric-encryption-0.5.0
- old
+ new
@@ -2,35 +2,35 @@
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
require 'rubygems'
require 'test/unit'
require 'shoulda'
-require 'symmetric/cipher'
+require 'symmetric_encryption/cipher'
-# Unit Test for Symmetric::Cipher
+# Unit Test for SymmetricEncryption::Cipher
#
class CipherTest < Test::Unit::TestCase
context 'standalone' do
should "allow setting the cipher" do
- cipher = Symmetric::Cipher.new(
+ cipher = SymmetricEncryption::Cipher.new(
:cipher => 'aes-128-cbc',
:key => '1234567890ABCDEF1234567890ABCDEF',
:iv => '1234567890ABCDEF'
)
assert_equal 'aes-128-cbc', cipher.cipher
end
should "not require an iv" do
- cipher = Symmetric::Cipher.new(
+ cipher = SymmetricEncryption::Cipher.new(
:key => '1234567890ABCDEF1234567890ABCDEF'
)
- assert_equal "wjzpl29q+tsxyLBWAQsn5g==\n", cipher.encrypt('Hello World')
+ assert_equal "\302<\351\227oj\372\3331\310\260V\001\v'\346", cipher.encrypt('Hello World')
end
should "throw an exception on bad data" do
- cipher = Symmetric::Cipher.new(
+ cipher = SymmetricEncryption::Cipher.new(
:cipher => 'aes-128-cbc',
:key => '1234567890ABCDEF1234567890ABCDEF',
:iv => '1234567890ABCDEF'
)
assert_raise OpenSSL::Cipher::CipherError do
@@ -40,16 +40,16 @@
end
context 'with configuration' do
setup do
- @cipher = Symmetric::Cipher.new(
+ @cipher = SymmetricEncryption::Cipher.new(
:key => '1234567890ABCDEF1234567890ABCDEF',
:iv => '1234567890ABCDEF'
)
@social_security_number = "987654321"
- @social_security_number_encrypted = "Qd0qzN6oVuATJQBTf8X6tg==\n"
+ @social_security_number_encrypted = "A\335*\314\336\250V\340\023%\000S\177\305\372\266"
@sample_data = [
{ :text => '555052345', :encrypted => ''}
]
end
@@ -61,14 +61,9 @@
assert_equal @social_security_number_encrypted, @cipher.encrypt(@social_security_number)
end
should "decrypt string" do
assert_equal @social_security_number, @cipher.decrypt(@social_security_number_encrypted)
- end
-
- should "determine if string is encrypted" do
- assert_equal true, @cipher.encrypted?(@social_security_number_encrypted)
- assert_equal false, @cipher.encrypted?(@social_security_number)
end
end
end
\ No newline at end of file