symmetric-encryption 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +0,0 @@
1
- # encoding: utf-8
2
- module Symmetric #:nodoc
3
- VERSION = "0.4.0"
4
- end
Binary file
Binary file
@@ -1,51 +0,0 @@
1
- # Allow examples to be run in-place without requiring a gem install
2
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
3
-
4
- require 'rubygems'
5
- require 'test/unit'
6
- require 'shoulda'
7
-
8
- Symmetric::Encryption.load!(File.join(File.dirname(__FILE__), 'config', 'symmetric-encryption.yml'), 'test')
9
-
10
- # Unit Test for Symmetric::Encryption
11
- #
12
- class EncryptionTest < Test::Unit::TestCase
13
- context 'initialized' do
14
-
15
- context 'Symmetric::Encryption configuration' do
16
- setup do
17
- @config = Symmetric::Encryption.send(:read_config, File.join(File.dirname(__FILE__), 'config', 'symmetric-encryption.yml'), 'test')
18
- end
19
-
20
- should "match config file" do
21
- assert_equal @config[:ciphers][0][:cipher], Symmetric::Encryption.cipher.cipher
22
- end
23
- end
24
-
25
- context 'Symmetric::Encryption tests' do
26
- setup do
27
- @social_security_number = "987654321"
28
- @social_security_number_encrypted = "S+8X1NRrqdfEIQyFHVPuVA==\n"
29
- @social_security_number_encrypted_with_secondary_1 = "D1UCu38pqJ3jc0GvwJHiow==\n"
30
- end
31
-
32
- should "encrypt simple string" do
33
- assert_equal @social_security_number_encrypted, Symmetric::Encryption.encrypt(@social_security_number)
34
- end
35
-
36
- should "decrypt string" do
37
- assert_equal @social_security_number, Symmetric::Encryption.decrypt(@social_security_number_encrypted)
38
- end
39
-
40
- should "determine if string is encrypted" do
41
- assert_equal true, Symmetric::Encryption.encrypted?(@social_security_number_encrypted)
42
- assert_equal false, Symmetric::Encryption.encrypted?(@social_security_number)
43
- end
44
-
45
- should "decrypt with secondary key when first one fails" do
46
- assert_equal @social_security_number, Symmetric::Encryption.decrypt(@social_security_number_encrypted)
47
- end
48
- end
49
- end
50
-
51
- end