Sha256: 938562112b766369f239ce924bda43a10b9b63a2d5581d8804c89b565cf33cc6
Contents?: true
Size: 1.61 KB
Versions: 3
Compression:
Stored size: 1.61 KB
Contents
require 'spec_helper' describe InlineEncryption::Config do describe 'check_required_values' do let(:subject){ InlineEncryption::Config.new } it "should raise if 'key' is not set" do expect{ subject.check_required_variables }.to raise_error(InlineEncryption::MissingRequiredVariableError) end it "should not raise if 'key' is set" do subject[:key] = 'foo' expect{ subject.check_required_variables }.not_to raise_error end end describe 'real_key' do let(:subject){ InlineEncryption::Config.new } it 'should return nil if key is NilClass' do subject[:key] = nil expect(subject.real_key).to be_nil end it 'should return the key value if key is an OpenSSL::PKey::RSA key' do key = OpenSSL::PKey::RSA.new(128) subject[:key] = key expect(subject.real_key).to eq(key) end it 'should return an OpenSSL::PKey::RSA key from the given String' do temp_key = OpenSSL::PKey::RSA.generate(32) key = temp_key.to_s subject[:key] = key expect(subject.real_key.to_s).to eq(temp_key.to_s) expect(subject.real_key).to be_an_instance_of OpenSSL::PKey::RSA end it 'should load the contents of the given file if exists and use as key' do temp_key = OpenSSL::PKey::RSA.generate(32) key = 'foo' subject[:key] = key allow(File).to receive(:exists?).with('foo').and_return(true) allow(File).to receive(:read).with('foo').and_return(temp_key.to_s) expect(subject.real_key.to_s).to eq(temp_key.to_s) expect(subject.real_key).to be_an_instance_of OpenSSL::PKey::RSA end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
inline_encryption-2.0.1 | spec/inline_encryption/config_spec.rb |
inline_encryption-2.0.0 | spec/inline_encryption/config_spec.rb |
inline_encryption-1.0.5 | spec/inline_encryption/config_spec.rb |