attr_encrypted-magicless 1.3.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/.travis.yml +6 -0
- data/Gemfile +9 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +336 -0
- data/Rakefile +24 -0
- data/attr_encrypted-magicless.gemspec +38 -0
- data/lib/attr_encrypted-magicless.rb +1 -0
- data/lib/attr_encrypted.rb +384 -0
- data/lib/attr_encrypted/adapters/active_record.rb +49 -0
- data/lib/attr_encrypted/version.rb +3 -0
- data/test/active_record_test.rb +230 -0
- data/test/attr_encrypted_test.rb +339 -0
- data/test/compatibility_test.rb +106 -0
- data/test/legacy_active_record_test.rb +94 -0
- data/test/legacy_attr_encrypted_test.rb +306 -0
- data/test/legacy_compatibility_test.rb +87 -0
- data/test/test_helper.rb +38 -0
- metadata +245 -0
@@ -0,0 +1,306 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../test_helper', __FILE__)
|
3
|
+
|
4
|
+
class LegacySillyEncryptor
|
5
|
+
def self.silly_encrypt(options)
|
6
|
+
(options[:value] + options[:some_arg]).reverse
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.silly_decrypt(options)
|
10
|
+
options[:value].reverse.gsub(/#{options[:some_arg]}$/, '')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class LegacyUser
|
15
|
+
include AttrEncrypted
|
16
|
+
|
17
|
+
self.attr_encrypted_options[:key] = Proc.new { |user| user.class.to_s } # default key
|
18
|
+
|
19
|
+
attr_encrypted :email, :without_encoding, :key => 'secret key'
|
20
|
+
attr_encrypted :password, :prefix => 'crypted_', :suffix => '_test'
|
21
|
+
attr_encrypted :ssn, :key => :salt, :attribute => 'ssn_encrypted'
|
22
|
+
attr_encrypted :credit_card, :encryptor => LegacySillyEncryptor, :encrypt_method => :silly_encrypt, :decrypt_method => :silly_decrypt, :some_arg => 'test'
|
23
|
+
attr_encrypted :with_encoding, :key => 'secret key', :encode => true
|
24
|
+
attr_encrypted :with_custom_encoding, :key => 'secret key', :encode => 'm'
|
25
|
+
attr_encrypted :with_marshaling, :key => 'secret key', :marshal => true
|
26
|
+
attr_encrypted :with_true_if, :key => 'secret key', :if => true
|
27
|
+
attr_encrypted :with_false_if, :key => 'secret key', :if => false
|
28
|
+
attr_encrypted :with_true_unless, :key => 'secret key', :unless => true
|
29
|
+
attr_encrypted :with_false_unless, :key => 'secret key', :unless => false
|
30
|
+
attr_encrypted :with_if_changed, :key => 'secret key', :if => :should_encrypt
|
31
|
+
|
32
|
+
attr_encryptor :aliased, :key => 'secret_key'
|
33
|
+
|
34
|
+
attr_accessor :salt
|
35
|
+
attr_accessor :should_encrypt
|
36
|
+
|
37
|
+
def initialize
|
38
|
+
self.salt = Time.now.to_i.to_s
|
39
|
+
self.should_encrypt = true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class LegacyAdmin < LegacyUser
|
44
|
+
attr_encrypted :testing
|
45
|
+
end
|
46
|
+
|
47
|
+
class LegacySomeOtherClass
|
48
|
+
include AttrEncrypted
|
49
|
+
|
50
|
+
def self.call(object)
|
51
|
+
object.class
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class CryptedObject
|
56
|
+
include AttrEncrypted
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
class LegacyAttrEncryptedTest < Minitest::Test
|
61
|
+
|
62
|
+
def test_should_store_email_in_encrypted_attributes
|
63
|
+
assert LegacyUser.encrypted_attributes.include?(:email)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_should_not_store_salt_in_encrypted_attributes
|
67
|
+
assert !LegacyUser.encrypted_attributes.include?(:salt)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_attr_encrypted_should_return_true_for_email
|
71
|
+
assert LegacyUser.attr_encrypted?('email')
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_attr_encrypted_should_not_use_the_same_attribute_name_for_two_attributes_in_the_same_line
|
75
|
+
refute_equal LegacyUser.encrypted_attributes[:email][:attribute], LegacyUser.encrypted_attributes[:without_encoding][:attribute]
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_attr_encrypted_should_return_false_for_salt
|
79
|
+
assert !LegacyUser.attr_encrypted?('salt')
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_should_generate_an_encrypted_attribute
|
83
|
+
assert LegacyUser.new.respond_to?(:encrypted_email)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_should_generate_an_encrypted_attribute_with_a_prefix_and_suffix
|
87
|
+
assert LegacyUser.new.respond_to?(:crypted_password_test)
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_should_generate_an_encrypted_attribute_with_the_attribute_option
|
91
|
+
assert LegacyUser.new.respond_to?(:ssn_encrypted)
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_should_not_encrypt_nil_value
|
95
|
+
assert_nil LegacyUser.encrypt_email(nil)
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_should_not_encrypt_empty_string
|
99
|
+
assert_equal '', LegacyUser.encrypt_email('')
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_should_encrypt_email
|
103
|
+
refute_nil LegacyUser.encrypt_email('test@example.com')
|
104
|
+
refute_equal 'test@example.com', LegacyUser.encrypt_email('test@example.com')
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_should_encrypt_email_when_modifying_the_attr_writer
|
108
|
+
@user = LegacyUser.new
|
109
|
+
assert_nil @user.encrypted_email
|
110
|
+
@user.email = 'test@example.com'
|
111
|
+
refute_nil @user.encrypted_email
|
112
|
+
assert_equal LegacyUser.encrypt_email('test@example.com'), @user.encrypted_email
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_should_not_decrypt_nil_value
|
116
|
+
assert_nil LegacyUser.decrypt_email(nil)
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_should_not_decrypt_empty_string
|
120
|
+
assert_equal '', LegacyUser.decrypt_email('')
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_should_decrypt_email
|
124
|
+
encrypted_email = LegacyUser.encrypt_email('test@example.com')
|
125
|
+
refute_equal 'test@test.com', encrypted_email
|
126
|
+
assert_equal 'test@example.com', LegacyUser.decrypt_email(encrypted_email)
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_should_decrypt_email_when_reading
|
130
|
+
@user = LegacyUser.new
|
131
|
+
assert_nil @user.email
|
132
|
+
@user.encrypted_email = LegacyUser.encrypt_email('test@example.com')
|
133
|
+
assert_equal 'test@example.com', @user.email
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_should_encrypt_with_encoding
|
137
|
+
assert_equal LegacyUser.encrypt_with_encoding('test'), [LegacyUser.encrypt_without_encoding('test')].pack('m')
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_should_decrypt_with_encoding
|
141
|
+
encrypted = LegacyUser.encrypt_with_encoding('test')
|
142
|
+
assert_equal 'test', LegacyUser.decrypt_with_encoding(encrypted)
|
143
|
+
assert_equal LegacyUser.decrypt_with_encoding(encrypted), LegacyUser.decrypt_without_encoding(encrypted.unpack('m').first)
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_should_decrypt_utf8_with_encoding
|
147
|
+
encrypted = LegacyUser.encrypt_with_encoding("test\xC2\xA0utf-8\xC2\xA0text")
|
148
|
+
assert_equal "test\xC2\xA0utf-8\xC2\xA0text", LegacyUser.decrypt_with_encoding(encrypted)
|
149
|
+
assert_equal LegacyUser.decrypt_with_encoding(encrypted), LegacyUser.decrypt_without_encoding(encrypted.unpack('m').first)
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_should_encrypt_with_custom_encoding
|
153
|
+
assert_equal LegacyUser.encrypt_with_custom_encoding('test'), [LegacyUser.encrypt_without_encoding('test')].pack('m')
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_should_decrypt_with_custom_encoding
|
157
|
+
encrypted = LegacyUser.encrypt_with_custom_encoding('test')
|
158
|
+
assert_equal 'test', LegacyUser.decrypt_with_custom_encoding(encrypted)
|
159
|
+
assert_equal LegacyUser.decrypt_with_custom_encoding(encrypted), LegacyUser.decrypt_without_encoding(encrypted.unpack('m').first)
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_should_encrypt_with_marshaling
|
163
|
+
@user = LegacyUser.new
|
164
|
+
@user.with_marshaling = [1, 2, 3]
|
165
|
+
refute_nil @user.encrypted_with_marshaling
|
166
|
+
assert_equal LegacyUser.encrypt_with_marshaling([1, 2, 3]), @user.encrypted_with_marshaling
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_should_decrypt_with_marshaling
|
170
|
+
encrypted = LegacyUser.encrypt_with_marshaling([1, 2, 3])
|
171
|
+
@user = LegacyUser.new
|
172
|
+
assert_nil @user.with_marshaling
|
173
|
+
@user.encrypted_with_marshaling = encrypted
|
174
|
+
assert_equal [1, 2, 3], @user.with_marshaling
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_should_use_custom_encryptor_and_crypt_method_names_and_arguments
|
178
|
+
assert_equal LegacySillyEncryptor.silly_encrypt(:value => 'testing', :some_arg => 'test'), LegacyUser.encrypt_credit_card('testing')
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_should_evaluate_a_key_passed_as_a_symbol
|
182
|
+
@user = LegacyUser.new
|
183
|
+
assert_nil @user.ssn_encrypted
|
184
|
+
@user.ssn = 'testing'
|
185
|
+
refute_nil @user.ssn_encrypted
|
186
|
+
assert_equal Encryptor.encrypt(:value => 'testing', :key => @user.salt), @user.ssn_encrypted
|
187
|
+
end
|
188
|
+
|
189
|
+
def test_should_evaluate_a_key_passed_as_a_proc
|
190
|
+
@user = LegacyUser.new
|
191
|
+
assert_nil @user.crypted_password_test
|
192
|
+
@user.password = 'testing'
|
193
|
+
refute_nil @user.crypted_password_test
|
194
|
+
assert_equal Encryptor.encrypt(:value => 'testing', :key => 'LegacyUser'), @user.crypted_password_test
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_should_use_options_found_in_the_attr_encrypted_options_attribute
|
198
|
+
@user = LegacyUser.new
|
199
|
+
assert_nil @user.crypted_password_test
|
200
|
+
@user.password = 'testing'
|
201
|
+
refute_nil @user.crypted_password_test
|
202
|
+
assert_equal Encryptor.encrypt(:value => 'testing', :key => 'LegacyUser'), @user.crypted_password_test
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_should_inherit_encrypted_attributes
|
206
|
+
assert_equal [LegacyUser.encrypted_attributes.keys, :testing].flatten.collect { |key| key.to_s }.sort, LegacyAdmin.encrypted_attributes.keys.collect { |key| key.to_s }.sort
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_should_inherit_attr_encrypted_options
|
210
|
+
assert !LegacyUser.attr_encrypted_options.empty?
|
211
|
+
assert_equal LegacyUser.attr_encrypted_options, LegacyAdmin.attr_encrypted_options
|
212
|
+
end
|
213
|
+
|
214
|
+
def test_should_not_inherit_unrelated_attributes
|
215
|
+
assert LegacySomeOtherClass.attr_encrypted_options.empty?
|
216
|
+
assert LegacySomeOtherClass.encrypted_attributes.empty?
|
217
|
+
end
|
218
|
+
|
219
|
+
def test_should_evaluate_a_symbol_option
|
220
|
+
assert_equal CryptedObject, CryptedObject.new.send(:evaluate_attr_encrypted_option, :class)
|
221
|
+
end
|
222
|
+
|
223
|
+
def test_should_evaluate_a_proc_option
|
224
|
+
assert_equal CryptedObject, CryptedObject.new.send(:evaluate_attr_encrypted_option, proc { |object| object.class })
|
225
|
+
end
|
226
|
+
|
227
|
+
def test_should_evaluate_a_lambda_option
|
228
|
+
assert_equal CryptedObject, CryptedObject.new.send(:evaluate_attr_encrypted_option, lambda { |object| object.class })
|
229
|
+
end
|
230
|
+
|
231
|
+
def test_should_evaluate_a_method_option
|
232
|
+
assert_equal CryptedObject, CryptedObject.new.send(:evaluate_attr_encrypted_option, LegacySomeOtherClass.method(:call))
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_should_return_a_string_option
|
236
|
+
assert_equal 'CryptedObject', CryptedObject.new.send(:evaluate_attr_encrypted_option, 'CryptedObject')
|
237
|
+
end
|
238
|
+
|
239
|
+
def test_should_encrypt_with_true_if
|
240
|
+
@user = LegacyUser.new
|
241
|
+
assert_nil @user.encrypted_with_true_if
|
242
|
+
@user.with_true_if = 'testing'
|
243
|
+
refute_nil @user.encrypted_with_true_if
|
244
|
+
assert_equal Encryptor.encrypt(:value => 'testing', :key => 'secret key'), @user.encrypted_with_true_if
|
245
|
+
end
|
246
|
+
|
247
|
+
def test_should_not_encrypt_with_false_if
|
248
|
+
@user = LegacyUser.new
|
249
|
+
assert_nil @user.encrypted_with_false_if
|
250
|
+
@user.with_false_if = 'testing'
|
251
|
+
refute_nil @user.encrypted_with_false_if
|
252
|
+
assert_equal 'testing', @user.encrypted_with_false_if
|
253
|
+
end
|
254
|
+
|
255
|
+
def test_should_encrypt_with_false_unless
|
256
|
+
@user = LegacyUser.new
|
257
|
+
assert_nil @user.encrypted_with_false_unless
|
258
|
+
@user.with_false_unless = 'testing'
|
259
|
+
refute_nil @user.encrypted_with_false_unless
|
260
|
+
assert_equal Encryptor.encrypt(:value => 'testing', :key => 'secret key'), @user.encrypted_with_false_unless
|
261
|
+
end
|
262
|
+
|
263
|
+
def test_should_not_encrypt_with_true_unless
|
264
|
+
@user = LegacyUser.new
|
265
|
+
assert_nil @user.encrypted_with_true_unless
|
266
|
+
@user.with_true_unless = 'testing'
|
267
|
+
refute_nil @user.encrypted_with_true_unless
|
268
|
+
assert_equal 'testing', @user.encrypted_with_true_unless
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_should_work_with_aliased_attr_encryptor
|
272
|
+
assert LegacyUser.encrypted_attributes.include?(:aliased)
|
273
|
+
end
|
274
|
+
|
275
|
+
def test_should_always_reset_options
|
276
|
+
@user = LegacyUser.new
|
277
|
+
@user.with_if_changed = "encrypt_stuff"
|
278
|
+
@user.stubs(:instance_variable_get).returns(nil)
|
279
|
+
@user.stubs(:instance_variable_set).raises("BadStuff")
|
280
|
+
assert_raises RuntimeError do
|
281
|
+
@user.with_if_changed
|
282
|
+
end
|
283
|
+
|
284
|
+
@user = LegacyUser.new
|
285
|
+
@user.should_encrypt = false
|
286
|
+
@user.with_if_changed = "not_encrypted_stuff"
|
287
|
+
assert_equal "not_encrypted_stuff", @user.with_if_changed
|
288
|
+
assert_equal "not_encrypted_stuff", @user.encrypted_with_if_changed
|
289
|
+
end
|
290
|
+
|
291
|
+
def test_should_cast_values_as_strings_before_encrypting
|
292
|
+
string_encrypted_email = LegacyUser.encrypt_email('3')
|
293
|
+
assert_equal string_encrypted_email, LegacyUser.encrypt_email(3)
|
294
|
+
assert_equal '3', LegacyUser.decrypt_email(string_encrypted_email)
|
295
|
+
end
|
296
|
+
|
297
|
+
def test_should_create_query_accessor
|
298
|
+
@user = LegacyUser.new
|
299
|
+
assert !@user.email?
|
300
|
+
@user.email = ''
|
301
|
+
assert !@user.email?
|
302
|
+
@user.email = 'test@example.com'
|
303
|
+
assert @user.email?
|
304
|
+
end
|
305
|
+
|
306
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../test_helper', __FILE__)
|
3
|
+
|
4
|
+
# Test to ensure that existing representations in database do not break on
|
5
|
+
# migrating to new versions of this gem. This ensures that future versions of
|
6
|
+
# this gem will retain backwards compatibility with data generated by earlier
|
7
|
+
# versions.
|
8
|
+
class LegacyCompatibilityTest < Minitest::Test
|
9
|
+
class LegacyNonmarshallingPet < ActiveRecord::Base
|
10
|
+
PET_NICKNAME_SALT = Digest::SHA256.hexdigest('my-really-really-secret-pet-nickname-salt')
|
11
|
+
PET_NICKNAME_KEY = 'my-really-really-secret-pet-nickname-key'
|
12
|
+
PET_BIRTHDATE_SALT = Digest::SHA256.hexdigest('my-really-really-secret-pet-birthdate-salt')
|
13
|
+
PET_BIRTHDATE_KEY = 'my-really-really-secret-pet-birthdate-key'
|
14
|
+
|
15
|
+
attr_encrypted :nickname,
|
16
|
+
:key => proc { Encryptor.encrypt(:value => PET_NICKNAME_SALT, :key => PET_NICKNAME_KEY) }
|
17
|
+
attr_encrypted :birthdate,
|
18
|
+
:key => proc { Encryptor.encrypt(:value => PET_BIRTHDATE_SALT, :key => PET_BIRTHDATE_KEY) }
|
19
|
+
end
|
20
|
+
|
21
|
+
class LegacyMarshallingPet < ActiveRecord::Base
|
22
|
+
PET_NICKNAME_SALT = Digest::SHA256.hexdigest('my-really-really-secret-pet-nickname-salt')
|
23
|
+
PET_NICKNAME_KEY = 'my-really-really-secret-pet-nickname-key'
|
24
|
+
PET_BIRTHDATE_SALT = Digest::SHA256.hexdigest('my-really-really-secret-pet-birthdate-salt')
|
25
|
+
PET_BIRTHDATE_KEY = 'my-really-really-secret-pet-birthdate-key'
|
26
|
+
|
27
|
+
attr_encrypted :nickname,
|
28
|
+
:key => proc { Encryptor.encrypt(:value => PET_NICKNAME_SALT, :key => PET_NICKNAME_KEY) },
|
29
|
+
:marshal => true
|
30
|
+
attr_encrypted :birthdate,
|
31
|
+
:key => proc { Encryptor.encrypt(:value => PET_BIRTHDATE_SALT, :key => PET_BIRTHDATE_KEY) },
|
32
|
+
:marshal => true
|
33
|
+
end
|
34
|
+
|
35
|
+
def setup
|
36
|
+
ActiveRecord::Base.connection.tables.each { |table| ActiveRecord::Base.connection.drop_table(table) }
|
37
|
+
create_tables
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_nonmarshalling_backwards_compatibility
|
41
|
+
pet = LegacyNonmarshallingPet.create!(
|
42
|
+
:name => 'Fido',
|
43
|
+
:encrypted_nickname => 'uSUB6KGzta87yxesyVc3DA==',
|
44
|
+
:encrypted_birthdate => 'I3d691B2PtFXLx15kO067g=='
|
45
|
+
)
|
46
|
+
|
47
|
+
assert_equal 'Fido', pet.name
|
48
|
+
assert_equal 'Fido the Dog', pet.nickname
|
49
|
+
assert_equal '2011-07-09', pet.birthdate
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_marshalling_backwards_compatibility
|
53
|
+
pet = LegacyMarshallingPet.create!(
|
54
|
+
:name => 'Fido',
|
55
|
+
:encrypted_nickname => '7RwoT64in4H+fGVBPYtRcN0K4RtriIy1EP4nDojUa8g=',
|
56
|
+
:encrypted_birthdate => 'bSp9sJhXQSp2QlNZHiujtcK4lRVBE8HQhn1y7moQ63bGJR20hvRSZ73ePAmm+wc5'
|
57
|
+
)
|
58
|
+
|
59
|
+
assert_equal 'Fido', pet.name
|
60
|
+
assert_equal 'Mummy\'s little helper', pet.nickname
|
61
|
+
|
62
|
+
assert_equal Date.new(2011, 7, 9), pet.birthdate
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def create_tables
|
68
|
+
silence_stream(STDOUT) do
|
69
|
+
ActiveRecord::Schema.define(:version => 1) do
|
70
|
+
create_table :legacy_nonmarshalling_pets do |t|
|
71
|
+
t.string :name
|
72
|
+
t.string :encrypted_nickname
|
73
|
+
t.string :encrypted_birthdate
|
74
|
+
t.string :salt
|
75
|
+
end
|
76
|
+
create_table :legacy_marshalling_pets do |t|
|
77
|
+
t.string :name
|
78
|
+
t.string :encrypted_nickname
|
79
|
+
t.string :encrypted_birthdate
|
80
|
+
t.string :salt
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => ':memory:'
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
if RUBY_VERSION >= '1.9.3'
|
2
|
+
require 'simplecov'
|
3
|
+
require 'simplecov-rcov'
|
4
|
+
|
5
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
6
|
+
SimpleCov::Formatter::HTMLFormatter,
|
7
|
+
SimpleCov::Formatter::RcovFormatter,
|
8
|
+
]
|
9
|
+
|
10
|
+
SimpleCov.start do
|
11
|
+
add_filter 'test'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# ENV['ACTIVE_RECORD_VERSION'] ||= ENV['ACTIVERECORD']
|
16
|
+
|
17
|
+
require 'minitest'
|
18
|
+
require 'minitest/autorun'
|
19
|
+
require 'digest/sha2'
|
20
|
+
require 'rubygems'
|
21
|
+
gem 'activerecord', ENV['ACTIVE_RECORD_VERSION'] if ENV['ACTIVE_RECORD_VERSION']
|
22
|
+
require 'active_record'
|
23
|
+
require 'mocha/test_unit'
|
24
|
+
|
25
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
26
|
+
$:.unshift(File.dirname(__FILE__))
|
27
|
+
require 'attr_encrypted'
|
28
|
+
|
29
|
+
require 'active_support/lazy_load_hooks'
|
30
|
+
|
31
|
+
ActiveSupport.on_load(:active_record) do
|
32
|
+
include AttrEncrypted
|
33
|
+
end
|
34
|
+
|
35
|
+
puts "\nTesting with ActiveRecord #{ActiveRecord::VERSION::STRING rescue ENV['ACTIVE_RECORD_VERSION']}"
|
36
|
+
|
37
|
+
SECRET_KEY = 4.times.map { Digest::SHA256.hexdigest((Time.now.to_i * rand(5)).to_s) }.join
|
38
|
+
|
metadata
ADDED
@@ -0,0 +1,245 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: attr_encrypted-magicless
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.42
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sean Huber
|
8
|
+
- S. Brent Faulkner
|
9
|
+
- William Monk
|
10
|
+
- Stephen Aghaulor
|
11
|
+
autorequire:
|
12
|
+
bindir: exe
|
13
|
+
cert_chain: []
|
14
|
+
date: 2015-09-09 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: encryptor
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.3.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.3.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: activesupport
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '4.0'
|
37
|
+
- - "<"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '5.0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '4.0'
|
47
|
+
- - "<"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '5.0'
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: bundler
|
52
|
+
requirement: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '1.10'
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '1.10'
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: rake
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '10.0'
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '10.0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rdoc
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
type: :development
|
86
|
+
prerelease: false
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
name: sqlite3
|
94
|
+
requirement: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
- !ruby/object:Gem::Dependency
|
107
|
+
name: activerecord
|
108
|
+
requirement: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '4.0'
|
113
|
+
- - "<"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '5.0'
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '4.0'
|
123
|
+
- - "<"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '5.0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: minitest
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: mocha
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: 1.0.0
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: 1.0.0
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: simplecov
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: simplecov-rcov
|
170
|
+
requirement: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
type: :development
|
176
|
+
prerelease: false
|
177
|
+
version_requirements: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
description: Generates attr_accessors that encrypt and decrypt attributes transparently
|
183
|
+
email:
|
184
|
+
- shuber@huberry.com
|
185
|
+
- sbfaulkner@gmail.com
|
186
|
+
- billy.monk@gmail.com
|
187
|
+
- saghaulor@gmail.com
|
188
|
+
executables: []
|
189
|
+
extensions: []
|
190
|
+
extra_rdoc_files: []
|
191
|
+
files:
|
192
|
+
- ".gitignore"
|
193
|
+
- ".travis.yml"
|
194
|
+
- Gemfile
|
195
|
+
- MIT-LICENSE
|
196
|
+
- README.rdoc
|
197
|
+
- Rakefile
|
198
|
+
- attr_encrypted-magicless.gemspec
|
199
|
+
- lib/attr_encrypted-magicless.rb
|
200
|
+
- lib/attr_encrypted.rb
|
201
|
+
- lib/attr_encrypted/adapters/active_record.rb
|
202
|
+
- lib/attr_encrypted/version.rb
|
203
|
+
- test/active_record_test.rb
|
204
|
+
- test/attr_encrypted_test.rb
|
205
|
+
- test/compatibility_test.rb
|
206
|
+
- test/legacy_active_record_test.rb
|
207
|
+
- test/legacy_attr_encrypted_test.rb
|
208
|
+
- test/legacy_compatibility_test.rb
|
209
|
+
- test/test_helper.rb
|
210
|
+
homepage: https://github.com/estum/attr_encrypted
|
211
|
+
licenses: []
|
212
|
+
metadata: {}
|
213
|
+
post_install_message:
|
214
|
+
rdoc_options:
|
215
|
+
- "--line-numbers"
|
216
|
+
- "--inline-source"
|
217
|
+
- "--main"
|
218
|
+
- README.rdoc
|
219
|
+
require_paths:
|
220
|
+
- lib
|
221
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
222
|
+
requirements:
|
223
|
+
- - ">="
|
224
|
+
- !ruby/object:Gem::Version
|
225
|
+
version: '0'
|
226
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - ">="
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0'
|
231
|
+
requirements: []
|
232
|
+
rubyforge_project:
|
233
|
+
rubygems_version: 2.4.8
|
234
|
+
signing_key:
|
235
|
+
specification_version: 4
|
236
|
+
summary: Encrypt and decrypt attributes
|
237
|
+
test_files:
|
238
|
+
- test/active_record_test.rb
|
239
|
+
- test/attr_encrypted_test.rb
|
240
|
+
- test/compatibility_test.rb
|
241
|
+
- test/legacy_active_record_test.rb
|
242
|
+
- test/legacy_attr_encrypted_test.rb
|
243
|
+
- test/legacy_compatibility_test.rb
|
244
|
+
- test/test_helper.rb
|
245
|
+
has_rdoc: false
|