Sha256: 3157fbf522bc98babbba749fef7055ab3c2728dd530e5a7521101c792949a228

Contents?: true

Size: 1.2 KB

Versions: 11

Compression:

Stored size: 1.2 KB

Contents

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

  let(:example_cn) { "127.0.0.1" }
  let(:example_ou) { "ponycopter" }

  describe "#[]" do
    it "allows access to subject components via strings" do
      expect(example_certificate["CN"]).to eq example_cn
      expect(example_certificate["OU"]).to eq example_ou
    end

    it "allows access to subject components via symbols" do
      expect(example_certificate[:cn]).to eq example_cn
      expect(example_certificate[:ou]).to eq example_ou
    end
  end

  it "knows its #cn" do
    expect(example_certificate.cn).to eq example_cn
  end

  it "knows its #ou" do
    expect(example_certificate.ou).to eq example_ou
  end

  it "knows its attributes" do
    expect(example_certificate.attributes).to eq(cn: example_cn, ou: example_ou)
  end

  it "compares certificate objects by comparing their certificates" do
    second_cert = OpenSSL::X509::Certificate.new(cert_path("valid.crt").read)
    second_certificate = described_class.new(second_cert)

    expect(example_certificate).to be_eql second_certificate
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rails-auth-2.1.4 spec/rails/auth/x509/certificate_spec.rb
rails-auth-2.1.3 spec/rails/auth/x509/certificate_spec.rb
rails-auth-2.1.2 spec/rails/auth/x509/certificate_spec.rb
rails-auth-2.1.1 spec/rails/auth/x509/certificate_spec.rb
rails-auth-2.1.0 spec/rails/auth/x509/certificate_spec.rb
rails-auth-2.0.3 spec/rails/auth/x509/certificate_spec.rb
rails-auth-2.0.2 spec/rails/auth/x509/certificate_spec.rb
rails-auth-2.0.1 spec/rails/auth/x509/certificate_spec.rb
rails-auth-1.3.0 spec/rails/auth/x509/certificate_spec.rb
rails-auth-1.2.0 spec/rails/auth/x509/certificate_spec.rb
rails-auth-1.1.0 spec/rails/auth/x509/certificate_spec.rb