Sha256: 85ef3a7df9a1129fc5b76378abc6951622889260e3059339e4aa63bf3c2efb34
Contents?: true
Size: 1.98 KB
Versions: 2
Compression:
Stored size: 1.98 KB
Contents
require 'spec_helper' require 'securerandom' describe Keylime::Credential do let(:subject) { Keylime.new(service: 'testing') } let(:secret) { SecureRandom.hex } it 'accepts a keychain path' do credential = Keylime.new(keychain: 'other/file', service: 'testing') credential.set secret expect(credential.get.keychain).to eql 'other/file' end it 'can get internet passwords' do credential = Keylime.new(server: 'https://example.org', account: 'testing') credential.set secret expect(credential.get.password).to eql secret end it 'can get generic passwords' do subject.set secret expect(subject.get.password).to eql secret end describe '#get' do it 'returns a credential if it exists' do subject.set secret expect(subject.get.password).to eql secret end it 'returns nil if the credential does not exist' do expect(subject.get).to be_nil end end describe '#get!' do it 'returns a credential if it exists' do subject.set secret expect(subject.get.password).to eql secret end it 'prompts the user if the credential does not exist' do allow(STDIN).to receive(:gets) { "#{secret}\n" } expect do expect(subject.get!('Question').password).to eql secret end.to output("Question? \n").to_stdout end end describe '#set' do it 'sets the value of the credential' do subject.set secret expect(subject.get.password).to eql secret end it 'overwrites any existing credential' do subject.set 'oldvalue' expect(subject.get.password).to eql 'oldvalue' subject.set secret expect(subject.get.password).to eql secret end end describe '#delete!' do it 'removes the credential' do subject.set secret expect(subject.get.password).to eql secret subject.delete! expect(subject.get).to be_nil end it 'succeeds if credential does not exist' do subject.delete! expect(subject.get).to be_nil end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
keylime-0.0.2-x86_64-darwin-15 | spec/keylime/credential_spec.rb |
keylime-0.0.1-x86_64-darwin-15 | spec/keylime/credential_spec.rb |