Sha256: 4679dfc5b41b663259215e1e95f91c39e9b19dd906b066a312f47399f14f302c

Contents?: true

Size: 1.01 KB

Versions: 19

Compression:

Stored size: 1.01 KB

Contents

RSpec.describe Rails::Auth::ErrorPage::DebugMiddleware do
  let(:request) { Rack::MockRequest.env_for("https://www.example.com") }

  let(:example_config) { fixture_path("example_acl.yml").read }

  let(:example_acl) do
    Rails::Auth::ACL.from_yaml(
      example_config,
      matchers: {
        allow_x509_subject: Rails::Auth::X509::Matcher,
        allow_claims:       ClaimsMatcher
      }
    )
  end

  subject(:middleware) { described_class.new(app, acl: example_acl) }

  context "access granted" do
    let(:code) { 200 }
    let(:app)  { ->(env) { [code, env, "Hello, world!"] } }

    it "renders the expected response" do
      response = middleware.call(request)
      expect(response.first).to eq code
    end
  end

  context "access denied" do
    let(:app) { ->(_env) { raise(Rails::Auth::NotAuthorizedError, "not authorized!") } }

    it "renders the error page" do
      code, _env, body = middleware.call(request)
      expect(code).to eq 403
      expect(body.join).to include("Access Denied")
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rails-auth-2.1.4 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-2.1.3 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-2.1.2 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-2.1.1 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-2.1.0 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-2.0.3 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-2.0.2 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-2.0.1 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-1.3.0 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-1.2.0 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-1.1.0 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-1.0.0 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-0.5.3 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-0.5.2 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-0.5.1 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-0.5.0 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-0.4.1 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-0.4.0 spec/rails/auth/error_page/debug_middleware_spec.rb
rails-auth-0.3.0 spec/rails/auth/error_page/debug_middleware_spec.rb