Sha256: 9eebd0b4c7d131ca49d2a85135be26a46cbf885fd4b03c014b2dea1cc8178837

Contents?: true

Size: 926 Bytes

Versions: 8

Compression:

Stored size: 926 Bytes

Contents

RSpec.describe Rails::Auth::X509::Matcher do
  let(:example_cert)        { OpenSSL::X509::Certificate.new(cert_path("valid.crt").read) }
  let(:example_certificate) { Rails::Auth::X509::Certificate.new(example_cert) }

  let(:example_ou) { "ponycopter" }
  let(:another_ou) { "somethingelse" }

  let(:example_env) do
    { Rails::Auth::Env::CREDENTIALS_ENV_KEY => { "x509" => example_certificate } }
  end

  describe "#match" do
    it "matches against a valid Rails::Auth::X509::Credential" do
      matcher = described_class.new(ou: example_ou)
      expect(matcher.match(example_env)).to eq true
    end

    it "doesn't match if the subject mismatches" do
      matcher = described_class.new(ou: another_ou)
      expect(matcher.match(example_env)).to eq false
    end
  end

  it "knows its attributes" do
    matcher = described_class.new(ou: example_ou)
    expect(matcher.attributes).to eq(ou: example_ou)
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rails-auth-2.1.4 spec/rails/auth/x509/matcher_spec.rb
rails-auth-2.1.3 spec/rails/auth/x509/matcher_spec.rb
rails-auth-2.1.2 spec/rails/auth/x509/matcher_spec.rb
rails-auth-2.1.1 spec/rails/auth/x509/matcher_spec.rb
rails-auth-2.1.0 spec/rails/auth/x509/matcher_spec.rb
rails-auth-2.0.3 spec/rails/auth/x509/matcher_spec.rb
rails-auth-2.0.2 spec/rails/auth/x509/matcher_spec.rb
rails-auth-2.0.1 spec/rails/auth/x509/matcher_spec.rb