Skip to content

Commit

Permalink
Adds integrations tests
Browse files Browse the repository at this point in the history
Thanks for your work, Grzesiek Kolodziejczyk (@grk).
  • Loading branch information
tute committed Mar 1, 2015
1 parent 03008f5 commit 6235219
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
14 changes: 14 additions & 0 deletions spec/requests/flows/authorization_code_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,19 @@

should_have_json 'access_token', Doorkeeper::AccessToken.last.token
end

scenario 'resource owner authorizes the client with extra scopes' do
client_is_authorized(@client, @resource_owner, scopes: 'public')
visit authorization_endpoint_url(client: @client, scope: 'public write')
click_on 'Authorize'

authorization_code = Doorkeeper::AccessGrant.first.token
post token_endpoint_url(code: authorization_code, client: @client)

expect(Doorkeeper::AccessToken.count).to be(2)

should_have_json 'access_token', Doorkeeper::AccessToken.last.token
access_token_should_have_scopes :public, :write
end
end
end
13 changes: 13 additions & 0 deletions spec/requests/flows/skip_authorization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,18 @@
click_on 'Authorize'
access_grant_should_have_scopes :public
end

scenario 'doesn not skip authorization when scopes are greater' do
client_is_authorized(@client, @resource_owner, scopes: 'public')
visit authorization_endpoint_url(client: @client, scope: 'public write')
i_should_see 'Authorize'
end

scenario 'creates grant with new scope when scopes are greater' do
client_is_authorized(@client, @resource_owner, scopes: 'public')
visit authorization_endpoint_url(client: @client, scope: 'public write')
click_on 'Authorize'
access_grant_should_have_scopes :public, :write
end
end
end
2 changes: 1 addition & 1 deletion spec/support/helpers/model_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def access_grant_should_have_scopes(*args)
end

def access_token_should_have_scopes(*args)
grant = Doorkeeper::AccessToken.first
grant = Doorkeeper::AccessToken.last
expect(grant.scopes).to eq(Doorkeeper::OAuth::Scopes.from_array(args))
end
end
Expand Down

0 comments on commit 6235219

Please sign in to comment.