Sha256: 63968e8b5135d038a0615533be96c6fbc48eccb0ff0b799e967f24e651e2f125

Contents?: true

Size: 1.15 KB

Versions: 12

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

require 'certmeister/policy/existing'
require 'certmeister/in_memory_store'

describe Certmeister::Policy::Existing do

  subject { Certmeister::Policy::Existing.new(Certmeister::InMemoryStore.new) }

  it "must be configured with access to the store" do
    expect { subject.class.new }.to raise_error(ArgumentError)
    expect { subject.class.new(Object.new) }.to raise_error(ArgumentError)
    expect { subject }.to_not raise_error
  end

  it "demands a request" do
    expect { subject.authenticate }.to raise_error(ArgumentError)
  end

  context "when the store contains a cert for axl.hetzner.africa" do

    subject { Certmeister::Policy::Existing.new(Certmeister::InMemoryStore.new({"axl.hetzner.africa" => "...cert..."})) }

    it "refuses to authenticate a request for axl.hetzner.africa" do
      response = subject.authenticate(cn: 'axl.hetzner.africa')
      expect(response).to_not be_authenticated
      expect(response.error).to match /exists/
    end

    it "authenticates requests for other common names" do
      response = subject.authenticate(cn: 'bob.example.com')
      expect(response).to be_authenticated
    end

  end



end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
certmeister-1.0.0 spec/certmeister/policy/existing_spec.rb
certmeister-0.4.1 spec/certmeister/policy/existing_spec.rb
certmeister-0.4.0 spec/certmeister/policy/existing_spec.rb
certmeister-0.3.2 spec/certmeister/policy/existing_spec.rb
certmeister-0.3.1 spec/certmeister/policy/existing_spec.rb
certmeister-0.3.0 spec/certmeister/policy/existing_spec.rb
certmeister-0.2.3 spec/certmeister/policy/existing_spec.rb
certmeister-0.2.1 spec/certmeister/policy/existing_spec.rb
certmeister-0.2.0 spec/certmeister/policy/existing_spec.rb
certmeister-0.1.0 spec/certmeister/policy/existing_spec.rb
certmeister-0.0.2 spec/certmeister/policy/existing_spec.rb
certmeister-0.0.1 spec/certmeister/policy/existing_spec.rb