Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if db is writable on oauth authorization pages #5406

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading