attr_encrypted 4.0.0 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/CI.yml +43 -0
- data/CHANGELOG.md +9 -0
- data/README.md +4 -5
- data/attr_encrypted.gemspec +3 -4
- data/lib/attr_encrypted/adapters/active_record.rb +11 -11
- data/lib/attr_encrypted/version.rb +2 -2
- data/lib/attr_encrypted.rb +1 -1
- data/test/legacy_active_record_test.rb +9 -3
- data/test/test_helper.rb +6 -8
- metadata +11 -25
- data/.travis.yml +0 -22
- data/lib/attr_encrypted/adapters/data_mapper.rb +0 -24
- data/test/data_mapper_test.rb +0 -59
- data/test/legacy_data_mapper_test.rb +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c21421f2067b7534cedb1a861331873c4b3de6b578d9f0afa0579d7fb734cfa
|
4
|
+
data.tar.gz: 73d1180d07c224bc7b8a7d80691cde48a07eb6d9fd009d7d5a41974b6bde02e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 559cccac0a575b7c7834a0464c7ab218549e59cecc1c43d3ba6d7177994d18759d76b04e5a574d45a22ef0d57cb24f3881242282cb6ce3425b462d48cf48b3be
|
7
|
+
data.tar.gz: '09933cf933635867a06243b779ab46673266372a6b314f70a09faddac7aa75cb501b52510beb1f06f87a6a2ad104ff023e2d9b0b93a1c4f71e8888ab0b4a7dcc'
|
@@ -0,0 +1,43 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
name: Ruby ${{ matrix.ruby }} / ActiveRecord ${{ matrix.active_record }}
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
strategy:
|
14
|
+
fail-fast: false
|
15
|
+
matrix:
|
16
|
+
active_record:
|
17
|
+
- '6.0'
|
18
|
+
- '6.1'
|
19
|
+
- '7.0'
|
20
|
+
- '7.1'
|
21
|
+
ruby:
|
22
|
+
- '2.7'
|
23
|
+
- '3.0'
|
24
|
+
- '3.1'
|
25
|
+
- '3.2'
|
26
|
+
include:
|
27
|
+
- active_record: '5.1'
|
28
|
+
ruby: '2.7'
|
29
|
+
- active_record: '5.2'
|
30
|
+
ruby: '2.7'
|
31
|
+
- active_record: '7.1'
|
32
|
+
ruby: '3.3'
|
33
|
+
env:
|
34
|
+
ACTIVERECORD: ${{ matrix.active_record }}
|
35
|
+
steps:
|
36
|
+
- uses: actions/checkout@v3
|
37
|
+
- name: Set up Ruby
|
38
|
+
uses: ruby/setup-ruby@v1
|
39
|
+
with:
|
40
|
+
ruby-version: ${{ matrix.ruby }}
|
41
|
+
bundler-cache: true
|
42
|
+
- run: |
|
43
|
+
bundle exec rake test
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# attr_encrypted
|
2
2
|
|
3
|
+
## 4.1.1
|
4
|
+
|
5
|
+
* Fixed: Fix SystemStackError when extending the reload method with Module#prepend.
|
6
|
+
|
7
|
+
## 4.1.0
|
8
|
+
|
9
|
+
* Changed: Dropped support for `datamapper` which has not had a release since October 2011. This is in an attempt to make
|
10
|
+
maintenance and testing easier moving forward.
|
11
|
+
|
3
12
|
## 4.0.0
|
4
13
|
|
5
14
|
* Added: Support for Ruby >= 3.0.
|
data/README.md
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
# attr_encrypted
|
2
2
|
|
3
|
-
|
3
|
+
![workflow](https://github.com/attr-encrypted/attr_encrypted/actions/workflows/CI.yml/badge.svg) [![Gem Version](https://badge.fury.io/rb/attr_encrypted.svg)](https://badge.fury.io/rb/attr_encrypted)
|
4
4
|
|
5
5
|
Generates attr_accessors that transparently encrypt and decrypt attributes.
|
6
6
|
|
7
|
-
It works with ANY class, however, you get a few extra features when you're using it with `ActiveRecord
|
8
|
-
|
7
|
+
It works with ANY class, however, you get a few extra features when you're using it with `ActiveRecord` or `Sequel`.
|
9
8
|
|
10
9
|
## Installation
|
11
10
|
|
@@ -23,7 +22,7 @@ Then install the gem:
|
|
23
22
|
|
24
23
|
## Usage
|
25
24
|
|
26
|
-
If you're using an ORM like `ActiveRecord
|
25
|
+
If you're using an ORM like `ActiveRecord` or `Sequel`, using attr_encrypted is easy:
|
27
26
|
|
28
27
|
```ruby
|
29
28
|
class User
|
@@ -364,7 +363,7 @@ NOTE: This only works if all records are encrypted with the same encryption key
|
|
364
363
|
__NOTE: This feature is deprecated and will be removed in the next major release.__
|
365
364
|
|
366
365
|
|
367
|
-
###
|
366
|
+
### Sequel
|
368
367
|
|
369
368
|
#### Default options
|
370
369
|
|
data/attr_encrypted.gemspec
CHANGED
@@ -14,8 +14,8 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.summary = 'Encrypt and decrypt attributes'
|
15
15
|
s.description = 'Generates attr_accessors that encrypt and decrypt attributes transparently'
|
16
16
|
|
17
|
-
s.authors = ['Sean Huber', 'S. Brent Faulkner', 'William Monk', 'Stephen Aghaulor']
|
18
|
-
s.email = ['seah@shuber.io', 'sbfaulkner@gmail.com', 'billy.monk@gmail.com', 'saghaulor@gmail.com']
|
17
|
+
s.authors = ['Sean Huber', 'S. Brent Faulkner', 'William Monk', 'Stephen Aghaulor', 'Josh Branham', 'Mike Vastola']
|
18
|
+
s.email = ['seah@shuber.io', 'sbfaulkner@gmail.com', 'billy.monk@gmail.com', 'saghaulor@gmail.com', 'josh.php@gmail.com', 'Mike@Vasto.la']
|
19
19
|
s.homepage = 'http://github.com/attr-encrypted/attr_encrypted'
|
20
20
|
s.license = 'MIT'
|
21
21
|
|
@@ -29,13 +29,12 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.add_dependency('encryptor', ['~> 3.0.0'])
|
30
30
|
# support for testing with specific active record version
|
31
31
|
activerecord_version = if ENV.key?('ACTIVERECORD')
|
32
|
-
"~> #{ENV['ACTIVERECORD']}"
|
32
|
+
"~> #{ENV['ACTIVERECORD']}.0"
|
33
33
|
else
|
34
34
|
'>= 2.0.0'
|
35
35
|
end
|
36
36
|
s.add_development_dependency('activerecord', activerecord_version)
|
37
37
|
s.add_development_dependency('actionpack', activerecord_version)
|
38
|
-
s.add_development_dependency('datamapper')
|
39
38
|
s.add_development_dependency('rake')
|
40
39
|
s.add_development_dependency('minitest')
|
41
40
|
s.add_development_dependency('sequel')
|
@@ -6,19 +6,18 @@ if defined?(ActiveRecord::Base)
|
|
6
6
|
module ActiveRecord
|
7
7
|
RAILS_VERSION = Gem::Version.new(::ActiveRecord::VERSION::STRING).freeze
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
def reload(*args, &block)
|
15
|
-
result = reload_without_attr_encrypted(*args, &block)
|
16
|
-
self.class.attr_encrypted_encrypted_attributes.keys.each do |attribute_name|
|
17
|
-
instance_variable_set("@#{attribute_name}", nil)
|
18
|
-
end
|
19
|
-
result
|
9
|
+
module Reload
|
10
|
+
def reload(...)
|
11
|
+
result = super
|
12
|
+
self.class.attr_encrypted_encrypted_attributes.keys.each do |attribute_name|
|
13
|
+
instance_variable_set("@#{attribute_name}", nil)
|
20
14
|
end
|
15
|
+
result
|
16
|
+
end
|
17
|
+
end
|
21
18
|
|
19
|
+
def self.extended(base) # :nodoc:
|
20
|
+
base.class_eval do
|
22
21
|
attr_encrypted_options[:encode] = true
|
23
22
|
|
24
23
|
class << self
|
@@ -148,5 +147,6 @@ if defined?(ActiveRecord::Base)
|
|
148
147
|
ActiveSupport.on_load(:active_record) do
|
149
148
|
extend AttrEncrypted
|
150
149
|
extend AttrEncrypted::Adapters::ActiveRecord
|
150
|
+
prepend AttrEncrypted::Adapters::ActiveRecord::Reload
|
151
151
|
end
|
152
152
|
end
|
@@ -4,8 +4,8 @@ module AttrEncrypted
|
|
4
4
|
# Contains information about this gem's version
|
5
5
|
module Version
|
6
6
|
MAJOR = 4
|
7
|
-
MINOR =
|
8
|
-
PATCH =
|
7
|
+
MINOR = 1
|
8
|
+
PATCH = 1
|
9
9
|
|
10
10
|
# Returns a version string by joining <tt>MAJOR</tt>, <tt>MINOR</tt>, and <tt>PATCH</tt> with <tt>'.'</tt>
|
11
11
|
#
|
data/lib/attr_encrypted.rb
CHANGED
@@ -54,7 +54,7 @@ module AttrEncrypted
|
|
54
54
|
# string instead of just 'true'. See
|
55
55
|
# http://www.ruby-doc.org/core/classes/Array.html#M002245
|
56
56
|
# for more encoding directives.
|
57
|
-
# Defaults to false unless you're using it with ActiveRecord
|
57
|
+
# Defaults to false unless you're using it with ActiveRecord or Sequel.
|
58
58
|
#
|
59
59
|
# encode_iv: Defaults to true.
|
60
60
|
|
@@ -29,9 +29,15 @@ class LegacyPerson < ActiveRecord::Base
|
|
29
29
|
attr_encrypted :email, :key => 'a secret key'
|
30
30
|
attr_encrypted :credentials, :key => Proc.new { |user| Encryptor.encrypt(:value => user.salt, :key => 'some private key', insecure_mode: true, algorithm: 'aes-256-cbc') }, :marshal => true
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
if ActiveRecord.respond_to?(:deprecator)
|
33
|
+
ActiveRecord.deprecator.silence do
|
34
|
+
def after_initialize; end
|
35
|
+
end
|
36
|
+
else
|
37
|
+
ActiveSupport::Deprecation.silenced = true
|
38
|
+
def after_initialize; end
|
39
|
+
ActiveSupport::Deprecation.silenced = false
|
40
|
+
end
|
35
41
|
|
36
42
|
after_initialize :initialize_salt_and_credentials
|
37
43
|
|
data/test/test_helper.rb
CHANGED
@@ -16,17 +16,15 @@ SimpleCov.start do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
require 'minitest/autorun'
|
19
|
-
|
20
|
-
# Rails 4.0.x pins to an old minitest
|
21
|
-
unless defined?(MiniTest::Test)
|
22
|
-
MiniTest::Test = MiniTest::Unit::TestCase
|
23
|
-
end
|
24
|
-
|
25
19
|
require 'active_record'
|
26
|
-
require 'data_mapper'
|
27
20
|
require 'digest/sha2'
|
28
21
|
require 'sequel'
|
29
|
-
|
22
|
+
|
23
|
+
if ActiveRecord.respond_to?(:deprecator)
|
24
|
+
ActiveRecord.deprecator.behavior = :raise
|
25
|
+
else
|
26
|
+
ActiveSupport::Deprecation.behavior = :raise
|
27
|
+
end
|
30
28
|
|
31
29
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
32
30
|
$:.unshift(File.dirname(__FILE__))
|
metadata
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attr_encrypted
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Huber
|
8
8
|
- S. Brent Faulkner
|
9
9
|
- William Monk
|
10
10
|
- Stephen Aghaulor
|
11
|
-
|
11
|
+
- Josh Branham
|
12
|
+
- Mike Vastola
|
13
|
+
autorequire:
|
12
14
|
bindir: bin
|
13
15
|
cert_chain: []
|
14
|
-
date:
|
16
|
+
date: 2024-09-20 00:00:00.000000000 Z
|
15
17
|
dependencies:
|
16
18
|
- !ruby/object:Gem::Dependency
|
17
19
|
name: encryptor
|
@@ -55,20 +57,6 @@ dependencies:
|
|
55
57
|
- - ">="
|
56
58
|
- !ruby/object:Gem::Version
|
57
59
|
version: 2.0.0
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: datamapper
|
60
|
-
requirement: !ruby/object:Gem::Requirement
|
61
|
-
requirements:
|
62
|
-
- - ">="
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
version: '0'
|
65
|
-
type: :development
|
66
|
-
prerelease: false
|
67
|
-
version_requirements: !ruby/object:Gem::Requirement
|
68
|
-
requirements:
|
69
|
-
- - ">="
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version: '0'
|
72
60
|
- !ruby/object:Gem::Dependency
|
73
61
|
name: rake
|
74
62
|
requirement: !ruby/object:Gem::Requirement
|
@@ -187,12 +175,14 @@ email:
|
|
187
175
|
- sbfaulkner@gmail.com
|
188
176
|
- billy.monk@gmail.com
|
189
177
|
- saghaulor@gmail.com
|
178
|
+
- josh.php@gmail.com
|
179
|
+
- Mike@Vasto.la
|
190
180
|
executables: []
|
191
181
|
extensions: []
|
192
182
|
extra_rdoc_files: []
|
193
183
|
files:
|
184
|
+
- ".github/workflows/CI.yml"
|
194
185
|
- ".gitignore"
|
195
|
-
- ".travis.yml"
|
196
186
|
- CHANGELOG.md
|
197
187
|
- Gemfile
|
198
188
|
- MIT-LICENSE
|
@@ -211,17 +201,14 @@ files:
|
|
211
201
|
- checksum/attr_encrypted-3.1.0.gem.sha512
|
212
202
|
- lib/attr_encrypted.rb
|
213
203
|
- lib/attr_encrypted/adapters/active_record.rb
|
214
|
-
- lib/attr_encrypted/adapters/data_mapper.rb
|
215
204
|
- lib/attr_encrypted/adapters/sequel.rb
|
216
205
|
- lib/attr_encrypted/version.rb
|
217
206
|
- test/active_record_test.rb
|
218
207
|
- test/attr_encrypted_test.rb
|
219
208
|
- test/compatibility_test.rb
|
220
|
-
- test/data_mapper_test.rb
|
221
209
|
- test/legacy_active_record_test.rb
|
222
210
|
- test/legacy_attr_encrypted_test.rb
|
223
211
|
- test/legacy_compatibility_test.rb
|
224
|
-
- test/legacy_data_mapper_test.rb
|
225
212
|
- test/legacy_sequel_test.rb
|
226
213
|
- test/run.sh
|
227
214
|
- test/sequel_test.rb
|
@@ -252,20 +239,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
252
239
|
- !ruby/object:Gem::Version
|
253
240
|
version: '0'
|
254
241
|
requirements: []
|
255
|
-
rubygems_version: 3.
|
256
|
-
signing_key:
|
242
|
+
rubygems_version: 3.4.10
|
243
|
+
signing_key:
|
257
244
|
specification_version: 4
|
258
245
|
summary: Encrypt and decrypt attributes
|
259
246
|
test_files:
|
260
247
|
- test/active_record_test.rb
|
261
248
|
- test/attr_encrypted_test.rb
|
262
249
|
- test/compatibility_test.rb
|
263
|
-
- test/data_mapper_test.rb
|
264
250
|
- test/legacy_active_record_test.rb
|
265
251
|
- test/legacy_attr_encrypted_test.rb
|
266
252
|
- test/legacy_compatibility_test.rb
|
267
|
-
- test/legacy_data_mapper_test.rb
|
268
253
|
- test/legacy_sequel_test.rb
|
269
254
|
- test/run.sh
|
270
255
|
- test/sequel_test.rb
|
271
256
|
- test/test_helper.rb
|
257
|
+
...
|
data/.travis.yml
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
dist: focal
|
3
|
-
os: linux
|
4
|
-
cache: bundler
|
5
|
-
rvm:
|
6
|
-
- 2.6.10
|
7
|
-
- 2.7.6
|
8
|
-
env:
|
9
|
-
- ACTIVERECORD=5.1.1
|
10
|
-
- ACTIVERECORD=5.2.8
|
11
|
-
- ACTIVERECORD=6.0.6
|
12
|
-
- ACTIVERECORD=6.1.7
|
13
|
-
- ACTIVERECORD=7.0.4
|
14
|
-
jobs:
|
15
|
-
fast_finish: false
|
16
|
-
exclude:
|
17
|
-
- rvm: 2.6.10
|
18
|
-
env: ACTIVERECORD=7.0.4
|
19
|
-
|
20
|
-
addons:
|
21
|
-
code_climate:
|
22
|
-
repo_token: a90435ed4954dd6e9f3697a20c5bc3754f67d94703f870e8fc7b00f69f5b2d06
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
if defined?(DataMapper)
|
4
|
-
module AttrEncrypted
|
5
|
-
module Adapters
|
6
|
-
module DataMapper
|
7
|
-
def self.extended(base) # :nodoc:
|
8
|
-
class << base
|
9
|
-
alias_method :included_without_attr_encrypted, :included
|
10
|
-
alias_method :included, :included_with_attr_encrypted
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def included_with_attr_encrypted(base)
|
15
|
-
included_without_attr_encrypted(base)
|
16
|
-
base.extend AttrEncrypted
|
17
|
-
base.attr_encrypted_options[:encode] = true
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
DataMapper::Resource.extend AttrEncrypted::Adapters::DataMapper
|
24
|
-
end
|
data/test/data_mapper_test.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'test_helper'
|
4
|
-
|
5
|
-
DataMapper.setup(:default, 'sqlite3::memory:')
|
6
|
-
|
7
|
-
class Client
|
8
|
-
include DataMapper::Resource
|
9
|
-
|
10
|
-
property :id, Serial
|
11
|
-
property :encrypted_email, String
|
12
|
-
property :encrypted_email_iv, String
|
13
|
-
property :encrypted_email_salt, String
|
14
|
-
|
15
|
-
property :encrypted_credentials, Text
|
16
|
-
property :encrypted_credentials_iv, Text
|
17
|
-
property :encrypted_credentials_salt, Text
|
18
|
-
|
19
|
-
self.attr_encrypted_options[:mode] = :per_attribute_iv_and_salt
|
20
|
-
|
21
|
-
attr_encrypted :email, :key => SECRET_KEY
|
22
|
-
attr_encrypted :credentials, :key => SECRET_KEY, :marshal => true
|
23
|
-
|
24
|
-
def initialize(attrs = {})
|
25
|
-
super attrs
|
26
|
-
self.credentials ||= { :username => 'example', :password => 'test' }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
DataMapper.auto_migrate!
|
31
|
-
|
32
|
-
class DataMapperTest < Minitest::Test
|
33
|
-
|
34
|
-
def setup
|
35
|
-
Client.all.each(&:destroy)
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_should_encrypt_email
|
39
|
-
@client = Client.new :email => 'test@example.com'
|
40
|
-
assert @client.save
|
41
|
-
refute_nil @client.encrypted_email
|
42
|
-
refute_equal @client.email, @client.encrypted_email
|
43
|
-
assert_equal @client.email, Client.first.email
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_should_marshal_and_encrypt_credentials
|
47
|
-
@client = Client.new
|
48
|
-
assert @client.save
|
49
|
-
refute_nil @client.encrypted_credentials
|
50
|
-
refute_equal @client.credentials, @client.encrypted_credentials
|
51
|
-
assert_equal @client.credentials, Client.first.credentials
|
52
|
-
assert Client.first.credentials.is_a?(Hash)
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_should_encode_by_default
|
56
|
-
assert Client.attr_encrypted_options[:encode]
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'test_helper'
|
4
|
-
|
5
|
-
DataMapper.setup(:default, 'sqlite3::memory:')
|
6
|
-
|
7
|
-
class LegacyClient
|
8
|
-
include DataMapper::Resource
|
9
|
-
self.attr_encrypted_options[:insecure_mode] = true
|
10
|
-
self.attr_encrypted_options[:algorithm] = 'aes-256-cbc'
|
11
|
-
self.attr_encrypted_options[:mode] = :single_iv_and_salt
|
12
|
-
|
13
|
-
property :id, Serial
|
14
|
-
property :encrypted_email, String
|
15
|
-
property :encrypted_credentials, Text
|
16
|
-
property :salt, String
|
17
|
-
|
18
|
-
attr_encrypted :email, :key => 'a secret key', mode: :single_iv_and_salt
|
19
|
-
attr_encrypted :credentials, :key => Proc.new { |client| Encryptor.encrypt(:value => client.salt, :key => 'some private key', insecure_mode: true, algorithm: 'aes-256-cbc') }, :marshal => true, mode: :single_iv_and_salt
|
20
|
-
|
21
|
-
def initialize(attrs = {})
|
22
|
-
super attrs
|
23
|
-
self.salt ||= Digest::SHA1.hexdigest((Time.now.to_i * rand(5)).to_s)
|
24
|
-
self.credentials ||= { :username => 'example', :password => 'test' }
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
DataMapper.auto_migrate!
|
29
|
-
|
30
|
-
class LegacyDataMapperTest < Minitest::Test
|
31
|
-
|
32
|
-
def setup
|
33
|
-
LegacyClient.all.each(&:destroy)
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_should_encrypt_email
|
37
|
-
@client = LegacyClient.new :email => 'test@example.com'
|
38
|
-
assert @client.save
|
39
|
-
refute_nil @client.encrypted_email
|
40
|
-
refute_equal @client.email, @client.encrypted_email
|
41
|
-
assert_equal @client.email, LegacyClient.first.email
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_should_marshal_and_encrypt_credentials
|
45
|
-
@client = LegacyClient.new
|
46
|
-
assert @client.save
|
47
|
-
refute_nil @client.encrypted_credentials
|
48
|
-
refute_equal @client.credentials, @client.encrypted_credentials
|
49
|
-
assert_equal @client.credentials, LegacyClient.first.credentials
|
50
|
-
assert LegacyClient.first.credentials.is_a?(Hash)
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_should_encode_by_default
|
54
|
-
assert LegacyClient.attr_encrypted_options[:encode]
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|