Sha256: 93c393e713a73b2c55d97e2fab707a26ad59d7c1c125ca4322f926b7cc7c734a

Contents?: true

Size: 1.4 KB

Versions: 35

Compression:

Stored size: 1.4 KB

Contents

module AuthorizationRequestHelper
  def resource_owner_is_authenticated(resource_owner = nil)
    resource_owner ||= User.create!(name: 'Joe', password: 'sekret')
    Doorkeeper.configuration.instance_variable_set(:@authenticate_resource_owner, proc { resource_owner })
  end

  def resource_owner_is_not_authenticated
    Doorkeeper.configuration.instance_variable_set(:@authenticate_resource_owner, proc { redirect_to('/sign_in') })
  end

  def default_scopes_exist(*scopes)
    Doorkeeper.configuration.instance_variable_set(:@default_scopes, Doorkeeper::OAuth::Scopes.from_array(scopes))
  end

  def optional_scopes_exist(*scopes)
    Doorkeeper.configuration.instance_variable_set(:@optional_scopes, Doorkeeper::OAuth::Scopes.from_array(scopes))
  end

  def client_should_be_authorized(client)
    expect(client.access_grants.size).to eq(1)
  end

  def client_should_not_be_authorized(client)
    expect(client.size).to eq(0)
  end

  def i_should_be_on_client_callback(client)
    expect(client.redirect_uri).to eq("#{current_uri.scheme}://#{current_uri.host}#{current_uri.path}")
  end

  def allowing_forgery_protection(&block)
    _original_value = ActionController::Base.allow_forgery_protection
    ActionController::Base.allow_forgery_protection = true

    block.call
  ensure
    ActionController::Base.allow_forgery_protection = _original_value
  end
end

RSpec.configuration.send :include, AuthorizationRequestHelper

Version data entries

35 entries across 35 versions & 3 rubygems

Version Path
doorkeeper-mongodb-4.2.0 spec/support/helpers/authorization_request_helper.rb
doorkeeper-sequel-1.5.0 spec/support/helpers/authorization_request_helper.rb
doorkeeper-4.4.3 spec/support/helpers/authorization_request_helper.rb
doorkeeper-4.4.2 spec/support/helpers/authorization_request_helper.rb
doorkeeper-4.4.1 spec/support/helpers/authorization_request_helper.rb
doorkeeper-4.4.0 spec/support/helpers/authorization_request_helper.rb
doorkeeper-mongodb-4.1.0 spec/support/helpers/authorization_request_helper.rb
doorkeeper-4.3.2 spec/support/helpers/authorization_request_helper.rb
doorkeeper-4.3.1 spec/support/helpers/authorization_request_helper.rb
doorkeeper-4.3.0 spec/support/helpers/authorization_request_helper.rb
doorkeeper-sequel-1.4.0 spec/support/helpers/authorization_request_helper.rb
doorkeeper-mongodb-4.0.1 spec/support/helpers/authorization_request_helper.rb
doorkeeper-mongodb-4.0.0 spec/support/helpers/authorization_request_helper.rb
doorkeeper-sequel-1.3.1 spec/support/helpers/authorization_request_helper.rb
doorkeeper-sequel-1.3.0 spec/support/helpers/authorization_request_helper.rb
doorkeeper-sequel-1.2.3 spec/support/helpers/authorization_request_helper.rb
doorkeeper-sequel-1.2.2 spec/support/helpers/authorization_request_helper.rb
doorkeeper-4.2.6 spec/support/helpers/authorization_request_helper.rb
doorkeeper-4.2.5 spec/support/helpers/authorization_request_helper.rb
doorkeeper-sequel-1.2.1 spec/support/helpers/authorization_request_helper.rb