diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
commit | edaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch) | |
tree | 11f143effbfeba52329fb7afbd05e6e2a3790241 /spec/requests/users_controller_spec.rb | |
parent | d8a5691316400a0f7ec4f83832698f1988eb27c1 (diff) |
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'spec/requests/users_controller_spec.rb')
-rw-r--r-- | spec/requests/users_controller_spec.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb index eefc24f7824..dacc11eece7 100644 --- a/spec/requests/users_controller_spec.rb +++ b/spec/requests/users_controller_spec.rb @@ -636,6 +636,8 @@ RSpec.describe UsersController do describe 'GET #exists' do before do sign_in(user) + + allow(::Gitlab::ApplicationRateLimiter).to receive(:throttled?).and_return(false) end context 'when user exists' do @@ -677,6 +679,17 @@ RSpec.describe UsersController do end end end + + context 'when the rate limit has been reached' do + it 'returns status 429 Too Many Requests', :aggregate_failures do + ip = '1.2.3.4' + expect(::Gitlab::ApplicationRateLimiter).to receive(:throttled?).with(:username_exists, scope: ip).and_return(true) + + get user_exists_url(user.username), env: { 'REMOTE_ADDR': ip } + + expect(response).to have_gitlab_http_status(:too_many_requests) + end + end end describe '#ensure_canonical_path' do |