Sha256: 4050d5d1b3a701b82a48e2ea0c6b9581c5a16cf1c244881e7320c7ef58a45be6

Contents?: true

Size: 1.35 KB

Versions: 10

Compression:

Stored size: 1.35 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

  it "refuses to authenticate a request with a missing cn" do
    response = subject.authenticate(cn: nil)
    expect(response).to_not be_authenticated
    expect(response.error).to eql "missing cn"
  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

10 entries across 10 versions & 1 rubygems

Version Path
certmeister-2.3.2 spec/certmeister/policy/existing_spec.rb
certmeister-2.3.1 spec/certmeister/policy/existing_spec.rb
certmeister-2.3.0 spec/certmeister/policy/existing_spec.rb
certmeister-2.2.0 spec/certmeister/policy/existing_spec.rb
certmeister-2.1.0 spec/certmeister/policy/existing_spec.rb
certmeister-2.0.0 spec/certmeister/policy/existing_spec.rb
certmeister-1.2.1 spec/certmeister/policy/existing_spec.rb
certmeister-1.2.0 spec/certmeister/policy/existing_spec.rb
certmeister-1.1.0 spec/certmeister/policy/existing_spec.rb
certmeister-1.0.1 spec/certmeister/policy/existing_spec.rb