-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace attr_encrypted gem with lockbox
- Loading branch information
1 parent
fb102a1
commit cd8259b
Showing
10 changed files
with
46 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'lockbox' | ||
require 'keypairs/engine' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec::Matchers.define :encrypt_attribute do |attribute| | ||
database_column_name = "#{attribute}_ciphertext" | ||
|
||
match do |model| | ||
# Correct responds to methods | ||
model.respond_to?(attribute) && | ||
model.respond_to?("#{attribute}=") && | ||
model.respond_to?(database_column_name) && | ||
model.respond_to?("#{database_column_name}=") && | ||
# Correct database columns | ||
model.class.column_names.exclude?(attribute.to_s) && | ||
model.class.column_names.include?(database_column_name) | ||
end | ||
|
||
failure_message do |model| | ||
if model.class.column_names.include?(database_column_name) | ||
"#{attribute} should use lockbox encrypts on #{model.class}" | ||
else | ||
"#{database_column_name} must be a column on #{model.class} for encryption to work" | ||
end | ||
end | ||
|
||
failure_message_when_negated do |model| | ||
if model.class.column_names.include?(database_column_name) | ||
"#{attribute} should not use lockbox encrypts on #{model.class}" | ||
else | ||
"#{database_column_name} shouldn't be a column on #{model.class}" | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.