Sha256: 65fbcbf2cb3c5960a821fa21a74e15af89f9099ca3e796e528f3005a1f2bf433

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'
require 'seraph/authenticator'
require 'seraph/password_encryptor'

RSpec.describe Seraph::Authenticator do
  describe '.call' do
    let(:plaintext) { 'foobar12' }
    let(:encrypted) { Seraph::PasswordEncryptor.call(plaintext).to_s }
    subject(:authenticated) { described_class.call(encrypted, provided) }

    context 'when the provided password is the same as the encrypted one' do
      let(:provided) { plaintext }
      it { is_expected.to be_truthy }
    end

    context 'when the provided password is different than the encrypted one' do
      let(:provided) { 'wrongpassword' }
      it { is_expected.to be_falsey }
    end

    context 'when pepper is set' do
      include_context 'pepper set in configuration'

      context 'when the provided password is the same as the encrypted one' do
        let(:provided) { plaintext }
        it { is_expected.to be_truthy }
      end

      context 'when the provided password is different than the encrypted one' do
        let(:provided) { 'wrongpassword' }
        it { is_expected.to be_falsey }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
seraph-0.0.5 spec/seraph/authenticator_spec.rb