crypt_keeper 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Guardfile +1 -1
- data/crypt_keeper.gemspec +5 -4
- data/gemfiles/activerecord_3_0.gemfile.lock +41 -37
- data/gemfiles/activerecord_3_1.gemfile.lock +41 -37
- data/gemfiles/activerecord_3_2.gemfile.lock +41 -37
- data/lib/crypt_keeper/log_subscriber/mysql_aes.rb +1 -1
- data/lib/crypt_keeper/log_subscriber/postgres_pgp.rb +1 -1
- data/lib/crypt_keeper/model.rb +5 -1
- data/lib/crypt_keeper/provider/mysql_aes.rb +2 -0
- data/lib/crypt_keeper/provider/postgres_pgp.rb +2 -0
- data/lib/crypt_keeper/version.rb +1 -1
- data/spec/log_subscriber/mysql_aes_spec.rb +5 -0
- data/spec/log_subscriber/postgres_pgp_spec.rb +5 -0
- data/spec/model_spec.rb +10 -6
- data/spec/provider/aes_spec.rb +5 -15
- data/spec/provider/mysql_aes_spec.rb +4 -10
- data/spec/provider/postgres_pgp_spec.rb +8 -12
- data/spec/support/active_record.rb +1 -3
- metadata +29 -13
data/.gitignore
CHANGED
data/Guardfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# A sample Guardfile
|
2
2
|
# More info at https://github.com/guard/guard#readme
|
3
3
|
|
4
|
-
guard 'rspec',
|
4
|
+
guard 'rspec', all_on_start: false, all_after_pass: false, cli: '--fail-fast' do
|
5
5
|
watch(%r{^spec/.+_spec\.rb$})
|
6
6
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
7
|
watch('spec/spec_helper.rb') { "spec" }
|
data/crypt_keeper.gemspec
CHANGED
@@ -19,10 +19,11 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_runtime_dependency 'activesupport', '>= 3.0'
|
20
20
|
gem.add_runtime_dependency 'appraisal', '~> 0.5.1'
|
21
21
|
|
22
|
-
gem.add_development_dependency 'rspec', '~> 2.
|
23
|
-
gem.add_development_dependency 'guard', '~> 1.
|
24
|
-
gem.add_development_dependency 'guard-rspec', '~>
|
25
|
-
gem.add_development_dependency 'rake', '~> 0.
|
22
|
+
gem.add_development_dependency 'rspec', '~> 2.12.0'
|
23
|
+
gem.add_development_dependency 'guard', '~> 1.6.0'
|
24
|
+
gem.add_development_dependency 'guard-rspec', '~> 2.3.0'
|
25
|
+
gem.add_development_dependency 'rake', '~> 10.0.3'
|
26
|
+
gem.add_development_dependency 'rb-fsevent', '~> 0.9.1'
|
26
27
|
|
27
28
|
if RUBY_PLATFORM == 'java'
|
28
29
|
gem.add_development_dependency 'jruby-openssl', '~> 0.7.7'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: /Users/justin/work/Personal/crypt_keeper
|
3
3
|
specs:
|
4
|
-
crypt_keeper (0.
|
4
|
+
crypt_keeper (0.8.0)
|
5
5
|
activerecord (>= 3.0)
|
6
6
|
activesupport (>= 3.0)
|
7
7
|
appraisal (~> 0.5.1)
|
@@ -9,54 +9,57 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activemodel (3.2.
|
13
|
-
activesupport (= 3.2.
|
12
|
+
activemodel (3.2.9)
|
13
|
+
activesupport (= 3.2.9)
|
14
14
|
builder (~> 3.0.0)
|
15
|
-
activerecord (3.2.
|
16
|
-
activemodel (= 3.2.
|
17
|
-
activesupport (= 3.2.
|
15
|
+
activerecord (3.2.9)
|
16
|
+
activemodel (= 3.2.9)
|
17
|
+
activesupport (= 3.2.9)
|
18
18
|
arel (~> 3.0.2)
|
19
19
|
tzinfo (~> 0.3.29)
|
20
|
-
activesupport (3.2.
|
20
|
+
activesupport (3.2.9)
|
21
21
|
i18n (~> 0.6)
|
22
22
|
multi_json (~> 1.0)
|
23
23
|
appraisal (0.5.1)
|
24
24
|
bundler
|
25
25
|
rake
|
26
26
|
arel (3.0.2)
|
27
|
-
builder (3.0.
|
27
|
+
builder (3.0.4)
|
28
|
+
coderay (1.0.8)
|
28
29
|
diff-lcs (1.1.3)
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
guard (1.6.0)
|
31
|
+
listen (>= 0.6.0)
|
32
|
+
lumberjack (>= 1.0.2)
|
33
|
+
pry (>= 0.9.10)
|
32
34
|
thor (>= 0.14.6)
|
33
|
-
guard-rspec (
|
35
|
+
guard-rspec (2.3.3)
|
34
36
|
guard (>= 1.1)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
multi_json (1.
|
37
|
+
rspec (~> 2.11)
|
38
|
+
i18n (0.6.1)
|
39
|
+
listen (0.6.0)
|
40
|
+
lumberjack (1.0.2)
|
41
|
+
method_source (0.8.1)
|
42
|
+
multi_json (1.5.0)
|
41
43
|
mysql2 (0.3.11)
|
42
|
-
pg (0.14.
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
rspec (2.
|
50
|
-
rspec-core (~> 2.
|
51
|
-
rspec-expectations (~> 2.
|
52
|
-
rspec-mocks (~> 2.
|
53
|
-
rspec-core (2.
|
54
|
-
rspec-expectations (2.
|
44
|
+
pg (0.14.1)
|
45
|
+
pry (0.9.10)
|
46
|
+
coderay (~> 1.0.5)
|
47
|
+
method_source (~> 0.8)
|
48
|
+
slop (~> 3.3.1)
|
49
|
+
rake (10.0.3)
|
50
|
+
rb-fsevent (0.9.2)
|
51
|
+
rspec (2.12.0)
|
52
|
+
rspec-core (~> 2.12.0)
|
53
|
+
rspec-expectations (~> 2.12.0)
|
54
|
+
rspec-mocks (~> 2.12.0)
|
55
|
+
rspec-core (2.12.2)
|
56
|
+
rspec-expectations (2.12.1)
|
55
57
|
diff-lcs (~> 1.1.3)
|
56
|
-
rspec-mocks (2.
|
58
|
+
rspec-mocks (2.12.1)
|
59
|
+
slop (3.3.3)
|
57
60
|
sqlite3 (1.3.6)
|
58
61
|
thor (0.16.0)
|
59
|
-
tzinfo (0.3.
|
62
|
+
tzinfo (0.3.35)
|
60
63
|
|
61
64
|
PLATFORMS
|
62
65
|
ruby
|
@@ -65,10 +68,11 @@ DEPENDENCIES
|
|
65
68
|
activerecord (~> 3.0)
|
66
69
|
activesupport (~> 3.0)
|
67
70
|
crypt_keeper!
|
68
|
-
guard (~> 1.
|
69
|
-
guard-rspec (~>
|
71
|
+
guard (~> 1.6.0)
|
72
|
+
guard-rspec (~> 2.3.0)
|
70
73
|
mysql2 (~> 0.3.11)
|
71
74
|
pg (~> 0.14.0)
|
72
|
-
rake (~> 0.
|
73
|
-
|
75
|
+
rake (~> 10.0.3)
|
76
|
+
rb-fsevent (~> 0.9.1)
|
77
|
+
rspec (~> 2.12.0)
|
74
78
|
sqlite3
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: /Users/justin/work/Personal/crypt_keeper
|
3
3
|
specs:
|
4
|
-
crypt_keeper (0.
|
4
|
+
crypt_keeper (0.8.0)
|
5
5
|
activerecord (>= 3.0)
|
6
6
|
activesupport (>= 3.0)
|
7
7
|
appraisal (~> 0.5.1)
|
@@ -9,54 +9,57 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activemodel (3.2.
|
13
|
-
activesupport (= 3.2.
|
12
|
+
activemodel (3.2.9)
|
13
|
+
activesupport (= 3.2.9)
|
14
14
|
builder (~> 3.0.0)
|
15
|
-
activerecord (3.2.
|
16
|
-
activemodel (= 3.2.
|
17
|
-
activesupport (= 3.2.
|
15
|
+
activerecord (3.2.9)
|
16
|
+
activemodel (= 3.2.9)
|
17
|
+
activesupport (= 3.2.9)
|
18
18
|
arel (~> 3.0.2)
|
19
19
|
tzinfo (~> 0.3.29)
|
20
|
-
activesupport (3.2.
|
20
|
+
activesupport (3.2.9)
|
21
21
|
i18n (~> 0.6)
|
22
22
|
multi_json (~> 1.0)
|
23
23
|
appraisal (0.5.1)
|
24
24
|
bundler
|
25
25
|
rake
|
26
26
|
arel (3.0.2)
|
27
|
-
builder (3.0.
|
27
|
+
builder (3.0.4)
|
28
|
+
coderay (1.0.8)
|
28
29
|
diff-lcs (1.1.3)
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
guard (1.6.0)
|
31
|
+
listen (>= 0.6.0)
|
32
|
+
lumberjack (>= 1.0.2)
|
33
|
+
pry (>= 0.9.10)
|
32
34
|
thor (>= 0.14.6)
|
33
|
-
guard-rspec (
|
35
|
+
guard-rspec (2.3.3)
|
34
36
|
guard (>= 1.1)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
multi_json (1.
|
37
|
+
rspec (~> 2.11)
|
38
|
+
i18n (0.6.1)
|
39
|
+
listen (0.6.0)
|
40
|
+
lumberjack (1.0.2)
|
41
|
+
method_source (0.8.1)
|
42
|
+
multi_json (1.5.0)
|
41
43
|
mysql2 (0.3.11)
|
42
|
-
pg (0.14.
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
rspec (2.
|
50
|
-
rspec-core (~> 2.
|
51
|
-
rspec-expectations (~> 2.
|
52
|
-
rspec-mocks (~> 2.
|
53
|
-
rspec-core (2.
|
54
|
-
rspec-expectations (2.
|
44
|
+
pg (0.14.1)
|
45
|
+
pry (0.9.10)
|
46
|
+
coderay (~> 1.0.5)
|
47
|
+
method_source (~> 0.8)
|
48
|
+
slop (~> 3.3.1)
|
49
|
+
rake (10.0.3)
|
50
|
+
rb-fsevent (0.9.2)
|
51
|
+
rspec (2.12.0)
|
52
|
+
rspec-core (~> 2.12.0)
|
53
|
+
rspec-expectations (~> 2.12.0)
|
54
|
+
rspec-mocks (~> 2.12.0)
|
55
|
+
rspec-core (2.12.2)
|
56
|
+
rspec-expectations (2.12.1)
|
55
57
|
diff-lcs (~> 1.1.3)
|
56
|
-
rspec-mocks (2.
|
58
|
+
rspec-mocks (2.12.1)
|
59
|
+
slop (3.3.3)
|
57
60
|
sqlite3 (1.3.6)
|
58
61
|
thor (0.16.0)
|
59
|
-
tzinfo (0.3.
|
62
|
+
tzinfo (0.3.35)
|
60
63
|
|
61
64
|
PLATFORMS
|
62
65
|
ruby
|
@@ -65,10 +68,11 @@ DEPENDENCIES
|
|
65
68
|
activerecord (~> 3.1)
|
66
69
|
activesupport (~> 3.1)
|
67
70
|
crypt_keeper!
|
68
|
-
guard (~> 1.
|
69
|
-
guard-rspec (~>
|
71
|
+
guard (~> 1.6.0)
|
72
|
+
guard-rspec (~> 2.3.0)
|
70
73
|
mysql2 (~> 0.3.11)
|
71
74
|
pg (~> 0.14.0)
|
72
|
-
rake (~> 0.
|
73
|
-
|
75
|
+
rake (~> 10.0.3)
|
76
|
+
rb-fsevent (~> 0.9.1)
|
77
|
+
rspec (~> 2.12.0)
|
74
78
|
sqlite3
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: /Users/justin/work/Personal/crypt_keeper
|
3
3
|
specs:
|
4
|
-
crypt_keeper (0.
|
4
|
+
crypt_keeper (0.8.0)
|
5
5
|
activerecord (>= 3.0)
|
6
6
|
activesupport (>= 3.0)
|
7
7
|
appraisal (~> 0.5.1)
|
@@ -9,54 +9,57 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activemodel (3.2.
|
13
|
-
activesupport (= 3.2.
|
12
|
+
activemodel (3.2.9)
|
13
|
+
activesupport (= 3.2.9)
|
14
14
|
builder (~> 3.0.0)
|
15
|
-
activerecord (3.2.
|
16
|
-
activemodel (= 3.2.
|
17
|
-
activesupport (= 3.2.
|
15
|
+
activerecord (3.2.9)
|
16
|
+
activemodel (= 3.2.9)
|
17
|
+
activesupport (= 3.2.9)
|
18
18
|
arel (~> 3.0.2)
|
19
19
|
tzinfo (~> 0.3.29)
|
20
|
-
activesupport (3.2.
|
20
|
+
activesupport (3.2.9)
|
21
21
|
i18n (~> 0.6)
|
22
22
|
multi_json (~> 1.0)
|
23
23
|
appraisal (0.5.1)
|
24
24
|
bundler
|
25
25
|
rake
|
26
26
|
arel (3.0.2)
|
27
|
-
builder (3.0.
|
27
|
+
builder (3.0.4)
|
28
|
+
coderay (1.0.8)
|
28
29
|
diff-lcs (1.1.3)
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
guard (1.6.0)
|
31
|
+
listen (>= 0.6.0)
|
32
|
+
lumberjack (>= 1.0.2)
|
33
|
+
pry (>= 0.9.10)
|
32
34
|
thor (>= 0.14.6)
|
33
|
-
guard-rspec (
|
35
|
+
guard-rspec (2.3.3)
|
34
36
|
guard (>= 1.1)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
multi_json (1.
|
37
|
+
rspec (~> 2.11)
|
38
|
+
i18n (0.6.1)
|
39
|
+
listen (0.6.0)
|
40
|
+
lumberjack (1.0.2)
|
41
|
+
method_source (0.8.1)
|
42
|
+
multi_json (1.5.0)
|
41
43
|
mysql2 (0.3.11)
|
42
|
-
pg (0.14.
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
rspec (2.
|
50
|
-
rspec-core (~> 2.
|
51
|
-
rspec-expectations (~> 2.
|
52
|
-
rspec-mocks (~> 2.
|
53
|
-
rspec-core (2.
|
54
|
-
rspec-expectations (2.
|
44
|
+
pg (0.14.1)
|
45
|
+
pry (0.9.10)
|
46
|
+
coderay (~> 1.0.5)
|
47
|
+
method_source (~> 0.8)
|
48
|
+
slop (~> 3.3.1)
|
49
|
+
rake (10.0.3)
|
50
|
+
rb-fsevent (0.9.2)
|
51
|
+
rspec (2.12.0)
|
52
|
+
rspec-core (~> 2.12.0)
|
53
|
+
rspec-expectations (~> 2.12.0)
|
54
|
+
rspec-mocks (~> 2.12.0)
|
55
|
+
rspec-core (2.12.2)
|
56
|
+
rspec-expectations (2.12.1)
|
55
57
|
diff-lcs (~> 1.1.3)
|
56
|
-
rspec-mocks (2.
|
58
|
+
rspec-mocks (2.12.1)
|
59
|
+
slop (3.3.3)
|
57
60
|
sqlite3 (1.3.6)
|
58
61
|
thor (0.16.0)
|
59
|
-
tzinfo (0.3.
|
62
|
+
tzinfo (0.3.35)
|
60
63
|
|
61
64
|
PLATFORMS
|
62
65
|
ruby
|
@@ -65,10 +68,11 @@ DEPENDENCIES
|
|
65
68
|
activerecord (~> 3.2)
|
66
69
|
activesupport (~> 3.2)
|
67
70
|
crypt_keeper!
|
68
|
-
guard (~> 1.
|
69
|
-
guard-rspec (~>
|
71
|
+
guard (~> 1.6.0)
|
72
|
+
guard-rspec (~> 2.3.0)
|
70
73
|
mysql2 (~> 0.3.11)
|
71
74
|
pg (~> 0.14.0)
|
72
|
-
rake (~> 0.
|
73
|
-
|
75
|
+
rake (~> 10.0.3)
|
76
|
+
rb-fsevent (~> 0.9.1)
|
77
|
+
rspec (~> 2.12.0)
|
74
78
|
sqlite3
|
data/lib/crypt_keeper/model.rb
CHANGED
@@ -83,7 +83,11 @@ module CryptKeeper
|
|
83
83
|
|
84
84
|
# Private: An instance of the encryptor class
|
85
85
|
def encryptor
|
86
|
-
@encryptor ||=
|
86
|
+
@encryptor ||= if crypt_keeper_encryptor.blank?
|
87
|
+
raise ArgumentError.new('You must specify an encryptor')
|
88
|
+
else
|
89
|
+
encryptor_klass.new(crypt_keeper_options.dup)
|
90
|
+
end
|
87
91
|
end
|
88
92
|
|
89
93
|
# Private: The encryptor class
|
data/lib/crypt_keeper/version.rb
CHANGED
@@ -4,6 +4,11 @@ module CryptKeeper::LogSubscriber
|
|
4
4
|
describe PostgresPgp do
|
5
5
|
use_postgres
|
6
6
|
|
7
|
+
# Fire the ActiveSupport.on_load
|
8
|
+
before do
|
9
|
+
CryptKeeper::Provider::PostgresPgp.new key: 'secret'
|
10
|
+
end
|
11
|
+
|
7
12
|
subject { ::ActiveRecord::LogSubscriber.new }
|
8
13
|
|
9
14
|
let(:input_query) do
|
data/spec/model_spec.rb
CHANGED
@@ -13,18 +13,18 @@ module CryptKeeper
|
|
13
13
|
end
|
14
14
|
|
15
15
|
context "Fields" do
|
16
|
-
it "
|
16
|
+
it "enables encryption for the given fields" do
|
17
17
|
subject.crypt_keeper :storage, :secret, encryptor: :fake_encryptor
|
18
18
|
subject.crypt_keeper_fields.should == [:storage, :secret]
|
19
19
|
end
|
20
20
|
|
21
|
-
it "
|
21
|
+
it "raises an exception for missing field" do
|
22
22
|
msg = "Column :none does not exist"
|
23
23
|
subject.crypt_keeper :none, encryptor: :fake_encryptor
|
24
24
|
expect { subject.new.save }.to raise_error(ArgumentError, msg)
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
27
|
+
it "raises an exception for non text fields" do
|
28
28
|
msg = "Column :name must be of type 'text' to be used for encryption"
|
29
29
|
subject.crypt_keeper :name, encryptor: :fake_encryptor
|
30
30
|
expect { subject.new.save }.to raise_error(ArgumentError, msg)
|
@@ -32,16 +32,20 @@ module CryptKeeper
|
|
32
32
|
end
|
33
33
|
|
34
34
|
context "Options" do
|
35
|
-
it "
|
35
|
+
it "stores options in crypt_keeper_options" do
|
36
36
|
subject.crypt_keeper :storage, :secret, key1: 1, key2: 2, encryptor: :fake_encryptor
|
37
37
|
subject.crypt_keeper_options.should == { key1: 1, key2: 2 }
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
40
|
+
it "accepts the class name as a string" do
|
41
41
|
subject.crypt_keeper :storage, :secret, key1: 1, key2: 2, encryptor: "FakeEncryptor"
|
42
42
|
subject.send(:encryptor_klass).should == CryptKeeper::Provider::FakeEncryptor
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
+
it "raises an error on missing encryptor" do
|
46
|
+
msg = "You must specify an encryptor"
|
47
|
+
subject.crypt_keeper :storage, :secret
|
48
|
+
expect { subject.create! storage: 'asdf' }.to raise_error(ArgumentError, msg)
|
45
49
|
end
|
46
50
|
end
|
47
51
|
end
|
data/spec/provider/aes_spec.rb
CHANGED
@@ -10,13 +10,8 @@ module CryptKeeper
|
|
10
10
|
Digest::SHA256.digest('cake')
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should raise an exception with a missing key" do
|
18
|
-
expect { Aes.new }.to raise_error(ArgumentError, "Missing :key")
|
19
|
-
end
|
13
|
+
its(:key) { should == hexed_key }
|
14
|
+
specify { expect { Aes.new }.to raise_error(ArgumentError, "Missing :key") }
|
20
15
|
end
|
21
16
|
|
22
17
|
describe "#encrypt" do
|
@@ -24,11 +19,8 @@ module CryptKeeper
|
|
24
19
|
subject.encrypt 'string'
|
25
20
|
end
|
26
21
|
|
27
|
-
|
28
|
-
|
29
|
-
encrypted.should_not be_nil
|
30
|
-
encrypted.should_not be_empty
|
31
|
-
end
|
22
|
+
specify { encrypted.should_not == 'string' }
|
23
|
+
specify { encrypted.should_not be_blank }
|
32
24
|
end
|
33
25
|
|
34
26
|
describe "#decrypt" do
|
@@ -36,9 +28,7 @@ module CryptKeeper
|
|
36
28
|
subject.decrypt "MC41MDk5MjI2NjgxMDI1MDI2OmNyeXB0X2tlZXBlcjpPI/8dCqWXDMVj7Jqs\nuwf/\n"
|
37
29
|
end
|
38
30
|
|
39
|
-
|
40
|
-
decrypted.should == 'string'
|
41
|
-
end
|
31
|
+
specify { decrypted.should == 'string' }
|
42
32
|
end
|
43
33
|
end
|
44
34
|
end
|
@@ -19,22 +19,16 @@ module CryptKeeper
|
|
19
19
|
its(:key) { should == 'candy' }
|
20
20
|
|
21
21
|
describe "#initialize" do
|
22
|
-
|
23
|
-
expect { MysqlAes.new }.to raise_error(ArgumentError, "Missing :key")
|
24
|
-
end
|
22
|
+
specify { expect { MysqlAes.new }.to raise_error(ArgumentError, "Missing :key") }
|
25
23
|
end
|
26
24
|
|
27
25
|
describe "#encrypt" do
|
28
|
-
|
29
|
-
|
30
|
-
subject.encrypt(plain_text).should_not be_empty
|
31
|
-
end
|
26
|
+
specify { subject.encrypt(plain_text).should_not == plain_text }
|
27
|
+
specify { subject.encrypt(plain_text).should_not be_blank }
|
32
28
|
end
|
33
29
|
|
34
30
|
describe "#decrypt" do
|
35
|
-
|
36
|
-
subject.decrypt(cipher_text).should == plain_text
|
37
|
-
end
|
31
|
+
specify { subject.decrypt(cipher_text).should == plain_text }
|
38
32
|
end
|
39
33
|
end
|
40
34
|
end
|
@@ -16,27 +16,23 @@ module CryptKeeper
|
|
16
16
|
its(:key) { should == 'candy' }
|
17
17
|
|
18
18
|
describe "#initialize" do
|
19
|
-
|
20
|
-
expect { PostgresPgp.new }.to raise_error(ArgumentError, "Missing :key")
|
21
|
-
end
|
19
|
+
specify { expect { PostgresPgp.new }.to raise_error(ArgumentError, "Missing :key") }
|
22
20
|
end
|
23
21
|
|
24
22
|
describe "#encrypt" do
|
25
|
-
|
26
|
-
subject.encrypt(plain_text).should_not == plain_text
|
27
|
-
subject.encrypt(plain_text).should_not be_empty
|
23
|
+
context "Strings" do
|
24
|
+
specify { subject.encrypt(plain_text).should_not == plain_text }
|
25
|
+
specify { subject.encrypt(plain_text).should_not be_empty }
|
28
26
|
end
|
29
27
|
|
30
|
-
|
31
|
-
subject.encrypt(integer_plain_text).should_not == integer_plain_text
|
32
|
-
subject.encrypt(integer_plain_text).should_not be_empty
|
28
|
+
context "Integers" do
|
29
|
+
specify { subject.encrypt(integer_plain_text).should_not == integer_plain_text }
|
30
|
+
specify { subject.encrypt(integer_plain_text).should_not be_empty }
|
33
31
|
end
|
34
32
|
end
|
35
33
|
|
36
34
|
describe "#decrypt" do
|
37
|
-
|
38
|
-
subject.decrypt(cipher_text).should == plain_text
|
39
|
-
end
|
35
|
+
specify { subject.decrypt(cipher_text).should == plain_text }
|
40
36
|
end
|
41
37
|
end
|
42
38
|
end
|
@@ -8,7 +8,6 @@ module CryptKeeper
|
|
8
8
|
class SensitiveData < ActiveRecord::Base; end
|
9
9
|
|
10
10
|
module ConnectionHelpers
|
11
|
-
|
12
11
|
def use_postgres
|
13
12
|
before :all do
|
14
13
|
::ActiveRecord::Base.clear_active_connections!
|
@@ -29,7 +28,7 @@ module CryptKeeper
|
|
29
28
|
before :all do
|
30
29
|
::ActiveRecord::Base.clear_active_connections!
|
31
30
|
::ActiveRecord::Base.establish_connection(:adapter => 'sqlite3',
|
32
|
-
|
31
|
+
:database => ':memory:')
|
33
32
|
|
34
33
|
::ActiveRecord::Schema.define do
|
35
34
|
create_table :sensitive_data, :force => true do |t|
|
@@ -40,7 +39,6 @@ module CryptKeeper
|
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
43
|
-
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crypt_keeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
requirements:
|
67
67
|
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 2.
|
69
|
+
version: 2.12.0
|
70
70
|
type: :development
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,7 +74,7 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 2.
|
77
|
+
version: 2.12.0
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: guard
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
requirements:
|
83
83
|
- - ~>
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 1.
|
85
|
+
version: 1.6.0
|
86
86
|
type: :development
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -90,7 +90,7 @@ dependencies:
|
|
90
90
|
requirements:
|
91
91
|
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 1.
|
93
|
+
version: 1.6.0
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: guard-rspec
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - ~>
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
101
|
+
version: 2.3.0
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -106,7 +106,7 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
109
|
+
version: 2.3.0
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
111
|
name: rake
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,7 +114,7 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
117
|
+
version: 10.0.3
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -122,7 +122,23 @@ dependencies:
|
|
122
122
|
requirements:
|
123
123
|
- - ~>
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0.
|
125
|
+
version: 10.0.3
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rb-fsevent
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ~>
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 0.9.1
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ~>
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 0.9.1
|
126
142
|
- !ruby/object:Gem::Dependency
|
127
143
|
name: sqlite3
|
128
144
|
requirement: !ruby/object:Gem::Requirement
|
@@ -227,7 +243,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
227
243
|
version: '0'
|
228
244
|
segments:
|
229
245
|
- 0
|
230
|
-
hash:
|
246
|
+
hash: 838883882659964076
|
231
247
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
232
248
|
none: false
|
233
249
|
requirements:
|
@@ -236,10 +252,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
252
|
version: '0'
|
237
253
|
segments:
|
238
254
|
- 0
|
239
|
-
hash:
|
255
|
+
hash: 838883882659964076
|
240
256
|
requirements: []
|
241
257
|
rubyforge_project:
|
242
|
-
rubygems_version: 1.8.
|
258
|
+
rubygems_version: 1.8.24
|
243
259
|
signing_key:
|
244
260
|
specification_version: 3
|
245
261
|
summary: Transparent encryption for ActiveRecord that isn't over-engineered
|