Commit a8a65881 authored by John Mason's avatar John Mason Committed by Stan Hu

Alias user_email_lookup_limit to search_rate_limit

Changelog: changed
parent ed363ad1
......@@ -202,7 +202,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/29418')
end
def application_setting_params
def application_setting_params # rubocop:disable Metrics/AbcSize
params[:application_setting] ||= {}
if params[:application_setting].key?(:enabled_oauth_sign_in_sources)
......@@ -229,6 +229,10 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
params.delete(:domain_denylist_raw) if params[:domain_denylist]
params.delete(:domain_allowlist_raw) if params[:domain_allowlist]
if params[:application_setting].key?(:user_email_lookup_limit)
params[:application_setting][:search_rate_limit] ||= params[:application_setting][:user_email_lookup_limit]
end
params[:application_setting].permit(visible_application_setting_attributes)
end
......
......@@ -390,7 +390,7 @@ listed in the descriptions of the relevant settings.
| `push_event_hooks_limit` | integer | no | Number of changes (branches or tags) in a single push to determine whether webhooks and services fire or not. Webhooks and services aren't submitted if it surpasses that value. |
| `rate_limiting_response_text` | string | no | When rate limiting is enabled via the `throttle_*` settings, send this plain text response when a rate limit is exceeded. 'Retry later' is sent if this is blank. |
| `raw_blob_request_limit` | integer | no | Max number of requests per minute for each raw path. Default: 300. To disable throttling set to 0.|
| `user_email_lookup_limit` | integer | no | **{warning}** **[Removed](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/80631/)** in GitLab 14.9. Replaced by `search_rate_limit`. Max number of requests per minute for email lookup. Default: 60. To disable throttling set to 0.|
| `user_email_lookup_limit` | integer | no | **{warning}** **[Deprecated](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/80631/)** in GitLab 14.9 will be removed in 15.0. Replaced by `search_rate_limit`. Max number of requests per minute for email lookup. Default: 60. To disable throttling set to 0.|
| `search_rate_limit` | integer | no | Max number of requests per minute for performing a search while authenticated. Default: 30. To disable throttling set to 0.|
| `search_rate_limit_unauthenticated` | integer | no | Max number of requests per minute for performing a search while unauthenticated. Default: 10. To disable throttling set to 0.|
| `recaptcha_enabled` | boolean | no | (**If enabled, requires:** `recaptcha_private_key` and `recaptcha_site_key`) Enable reCAPTCHA. |
......
......@@ -291,6 +291,46 @@ RSpec.describe Admin::ApplicationSettingsController, :do_not_mock_admin_mode_set
end
end
end
describe 'user_email_lookup_limit aliasing' do
let(:application_setting) { ApplicationSetting.current }
let(:user_email_lookup_limit) { 8675 }
let(:search_rate_limit) { 309 }
context 'when search_rate_limit is specified' do
let(:settings_params) do
{
user_email_lookup_limit: user_email_lookup_limit,
search_rate_limit: search_rate_limit
}
end
it 'updates search_rate_limit with correct value' do
expect(application_setting.search_rate_limit).not_to eq user_email_lookup_limit
expect(application_setting.search_rate_limit).not_to eq search_rate_limit
put :update, params: { application_setting: settings_params }
expect(application_setting.reload.search_rate_limit).to eq search_rate_limit
end
end
context 'when search_rate_limit is not specified' do
let(:settings_params) do
{
user_email_lookup_limit: search_rate_limit
}
end
it 'applies user_email_lookup_limit value to search_rate_limit' do
expect(application_setting.search_rate_limit).not_to eq search_rate_limit
put :update, params: { application_setting: settings_params }
expect(application_setting.reload.search_rate_limit).to eq search_rate_limit
end
end
end
end
describe 'PUT #reset_registration_token' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment