Remove new lines

This commit is contained in:
Jorge Manrubia 2021-03-11 00:13:00 +01:00
parent 4e1f66f90b
commit 1406ac294f
59 changed files with 136 additions and 31 deletions

View File

@ -46,4 +46,3 @@ class ActionText::ModelEncryptionTest < ActiveSupport::TestCase
assert_equal expected_value, model.reload.send(attribute_name).body.to_html
end
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "active_support/core_ext/module"
require "active_support/core_ext/array"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# The algorithm used for encrypting and decrypting +Message+ objects.

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "openssl"
require "base64"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# Container of contfiguration options

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# Configuration API for +ActiveRecord::Encryption+

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# An encryption context configures the different entities used to perform encryption:

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# +ActiveRecord::Encryption+ uses encryption contexts to configure the different entities used to
@ -67,4 +69,4 @@ module ActiveRecord
end
end
end
end
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# A +KeyProvider+ that derives keys from passwords

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# This is the concern mixed in Active Record models to make them encryptable. It adds the +encrypts+

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# An +ActiveModel::Type+ that encrypts/decrypts strings of text
@ -107,7 +109,7 @@ module ActiveRecord
end
def clean_text_type
@clean_text_type ||= ActiveRecord::Encryption::EncryptedAttributeType.new(downcase: downcase, encryptor: ActiveRecord::Encryption::NullEncryptor.new )
@clean_text_type ||= ActiveRecord::Encryption::EncryptedAttributeType.new(downcase: downcase, encryptor: ActiveRecord::Encryption::NullEncryptor.new)
end
end
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# Encrypts encryptable columns when loading fixtures automatically

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# An encryptor that can encrypt data but can't decrypt it

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "openssl"
require "zip"
require "active_support/core_ext/numeric"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# Implements a simple envelope encryption approach where:

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
module Errors

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Automatically expand encrypted arguments to support querying both encrypted and unencrypted data
#
# Active Record Encryption supports querying the db using deterministic attributes. For example:
@ -54,17 +56,17 @@ module ActiveRecord
return value if check_for_additional_values && value.is_a?(Array) && value.last.is_a?(AdditionalValue)
case value
when String, Array
list = Array(value)
list + list.flat_map do |each_value|
if check_for_additional_values && each_value.is_a?(AdditionalValue)
each_value
else
additional_values_for(each_value, type)
end
when String, Array
list = Array(value)
list + list.flat_map do |each_value|
if check_for_additional_values && each_value.is_a?(AdditionalValue)
each_value
else
additional_values_for(each_value, type)
end
else
value
end
else
value
end
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# A key is a container for a given +secret+

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "securerandom"
module ActiveRecord

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# A +KeyProvider+ serves keys:

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# Encrypts all the models belonging to the provided list of classes

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# A message defines the structure of the data we store in encrypted attributes. It contains:

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# A message serializer that serializes +Messages+ with JSON.
@ -51,9 +53,9 @@ module ActiveRecord
end
def headers_to_json(headers)
headers.collect do |key, value|
[key, value.is_a?(ActiveRecord::Encryption::Message) ? message_to_json(value) : encode_if_needed(value)]
end.to_h
headers.transform_values do |value|
value.is_a?(ActiveRecord::Encryption::Message) ? message_to_json(value) : encode_if_needed(value)
end
end
def encode_if_needed(value)
@ -75,4 +77,4 @@ module ActiveRecord
end
end
end
end
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# An encryptor that won't decrypt or encrypt. It will just return the passed

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# This is a wrapper for a hash of encryption properties. It is used by

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActiveRecord
module Encryption
# A +NullEncryptor+ that will raise an error when trying to encrypt data

View File

@ -555,7 +555,7 @@ db_namespace = namespace :db do
desc "Generate a set of keys for configuring Active Record encryption in a given environment"
task :init do
puts <<~MSG
Add this entry to the credentials of the target environment:
Add this entry to the credentials of the target environment:#{' '}
active_record_encryption:
master_key: #{SecureRandom.alphanumeric(32)}

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
class ActiveRecord::Encryption::Aes256GcmTest < ActiveSupport::TestCase

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
class ActiveRecord::Encryption::CipherTest < ActiveSupport::TestCase

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
require "models/post"

View File

