Commit 37415b2
Changed files (3)
lib
spec
lib/tfa/cli.rb
@@ -117,12 +117,11 @@ module TFA
end
def ensure_upgraded!
- unless upgraded?
- say_status :error, "Use the `upgrade` command to upgrade your database.", :red
- false
- else
- true
- end
+ return true if upgraded?
+
+ error = "Use the `upgrade` command to upgrade your database."
+ say_status :error, error, :red
+ false
end
def upgraded?
lib/tfa/secure_storage.rb
@@ -25,7 +25,8 @@ module TFA
decipher.decrypt
decipher.key = digest
decipher.iv = Base64.decode64(data[:iv])
- IO.write(@original.path, decipher.update(Base64.decode64(data[:cipher_text])) + decipher.final)
+ plain_text = decipher.update(Base64.decode64(data[:cipher_text]))
+ IO.write(@original.path, plain_text + decipher.final)
end
def encrypted?
spec/lib/secure_storage_spec.rb
@@ -1,7 +1,7 @@
module TFA
describe SecureStorage do
subject { described_class.new(original, passphrase) }
- let(:original) { Tempfile.new('tfa') }
+ let(:original) { Tempfile.new("tfa") }
let(:passphrase) { -> { SecureRandom.uuid } }
after { original.unlink }
@@ -9,7 +9,7 @@ module TFA
describe "decrypt!" do
let(:message) { JSON.generate(secret: SecureRandom.uuid) }
- it 'decrypts an encrypted file' do
+ it "decrypts an encrypted file" do
IO.write(original.path, message)
subject.encrypt!
subject.decrypt!
@@ -20,7 +20,7 @@ module TFA
describe "encrypt!" do
let(:message) { JSON.generate(secret: SecureRandom.uuid) }
- it 'encrypts a file' do
+ it "encrypts a file" do
IO.write(original.path, message)
subject.encrypt!
expect(IO.read(original.path)).to_not eql(message)