Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab/CODEOWNERS3
-rw-r--r--app/assets/stylesheets/framework/blocks.scss1
-rw-r--r--app/models/hooks/web_hook_log.rb4
-rw-r--r--app/services/web_hook_service.rb4
-rw-r--r--app/views/projects/hook_logs/_index.html.haml2
-rw-r--r--app/views/shared/hook_logs/_status_label.html.haml4
-rw-r--r--changelogs/unreleased/118791-clean-up-spacing-on-recent-deliveries-section-of-project-service-s.yml5
-rw-r--r--doc/ci/parent_child_pipelines.md2
-rw-r--r--lib/api/project_import.rb16
-rw-r--r--spec/models/hooks/web_hook_log_spec.rb16
-rw-r--r--spec/requests/api/project_import_spec.rb13
11 files changed, 62 insertions, 8 deletions
diff --git a/.gitlab/CODEOWNERS b/.gitlab/CODEOWNERS
index 19aa96701d8..7dc1c302304 100644
--- a/.gitlab/CODEOWNERS
+++ b/.gitlab/CODEOWNERS
@@ -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
diff --git a/app/assets/stylesheets/framework/blocks.scss b/app/assets/stylesheets/framework/blocks.scss
index 53a8f7c483a..37cb2372b80 100644
--- a/app/assets/stylesheets/framework/blocks.scss
+++ b/app/assets/stylesheets/framework/blocks.scss
@@ -69,7 +69,6 @@
&.footer-block {
margin-top: $gl-padding-24;
border-bottom: 0;
- margin-bottom: -$gl-padding;
}
&.content-component-block {
diff --git a/app/models/hooks/web_hook_log.rb b/app/models/hooks/web_hook_log.rb
index df0e7b30f84..ed2e4408ce3 100644
--- a/app/models/hooks/web_hook_log.rb
+++ b/app/models/hooks/web_hook_log.rb
@@ -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
diff --git a/app/services/web_hook_service.rb b/app/services/web_hook_service.rb
index 87edac36e33..514ba998d2c 100644
--- a/app/services/web_hook_service.rb
+++ b/app/services/web_hook_service.rb
@@ -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
diff --git a/app/views/projects/hook_logs/_index.html.haml b/app/views/projects/hook_logs/_index.html.haml
index ada986dd969..f3cea6bea68 100644
--- a/app/views/projects/hook_logs/_index.html.haml
+++ b/app/views/projects/hook_logs/_index.html.haml
@@ -1,4 +1,4 @@
-.row.prepend-top-default.append-bottom-default
+.row.prepend-top-32.append-bottom-default
.col-lg-3
%h4.prepend-top-0
Recent Deliveries
diff --git a/app/views/shared/hook_logs/_status_label.html.haml b/app/views/shared/hook_logs/_status_label.html.haml
index 993880b7d6e..dfa5ecee448 100644
--- a/app/views/shared/hook_logs/_status_label.html.haml
+++ b/app/views/shared/hook_logs/_status_label.html.haml
@@ -1,3 +1,3 @@
- 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
diff --git a/changelogs/unreleased/118791-clean-up-spacing-on-recent-deliveries-section-of-project-service-s.yml b/changelogs/unreleased/118791-clean-up-spacing-on-recent-deliveries-section-of-project-service-s.yml
new file mode 100644
index 00000000000..608c7a419d3
--- /dev/null
+++ b/changelogs/unreleased/118791-clean-up-spacing-on-recent-deliveries-section-of-project-service-s.yml
@@ -0,0 +1,5 @@
+---
+title: Fix spacing and UI on Recent Deliveries section of Project Services
+merge_request: 22666
+author:
+type: fixed
diff --git a/doc/ci/parent_child_pipelines.md b/doc/ci/parent_child_pipelines.md
index 03ef042d55a..95a364d9a94 100644
--- a/doc/ci/parent_child_pipelines.md
+++ b/doc/ci/parent_child_pipelines.md
@@ -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:
diff --git a/lib/api/project_import.rb b/lib/api/project_import.rb
index b3f17447ea0..7e0bd299761 100644
--- a/lib/api/project_import.rb
+++ b/lib/api/project_import.rb
@@ -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')
diff --git a/spec/models/hooks/web_hook_log_spec.rb b/spec/models/hooks/web_hook_log_spec.rb
index 3520720d9a4..128601794cf 100644
--- a/spec/models/hooks/web_hook_log_spec.rb
+++ b/spec/models/hooks/web_hook_log_spec.rb
@@ -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
diff --git a/spec/requests/api/project_import_spec.rb b/spec/requests/api/project_import_spec.rb
index 186f0f52a46..71dd8fee0ae 100644
--- a/spec/requests/api/project_import_spec.rb
+++ b/spec/requests/api/project_import_spec.rb
@@ -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