Commit dbe80b3
Changed files (2)
spec
spec/lib/secure_proxy_spec.rb
@@ -0,0 +1,30 @@
+module TFA
+ describe SecureProxy do
+ subject { described_class.new(original, passphrase) }
+ let(:original) { Tempfile.new('tfa') }
+ let(:passphrase) { SecureRandom.uuid }
+
+ after { original.unlink }
+
+ describe "decrypt!" do
+ let(:message) { JSON.generate(secret: SecureRandom.uuid) }
+
+ it 'decrypts an encrypted file' do
+ IO.write(original.path, message)
+ subject.encrypt!
+ subject.decrypt!
+ expect(IO.read(original.path)).to eql(message)
+ end
+ end
+
+ describe "encrypt!" do
+ let(:message) { JSON.generate(secret: SecureRandom.uuid) }
+
+ it 'encrypts a file' do
+ IO.write(original.path, message)
+ subject.encrypt!
+ expect(IO.read(original.path)).to_not eql(message)
+ end
+ end
+ end
+end
spec/spec_helper.rb
@@ -18,6 +18,7 @@ require 'tfa'
require 'securerandom'
require 'tempfile'
require 'tmpdir'
+require 'json'
RSpec.configure do |config|
# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.