@ -1,8 +1,10 @@
# frozen_string_literal: true
require "cases/encryption/helper"
require "models/book"
class ActiveRecord::Encryption::ConfigurableTest < ActiveRecord::TestCase
test 'can access context properties with top level getters' do
test "can access context properties with top level getters" do
assert_equal ActiveRecord::Encryption.key_provider, ActiveRecord::Encryption.context.key_provider
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
require "models/book"
require "models/post"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
class ActiveRecord::Encryption::DerivedSecretKeyProviderTest < ActiveRecord::TestCase

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
require "models/author"
require "models/book"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
require "models/author"
require "models/book"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
require "models/book"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
class ActiveRecord::Encryption::EncryptingOnlyEncryptorTest < ActiveSupport::TestCase

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
require "models/author"
@ -45,7 +47,7 @@ class ActiveRecord::Encryption::EncryptionSchemesTest < ActiveRecord::TestCase
end
def decrypt(encrypted_text, key_provider: nil, cipher_options: {})
@ciphertexts_by_clear_value.each{ |clear_value, encrypted_value| return clear_value if encrypted_value == encrypted_text }
@ciphertexts_by_clear_value.each { |clear_value, encrypted_value| return clear_value if encrypted_value == encrypted_text }
raise ActiveRecord::Encryption::Errors::Decryption, "Couldn't find a match for #{encrypted_text} (#{@ciphertexts_by_clear_value.inspect})"
end
@ -57,7 +59,7 @@ class ActiveRecord::Encryption::EncryptionSchemesTest < ActiveRecord::TestCase
class EncryptedAuthor1 < Author
self.table_name = "authors"
encrypts :name, encryptor: TestEncryptor.new( "1" => "2" )
encrypts :name, encryptor: TestEncryptor.new("1" => "2")
end
class EncryptedAuthor2 < Author
@ -75,6 +77,4 @@ class ActiveRecord::Encryption::EncryptionSchemesTest < ActiveRecord::TestCase
end
author
end
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
class ActiveRecord::Encryption::EncryptorTest < ActiveSupport::TestCase

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
class ActiveRecord::Encryption::EnvelopeEncryptionKeyProviderTest < ActiveRecord::TestCase

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
require "models/book"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/helper"
require "benchmark/ips"
@ -132,7 +134,7 @@ end
class ActiveRecord::TestCase
include ActiveRecord::Encryption::EncryptionHelpers, ActiveRecord::Encryption::PerformanceHelpers
#, PerformanceHelpers
# , PerformanceHelpers
ENCRYPTION_ERROR_FLAGS = %i[ master_key store_key_references key_derivation_salt support_unencrypted_data
encrypt_fixtures ]
@ -149,4 +151,4 @@ class ActiveRecord::TestCase
ActiveRecord::Encryption.config.public_send("#{property}=", instance_variable_get("@_original_#{property}"))
end
end
end
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
class ActiveRecord::Encryption::KeyGeneratorTest < ActiveSupport::TestCase

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
class ActiveRecord::Encryption::KeyProviderTest < ActiveRecord::TestCase

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
class ActiveRecord::Encryption::KeyTest < ActiveSupport::TestCase

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
require "models/author"
require "models/post"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
class ActiveRecord::Encryption::MessageSerializerTest < ActiveSupport::TestCase
@ -52,4 +54,4 @@ class ActiveRecord::Encryption::MessageSerializerTest < ActiveSupport::TestCase
def serialize_and_deserialize(message, with: @serializer)
@serializer.load @serializer.dump(message)
end
end
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
class ActiveRecord::Encryption::MessageTest < ActiveSupport::TestCase

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
class ActiveRecord::Encryption::NullEncryptorTest < ActiveSupport::TestCase

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
require "models/book"
require "models/post"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
require "models/book"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
require "models/book"
@ -7,7 +9,7 @@ class ActiveRecord::Encryption::ExtendedDeterministicQueriesPerformanceTest < Ac
baseline = -> { EncryptedBook.find_by(format: "paperback") } # not encrypted
# Performance is similar with SQL adapter
assert_slower_by_at_most 1.6 , baseline: baseline, duration: 2 do
assert_slower_by_at_most 1.6, baseline: baseline, duration: 2 do
EncryptedBook.find_by(name: "Agile Web Development with Rails") # encrypted, deterministic
end
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
class ActiveRecord::Encryption::StoragePerformanceTest < ActiveRecord::TestCase
@ -62,4 +64,4 @@ class ActiveRecord::Encryption::StoragePerformanceTest < ActiveRecord::TestCase
def cipher
@cipher ||= ActiveRecord::Encryption::Cipher.new
end
end
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
class ActiveRecord::EncryptionPropertiesTest < ActiveSupport::TestCase

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
class ActiveRecord::Encryption::ReadOnlyNullEncryptorTest < ActiveSupport::TestCase

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "cases/encryption/helper"
require "models/post"

View File

@ -230,4 +230,4 @@ ActiveRecord::Encryption.configure \
deterministic_key: "test deterministic key",
key_derivation_salt: "testing key derivation salt"
ActiveRecord::Encryption::ExtendedDeterministicQueries.install_support
ActiveRecord::Encryption::ExtendedDeterministicQueries.install_support

View File

@ -388,4 +388,4 @@ class EncryptedPost < Post
encrypts :title
encrypts :body, key_provider: MutableDerivedSecretKeyProvider.new("my post body secret!")
end
end

View File

@ -7,4 +7,4 @@ end
class EncryptedTrafficLight < TrafficLight
encrypts :state
end
end