:redirect_uri => application.redirect_uri,
:response_type => "code",
:scope => "write_api")
- assert_response :redirect
assert_redirected_to login_path(:referer => oauth_authorization_path(:client_id => application.uid,
:redirect_uri => application.redirect_uri,
:response_type => "code",
:redirect_uri => application.redirect_uri,
:response_type => "code",
:scope => "write_api")
- assert_response :redirect
assert_redirected_to login_path(:referer => oauth_authorization_path(:client_id => application.uid,
:redirect_uri => application.redirect_uri,
:response_type => "code",
:redirect_uri => "https://bad.example.com/",
:response_type => "code",
:scope => "write_api")
- assert_response :success
+ assert_response :bad_request
assert_template "oauth2_authorizations/error"
assert_select "p", "The requested redirect uri is malformed or doesn't match client redirect URI."
end
:redirect_uri => application.redirect_uri,
:response_type => "code",
:scope => "bad_scope")
- assert_response :success
+ assert_response :bad_request
assert_template "oauth2_authorizations/error"
assert_select "p", "The requested scope is invalid, unknown, or malformed."
:redirect_uri => application.redirect_uri,
:response_type => "code",
:scope => "write_prefs")
- assert_response :success
+ assert_response :bad_request
assert_template "oauth2_authorizations/error"
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")
:redirect_uri => application.redirect_uri,
:response_type => "code",
:scope => "write_api")
- assert_response :redirect
assert_redirected_to(/^#{Regexp.escape(application.redirect_uri)}\?code=/)
end
:redirect_uri => application.redirect_uri,
:response_type => "code",
:scope => "write_api")
- assert_response :redirect
assert_redirected_to(/^#{Regexp.escape(application.redirect_uri)}\?error=access_denied/)
end