Sha256: caae0d86d5f997d38343a3cae29a5017ee54103e02dc606d8d1eca65a07fe0fc

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

describe Passrock::PasswordDb do

  let(:password_db) { passrock_password_db }
  let(:private_key) { passrock_private_key }
  let(:init_opts) { {:password_db => password_db, :private_key => private_key} }
  let(:insecure_password) { 'password' }
  let(:secure_password) { 'BoatActKnowsDog' }

  describe '#secure?' do

    let(:subject) { described_class.new(init_opts) }

    context 'when given password is present in the password database' do
      it 'returns false' do
        expect(subject.secure?(insecure_password)).to be_false

        # sanity check other known insecure passwords
        [ 'inIUfiWO13', 'PVGWpkf81', 'cSAuOcUW58', 'XxPRBGF11', 'WjNYUmGj72', 'P0RQU33SM3N3ST3r' ].each do |password|
          expect(subject.secure?(password)).to be_false
        end
      end
    end

    context 'when given password does not appear in the password database' do
      it 'returns true' do
        expect(subject.secure?(secure_password)).to be_true
      end
    end

  end

  describe '#insecure?' do

    let(:subject) { described_class.new(init_opts) }

    context 'when given password is present in the password database' do
      it 'returns true' do
        expect(subject.insecure?(insecure_password)).to be_true
      end
    end

    context 'when given password does not appear in the password database' do
      it 'returns false' do
        expect(subject.insecure?(secure_password)).to be_false
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
passrock-0.0.8 spec/passrock/password_db_spec.rb