Sha256: 0400bd1702e27fe37f85f358df8efc99fc1eb481f96048839e9cc8d31b78108f

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

RSpec.describe "RSpec ACL matchers", acl_spec: true do
  let(:another_certificate) { x509_certificate_hash(ou: "derpderp") }
  let(:example_certificate) { x509_certificate_hash(ou: "ponycopter") }

  subject do
    Rails::Auth::ACL.from_yaml(
      fixture_path("example_acl.yml").read,
      matchers: {
        allow_x509_subject: Rails::Auth::X509::Matcher,
        allow_claims:       ClaimsMatcher
      }
    )
  end

  describe "/baz/quux" do
    it { is_expected.to permit get_request(credentials: example_certificate) }
    it { is_expected.not_to permit get_request(credentials: another_certificate) }
    it { is_expected.not_to permit get_request }

    it "has the correct description" do
      expect(permit(get_request(credentials: example_certificate)).description)
        .to eq('allow GETs by #<InstanceDouble(Rails::Auth::X509::Certificate) "OU=ponycopter">')
      expect(permit(get_request(credentials: another_certificate)).description)
        .to eq('allow GETs by #<InstanceDouble(Rails::Auth::X509::Certificate) "OU=derpderp">')
      expect(permit(get_request).description)
        .to eq("allow GETs by unauthenticated clients")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails-auth-3.2.0 spec/rails/auth/rspec/matchers/acl_matchers_spec.rb
rails-auth-3.1.0 spec/rails/auth/rspec/matchers/acl_matchers_spec.rb
rails-auth-3.0.0 spec/rails/auth/rspec/matchers/acl_matchers_spec.rb
rails-auth-2.2.2 spec/rails/auth/rspec/matchers/acl_matchers_spec.rb
rails-auth-2.2.1 spec/rails/auth/rspec/matchers/acl_matchers_spec.rb