spec/rapid-vaults_spec.rb in rapid-vaults-1.0.0 vs spec/rapid-vaults_spec.rb in rapid-vaults-1.1.0

- old
+ new

@@ -1,32 +1,35 @@ require_relative 'spec_helper' require_relative '../lib/rapid-vaults' describe RapidVaults do - # let(:rapidvaults) { RapidVaults.new('fixtures/foo.yml', 'fixtures/key.txt', 'fixtures/nonce.txt', 'fixtures/tag.txt') } - context '.process' do - it 'raises an error for a non-string password' do - RapidVaults.instance_variable_set(:@settings, action: :encrypt, file: 'a', key: 'b', nonce: 'c', pw: 1) - expect { RapidVaults.process }.to raise_error('Password must be a string.') + it 'raises an error for a non-string password with openssl' do + expect { RapidVaults.process(algorithm: :openssl, action: :encrypt, file: 'a', key: 'b', nonce: 'c', pw: 1) }.to raise_error('Password must be a string.') end - it 'raises an error for a missing argument to encrypt' do - RapidVaults.instance_variable_set(:@settings, action: :encrypt, file: 'a', key: 'b') - expect { RapidVaults.process }.to raise_error('File, key, and nonce arguments are required for encryption.') + it 'raises an error for a missing argument to encrypt with openssl' do + expect { RapidVaults.process(algorithm: :openssl, action: :encrypt, file: 'a', key: 'b') }.to raise_error('File, key, and nonce arguments are required for encryption.') end - it 'raises an error for a missing argument to decrypt' do - RapidVaults.instance_variable_set(:@settings, action: :decrypt, file: 'a', key: 'b', nonce: 'c') - expect { RapidVaults.process }.to raise_error('File, key, nonce, and tag arguments are required for decryption.') + it 'raises an error for a missing argument to decrypt with openssl' do + expect { RapidVaults.process(algorithm: :openssl, action: :decrypt, file: 'a', key: 'b', nonce: 'c') }.to raise_error('File, key, nonce, and tag arguments are required for decryption.') end - it 'raises an error for a missing action' do - RapidVaults.instance_variable_set(:@settings, file: 'a', key: 'b', nonce: 'c', tag: 'd') - expect { RapidVaults.process }.to raise_error('Action must be one of generate, encrypt, or decrypt.') + it 'raises an error for a missing argument to decrypt with gpgme' do + expect { RapidVaults.process(algorithm: :gpgme, action: :decrypt, file: 'a') }.to raise_error('File and password arguments required for encryption or decryption.') end + it 'raises an error for a missing action with openssl' do + expect { RapidVaults.process(algorithm: :openssl, file: 'a', key: 'b', nonce: 'c', tag: 'd') }.to raise_error('Action must be one of generate, encrypt, or decrypt.') + end + it 'raises an error for a missing action with gpgme' do + expect { RapidVaults.process(algorithm: :gpgme, file: 'a', key: 'b') }.to raise_error('Action must be one of generate, encrypt, or decrypt.') + end + it 'raises an error for a missing argument to generate with gpgme' do + expect { RapidVaults.process(algorithm: :gpgme, action: :generate) }.to raise_error('GPG params file argument required for generation.') + end it 'raises an error for a nonexistent input file' do - RapidVaults.instance_variable_set(:@settings, action: :encrypt, file: 'a', key: 'b', nonce: 'c', tag: 'd') - expect { RapidVaults.process }.to raise_error('Input file is not an existing file.') + expect { RapidVaults.process(algorithm: :openssl, action: :encrypt, file: 'a', key: 'b', nonce: 'c', tag: 'd') }.to raise_error('Input file is not an existing file.') end it 'reads in all input files correctly for decryption' do - # + dummy = fixtures_dir + 'file.yaml' + expect { RapidVaults.process(algorithm: :openssl, action: :encrypt, file: dummy, key: dummy, nonce: dummy, pw: 'password') }.not_to raise_exception end end end