Commit c8e28a0b authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent eace733d
......@@ -2,9 +2,8 @@
*.rb @gitlab-org/maintainers/rails-backend
*.rake @gitlab-org/maintainers/rails-backend
# Technical writing team are the default reviewers for everything in `doc/`
# Technical writing team are the default reviewers for all markdown docs
*.md @gl-docsteam
doc/ @gl-docsteam
# Frontend maintainers should see everything in `app/assets/`
app/assets/ @gitlab-org/maintainers/frontend
......
......@@ -69,7 +69,6 @@
&.footer-block {
margin-top: $gl-padding-24;
border-bottom: 0;
margin-bottom: -$gl-padding;
}
&.content-component-block {
......
......@@ -23,6 +23,10 @@ class WebHookLog < ApplicationRecord
response_status =~ /^2/
end
def internal_error?
response_status == WebHookService::InternalErrorResponse::ERROR_MESSAGE
end
private
def obfuscate_basic_auth
......
......@@ -2,12 +2,14 @@
class WebHookService
class InternalErrorResponse
ERROR_MESSAGE = 'internal error'
attr_reader :body, :headers, :code
def initialize
@headers = Gitlab::HTTP::Response::Headers.new({})
@body = ''
@code = 'internal error'
@code = ERROR_MESSAGE
end
end
......
.row.prepend-top-default.append-bottom-default
.row.prepend-top-32.append-bottom-default
.col-lg-3
%h4.prepend-top-0
Recent Deliveries
......
- label_status = hook_log.success? ? 'badge-success' : 'badge-danger'
%span{ class: "label #{label_status}" }
= hook_log.response_status
%span{ class: "badge #{label_status}" }
= hook_log.internal_error? ? _('Error') : hook_log.response_status
---
title: Fix spacing and UI on Recent Deliveries section of Project Services
merge_request: 22666
author:
type: fixed
......@@ -4,7 +4,7 @@ type: reference
# Parent-child pipelines
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/16094) in GitLab Starter 12.7.
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/16094) in GitLab 12.7.
As pipelines grow more complex, a few related problems start to emerge:
......
......@@ -18,6 +18,14 @@ module API
def validate_file!
render_api_error!('The file is invalid', 400) unless file_is_valid?
end
def throttled?(key, scope)
rate_limiter.throttled?(key, scope: scope)
end
def rate_limiter
::Gitlab::ApplicationRateLimiter
end
end
before do
......@@ -43,6 +51,14 @@ module API
success Entities::ProjectImportStatus
end
post 'import' do
key = "project_import".to_sym
if throttled?(key, [current_user, key])
rate_limiter.log_request(request, "#{key}_request_limit".to_sym, current_user)
render_api_error!({ error: _('This endpoint has been requested too many times. Try again later.') }, 429)
end
validate_file!
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42437')
......
......@@ -69,4 +69,20 @@ describe WebHookLog do
it { expect(web_hook_log.success?).to be_falsey }
end
end
describe '#internal_error?' do
let(:web_hook_log) { build_stubbed(:web_hook_log, response_status: status) }
context 'when response status is not an internal error' do
let(:status) { '200' }
it { expect(web_hook_log.internal_error?).to be_falsey }
end
context 'when response status is an internal error' do
let(:status) { 'internal error' }
it { expect(web_hook_log.internal_error?).to be_truthy }
end
end
end
......@@ -196,6 +196,19 @@ describe API::ProjectImport do
end
end
context 'when request exceeds the rate limit' do
before do
allow(::Gitlab::ApplicationRateLimiter).to receive(:throttled?).and_return(true)
end
it 'prevents users from importing projects' do
post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.id }
expect(response).to have_gitlab_http_status(429)
expect(json_response['message']['error']).to eq('This endpoint has been requested too many times. Try again later.')
end
end
def stub_import(namespace)
expect_any_instance_of(ProjectImportState).to receive(:schedule)
expect(::Projects::CreateService).to receive(:new).with(user, hash_including(namespace_id: namespace.id)).and_call_original
......
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