Skip to content

Commit

Permalink
New test to cover not allowed to authenticate application
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Guo committed Jan 6, 2024
1 parent a7e0d3e commit 49d0b05
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions test/controllers/doorkeeper_authorizations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,18 @@ def setup
assert_response :redirect
assert_includes response.headers['location'], 'error=access_denied'
end

test 'should raise error if user is not allowed to authenticate application' do
disallowed_user = users(:user_shin)
disallowed_application = oauth_applications(:oauth_app_yxt_oauth2)

sign_in disallowed_user

assert_raises(Doorkeeper::Errors::DoorkeeperError) do
get oauth_authorization_url, params: { client_id: disallowed_application.uid,
redirect_uri: disallowed_application.redirect_uri,
response_type: 'code',
scope: 'public' }
end
end
end
2 changes: 1 addition & 1 deletion test/fixtures/oauth_applications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ oauth_app_yxt_oauth2:
confidential: true
div_class: "primary"
icon: "fa-graduation-cap"
allow_login_by_default: true
allow_login_by_default: false
superapp: false
created_at: <%= Time.zone.now %>
updated_at: <%= Time.zone.now %>
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/user_allowed_applications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ user_demo_use_oauth_app_yxt_oauth2:
user_shin_use_oauth_app_yxt_oauth2:
user_id: 3 # user_shin
oauth_application_id: 4 # oauth_app_yxt_oauth2
enable: true
enable: false

0 comments on commit 49d0b05

Please sign in to comment.