Sha256: e7d6d1a8dc0b2c24d4751c8f3f50040d8f68ebdd1cccee3c69052e47c4704fac

Contents?: true

Size: 1.45 KB

Versions: 5

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper_integration'

feature 'Implicit Grant Flow' do
  background do
    config_is_set(:authenticate_resource_owner) { User.first || redirect_to('/sign_in') }
    client_exists
    create_resource_owner
    sign_in
  end

  scenario 'resource owner authorizes the client' do
    visit authorization_endpoint_url(client: @client, response_type: 'token')
    click_on 'Authorize'

    access_token_should_exist_for @client, @resource_owner

    i_should_be_on_client_callback @client
  end

  context 'token reuse' do
    scenario 'should return a new token each request' do
      Doorkeeper.configuration.stub(:reuse_access_token).and_return(false)

      token = client_is_authorized(@client, @resource_owner)

      post "/oauth/authorize",
           client_id: @client.uid,
           state: '',
           redirect_uri: @client.redirect_uri,
           response_type: 'token',
           commit: 'Authorize'

      expect(response.location).not_to include(token.token)
    end

    scenario 'should return the same token if it is still accessible' do
      Doorkeeper.configuration.stub(:reuse_access_token).and_return(true)

      token = client_is_authorized(@client, @resource_owner)

      post "/oauth/authorize",
           client_id: @client.uid,
           state: '',
           redirect_uri: @client.redirect_uri,
           response_type: 'token',
           commit: 'Authorize'

      expect(response.location).to include(token.token)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
doorkeeper-2.0.1 spec/requests/flows/implicit_grant_spec.rb
doorkeeper-2.0.0 spec/requests/flows/implicit_grant_spec.rb
doorkeeper-2.0.0.rc3 spec/requests/flows/implicit_grant_spec.rb
doorkeeper-2.0.0.rc2 spec/requests/flows/implicit_grant_spec.rb
doorkeeper-2.0.0.alpha1 spec/requests/flows/implicit_grant_spec.rb