Skip to content

Commit

Permalink
Merge pull request #5406 from AntonKhorev/offline-message-oauth
Browse files Browse the repository at this point in the history
Check if db is writable on oauth authorization pages
  • Loading branch information
gravitystorm authored Dec 17, 2024
2 parents 86fae89 + 5bb23f6 commit 8551db4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/oauth2_authorizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ class Oauth2AuthorizationsController < Doorkeeper::AuthorizationsController
allow_all_form_action :only => :new

authorize_resource :class => false

before_action :check_database_writable
end
14 changes: 14 additions & 0 deletions test/controllers/oauth2_authorizations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ def test_new_bad_scope
assert_select "p", "The requested scope is invalid, unknown, or malformed."
end

def test_new_db_readonly
application = create(:oauth_application, :scopes => "write_api")

session_for(create(:user))

with_settings(:status => "database_readonly") do
get oauth_authorization_path(:client_id => application.uid,
:redirect_uri => application.redirect_uri,
:response_type => "code",
:scope => "write_api")
assert_redirected_to offline_path
end
end

def test_create
application = create(:oauth_application, :scopes => "write_api")

Expand Down

0 comments on commit 8551db4

Please sign in to comment.