Commit e6cc5f2a authored by DJ Mountney's avatar DJ Mountney

Apply 6 suggestion(s) to 2 file(s)

parent add38cc7
...@@ -41,7 +41,7 @@ module Gitlab ...@@ -41,7 +41,7 @@ module Gitlab
def read def read
if active? if active?
decrypt content_path.binread decrypt(content_path.binread)
else else
"" ""
end end
...@@ -55,7 +55,7 @@ module Gitlab ...@@ -55,7 +55,7 @@ module Gitlab
File.open(temp_file.path, 'wb') do |file| File.open(temp_file.path, 'wb') do |file|
file.write(encrypt(contents)) file.write(encrypt(contents))
end end
FileUtils.mv temp_file.path, content_path FileUtils.mv(temp_file.path, content_path)
ensure ensure
temp_file&.unlink temp_file&.unlink
end end
...@@ -71,7 +71,7 @@ module Gitlab ...@@ -71,7 +71,7 @@ module Gitlab
end end
def change(&block) def change(&block)
writing read, &block writing(read, &block)
end end
private private
...@@ -84,12 +84,12 @@ module Gitlab ...@@ -84,12 +84,12 @@ module Gitlab
def encrypt(contents) def encrypt(contents)
handle_missing_key! handle_missing_key!
encryptor.encrypt_and_sign contents encryptor.encrypt_and_sign(contents)
end end
def decrypt(contents) def decrypt(contents)
handle_missing_key! handle_missing_key!
encryptor.decrypt_and_verify contents encryptor.decrypt_and_verify(contents)
end end
def encryptor def encryptor
......
...@@ -79,7 +79,7 @@ RSpec.describe Gitlab::EncryptedConfiguration do ...@@ -79,7 +79,7 @@ RSpec.describe Gitlab::EncryptedConfiguration do
expect(config.foo[:bar]).to be true expect(config.foo[:bar]).to be true
end end
it 'throws a custom error when deferencing an invalid key map config' do it 'throws a custom error when referencing an invalid key map config' do
config = described_class.new(content_path: credentials_config_path, base_key: credentials_key) config = described_class.new(content_path: credentials_config_path, base_key: credentials_key)
config.write("stringcontent") config.write("stringcontent")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment