summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-11 00:09:06 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-11 00:09:06 +0000
commita9104a50136e485c8dda7af37106332f9010a1e8 (patch)
tree26880b70033a0952d7801c9554b99cea827820dd
parent696b36294520f8a311586f99e838b6a61b1b3f32 (diff)
downloadgitlab-ce-76926-follow-up-from-resolve-multi-selection-for-delete-on-registry-page.tar.gz
Add latest changes from gitlab-org/gitlab@master76926-follow-up-from-resolve-multi-selection-for-delete-on-registry-page
-rw-r--r--app/models/repository.rb6
-rw-r--r--changelogs/unreleased/refactoring-entities-file-14.yml5
-rw-r--r--changelogs/unreleased/sh-squelch-snowplow-tracker-messages.yml5
-rw-r--r--config/initializers/snowplow_tracker.rb23
-rw-r--r--doc/administration/troubleshooting/group_saml_scim.md20
-rw-r--r--doc/administration/troubleshooting/img/ADFS-configure-NameID.pngbin0 -> 22571 bytes
-rw-r--r--doc/administration/troubleshooting/img/ADFS-configure-assertions.pngbin0 -> 10561 bytes
-rw-r--r--doc/administration/troubleshooting/img/ADFS-determine-token-signing-certificate-fingerprint.pngbin0 -> 49772 bytes
-rw-r--r--doc/administration/troubleshooting/img/ADFS-determine-token-signing-fingerprint-from-shell.pngbin0 -> 28939 bytes
-rw-r--r--doc/administration/troubleshooting/img/ADFS-saml-setup-sso-url.pngbin0 -> 30321 bytes
-rw-r--r--doc/api/api_resources.md2
-rw-r--r--doc/api/settings.md2
-rw-r--r--lib/api/entities.rb80
-rw-r--r--lib/api/entities/event.rb23
-rw-r--r--lib/api/entities/namespace_basic.rb17
-rw-r--r--lib/api/entities/project_group_link.rb9
-rw-r--r--lib/api/entities/push_event_payload.rb10
-rw-r--r--lib/api/entities/todo.rb46
-rw-r--r--spec/models/repository_spec.rb39
19 files changed, 189 insertions, 98 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index e04db65fa94..ae19e6b8120 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -1130,6 +1130,12 @@ class Repository
true
end
+ def create_from_bundle(bundle_path)
+ raw.create_from_bundle(bundle_path).tap do |result|
+ after_create if result
+ end
+ end
+
def blobs_metadata(paths, ref = 'HEAD')
references = Array.wrap(paths).map { |path| [ref, path] }
diff --git a/changelogs/unreleased/refactoring-entities-file-14.yml b/changelogs/unreleased/refactoring-entities-file-14.yml
new file mode 100644
index 00000000000..1d6f7d59431
--- /dev/null
+++ b/changelogs/unreleased/refactoring-entities-file-14.yml
@@ -0,0 +1,5 @@
+---
+title: Separate 5 classes into own entities files
+merge_request: 24745
+author: Rajendra Kadam
+type: added
diff --git a/changelogs/unreleased/sh-squelch-snowplow-tracker-messages.yml b/changelogs/unreleased/sh-squelch-snowplow-tracker-messages.yml
new file mode 100644
index 00000000000..97956560c1a
--- /dev/null
+++ b/changelogs/unreleased/sh-squelch-snowplow-tracker-messages.yml
@@ -0,0 +1,5 @@
+---
+title: Squelch Snowplow tracker log messages
+merge_request: 24809
+author:
+type: fixed
diff --git a/config/initializers/snowplow_tracker.rb b/config/initializers/snowplow_tracker.rb
index 3c730e03738..fadedc97d83 100644
--- a/config/initializers/snowplow_tracker.rb
+++ b/config/initializers/snowplow_tracker.rb
@@ -3,21 +3,12 @@
# Gitlab.com uses Snowplow for identifying users and events.
# https://gitlab.com/gitlab-org/gitlab/issues/6329
#
-# SnowplowTracker write log into STDERR
+# SnowplowTracker writes logs to STDERR:
# https://github.com/snowplow/snowplow-ruby-tracker/blob/39fcfa2be793f2e25e73087a9700abc93f43b5e8/lib/snowplow-tracker/emitters.rb#L23
-# `LOGGER = Logger.new(STDERR)`
-#
-# In puma.rb, if `stdout_redirect` specify stderr, Puma will overwrite STDERR in:
-# https://github.com/puma/puma/blob/b41205f5cacbc2ad0060472bdce68ba636f42175/lib/puma/runner.rb#L134
-# `STDERR.reopen stderr, (append ? "a" : "w")`
-# As a result, SnowplowTracker will log into Puma stderr, when Puma enabled.
-#
-# By default, SnowplowTracker uses default log formatter.
-# When enable Puma, SnowplowTracker log is expected to be JSON format, as part of puma_stderr.log.
-# Hence overwrite ::SnowplowTracker::LOGGER.formatter to JSON formatter
-
-if defined?(::Puma) && defined?(::SnowplowTracker::LOGGER)
- ::SnowplowTracker::LOGGER.formatter = proc do |severity, datetime, progname, msg|
- { severity: severity, timestamp: datetime.utc.iso8601(3), pid: $$, progname: progname, message: msg }.to_json << "\n"
- end
+if defined?(::SnowplowTracker::LOGGER)
+ # This squelches the output of the logger since it doesn't really
+ # provide useful information.
+ # https://github.com/snowplow/snowplow-ruby-tracker/pull/109
+ # would make it possible to configure this logger directly.
+ ::SnowplowTracker::LOGGER.level = Logger::FATAL
end
diff --git a/doc/administration/troubleshooting/group_saml_scim.md b/doc/administration/troubleshooting/group_saml_scim.md
index 109379f98ca..7c2733d9d63 100644
--- a/doc/administration/troubleshooting/group_saml_scim.md
+++ b/doc/administration/troubleshooting/group_saml_scim.md
@@ -55,3 +55,23 @@ Adding a user:
SSO settings:
![OneLogin SSO settings](img/OneLogin-SSOsettings.png)
+
+## ADFS
+
+Setup SAML SSO URL:
+
+![ADFS Setup SAML SSO URL](img/ADFS-saml-setup-sso-url.png)
+
+Configure Assertions:
+
+![ADFS Configure Assertions](img/ADFS-configure-assertions.png)
+
+Configure NameID:
+
+![ADFS ADFS-configure-NameID](img/ADFS-configure-NameID.png)
+
+Determine Certificate Fingerprint:
+
+| Via UI | Via Shell |
+|--------|-----------|
+| ![ADFS Determine Token Signing Certificate Fingerprint](img/ADFS-determine-token-signing-certificate-fingerprint.png) | ![ADFS Determine Token Signing Fingerprint From Shell](img/ADFS-determine-token-signing-fingerprint-from-shell.png) |
diff --git a/doc/administration/troubleshooting/img/ADFS-configure-NameID.png b/doc/administration/troubleshooting/img/ADFS-configure-NameID.png
new file mode 100644
index 00000000000..d45e189b3ab
--- /dev/null
+++ b/doc/administration/troubleshooting/img/ADFS-configure-NameID.png
Binary files differ
diff --git a/doc/administration/troubleshooting/img/ADFS-configure-assertions.png b/doc/administration/troubleshooting/img/ADFS-configure-assertions.png
new file mode 100644
index 00000000000..53c26ad0be1
--- /dev/null
+++ b/doc/administration/troubleshooting/img/ADFS-configure-assertions.png
Binary files differ
diff --git a/doc/administration/troubleshooting/img/ADFS-determine-token-signing-certificate-fingerprint.png b/doc/administration/troubleshooting/img/ADFS-determine-token-signing-certificate-fingerprint.png
new file mode 100644
index 00000000000..cd1b9db31d9
--- /dev/null
+++ b/doc/administration/troubleshooting/img/ADFS-determine-token-signing-certificate-fingerprint.png
Binary files differ
diff --git a/doc/administration/troubleshooting/img/ADFS-determine-token-signing-fingerprint-from-shell.png b/doc/administration/troubleshooting/img/ADFS-determine-token-signing-fingerprint-from-shell.png
new file mode 100644
index 00000000000..431141dd3ef
--- /dev/null
+++ b/doc/administration/troubleshooting/img/ADFS-determine-token-signing-fingerprint-from-shell.png
Binary files differ
diff --git a/doc/administration/troubleshooting/img/ADFS-saml-setup-sso-url.png b/doc/administration/troubleshooting/img/ADFS-saml-setup-sso-url.png
new file mode 100644
index 00000000000..a837f1b19cc
--- /dev/null
+++ b/doc/administration/troubleshooting/img/ADFS-saml-setup-sso-url.png
Binary files differ
diff --git a/doc/api/api_resources.md b/doc/api/api_resources.md
index 2adc0087474..a20b903d534 100644
--- a/doc/api/api_resources.md
+++ b/doc/api/api_resources.md
@@ -131,7 +131,7 @@ The following API resources are available outside of project and group contexts
| [Projects](projects.md) | `/users/:id/projects` (also available for projects) |
| [Runners](runners.md) | `/runners` (also available for projects) |
| [Search](search.md) | `/search` (also available for groups and projects) |
-| [Settings](settings.md) | `/application/settings` |
+| [Settings](settings.md) **(CORE ONLY)** | `/application/settings` |
| [Statistics](statistics.md) | `/application/statistics` |
| [Sidekiq metrics](sidekiq_metrics.md) | `/sidekiq` |
| [Suggestions](suggestions.md) | `/suggestions` |
diff --git a/doc/api/settings.md b/doc/api/settings.md
index ae44c317dbb..cae51579afb 100644
--- a/doc/api/settings.md
+++ b/doc/api/settings.md
@@ -1,4 +1,4 @@
-# Application settings API
+# Application settings API **(CORE ONLY)**
These API calls allow you to read and modify GitLab instance
[application settings](#list-of-settings-that-can-be-accessed-via-api-calls)
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 98c0f78de1f..5c46a9f21e8 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -129,86 +129,6 @@ module API
end
end
- class PushEventPayload < Grape::Entity
- expose :commit_count, :action, :ref_type, :commit_from, :commit_to, :ref,
- :commit_title, :ref_count
- end
-
- class Event < Grape::Entity
- expose :project_id, :action_name
- expose :target_id, :target_iid, :target_type, :author_id
- expose :target_title
- expose :created_at
- expose :note, using: Entities::Note, if: ->(event, options) { event.note? }
- expose :author, using: Entities::UserBasic, if: ->(event, options) { event.author }
-
- expose :push_event_payload,
- as: :push_data,
- using: PushEventPayload,
- if: -> (event, _) { event.push_action? }
-
- expose :author_username do |event, options|
- event.author&.username
- end
- end
-
- class ProjectGroupLink < Grape::Entity
- expose :id, :project_id, :group_id, :group_access, :expires_at
- end
-
- class Todo < Grape::Entity
- expose :id
- expose :project, using: Entities::ProjectIdentity, if: -> (todo, _) { todo.project_id }
- expose :group, using: 'API::Entities::NamespaceBasic', if: -> (todo, _) { todo.group_id }
- expose :author, using: Entities::UserBasic
- expose :action_name
- expose :target_type
-
- expose :target do |todo, options|
- todo_options = options.fetch(todo.target_type, {})
- todo_target_class(todo.target_type).represent(todo.target, todo_options)
- end
-
- expose :target_url do |todo, options|
- todo_target_url(todo)
- end
-
- expose :body
- expose :state
- expose :created_at
-
- def todo_target_class(target_type)
- # false as second argument prevents looking up in module hierarchy
- # see also https://gitlab.com/gitlab-org/gitlab-foss/issues/59719
- ::API::Entities.const_get(target_type, false)
- end
-
- def todo_target_url(todo)
- target_type = todo.target_type.underscore
- target_url = "#{todo.resource_parent.class.to_s.underscore}_#{target_type}_url"
-
- Gitlab::Routing
- .url_helpers
- .public_send(target_url, todo.resource_parent, todo.target, anchor: todo_target_anchor(todo)) # rubocop:disable GitlabSecurity/PublicSend
- end
-
- def todo_target_anchor(todo)
- "note_#{todo.note_id}" if todo.note_id?
- end
- end
-
- class NamespaceBasic < Grape::Entity
- expose :id, :name, :path, :kind, :full_path, :parent_id, :avatar_url
-
- expose :web_url do |namespace|
- if namespace.user?
- Gitlab::Routing.url_helpers.user_url(namespace.owner)
- else
- namespace.web_url
- end
- end
- end
-
class Namespace < NamespaceBasic
expose :members_count_with_descendants, if: -> (namespace, opts) { expose_members_count_with_descendants?(namespace, opts) } do |namespace, _|
namespace.users_with_descendants.count
diff --git a/lib/api/entities/event.rb b/lib/api/entities/event.rb
new file mode 100644
index 00000000000..9c2d766b7f1
--- /dev/null
+++ b/lib/api/entities/event.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ class Event < Grape::Entity
+ expose :project_id, :action_name
+ expose :target_id, :target_iid, :target_type, :author_id
+ expose :target_title
+ expose :created_at
+ expose :note, using: Entities::Note, if: ->(event, options) { event.note? }
+ expose :author, using: Entities::UserBasic, if: ->(event, options) { event.author }
+
+ expose :push_event_payload,
+ as: :push_data,
+ using: Entities::PushEventPayload,
+ if: -> (event, _) { event.push_action? }
+
+ expose :author_username do |event, options|
+ event.author&.username
+ end
+ end
+ end
+end
diff --git a/lib/api/entities/namespace_basic.rb b/lib/api/entities/namespace_basic.rb
new file mode 100644
index 00000000000..f968a074bd2
--- /dev/null
+++ b/lib/api/entities/namespace_basic.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ class NamespaceBasic < Grape::Entity
+ expose :id, :name, :path, :kind, :full_path, :parent_id, :avatar_url
+
+ expose :web_url do |namespace|
+ if namespace.user?
+ Gitlab::Routing.url_helpers.user_url(namespace.owner)
+ else
+ namespace.web_url
+ end
+ end
+ end
+ end
+end
diff --git a/lib/api/entities/project_group_link.rb b/lib/api/entities/project_group_link.rb
new file mode 100644
index 00000000000..89138854e67
--- /dev/null
+++ b/lib/api/entities/project_group_link.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ class ProjectGroupLink < Grape::Entity
+ expose :id, :project_id, :group_id, :group_access, :expires_at
+ end
+ end
+end
diff --git a/lib/api/entities/push_event_payload.rb b/lib/api/entities/push_event_payload.rb
new file mode 100644
index 00000000000..6aad5f10177
--- /dev/null
+++ b/lib/api/entities/push_event_payload.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ class PushEventPayload < Grape::Entity
+ expose :commit_count, :action, :ref_type, :commit_from, :commit_to, :ref,
+ :commit_title, :ref_count
+ end
+ end
+end
diff --git a/lib/api/entities/todo.rb b/lib/api/entities/todo.rb
new file mode 100644
index 00000000000..820d1ceaadd
--- /dev/null
+++ b/lib/api/entities/todo.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ class Todo < Grape::Entity
+ expose :id
+ expose :project, using: Entities::ProjectIdentity, if: -> (todo, _) { todo.project_id }
+ expose :group, using: 'API::Entities::NamespaceBasic', if: -> (todo, _) { todo.group_id }
+ expose :author, using: Entities::UserBasic
+ expose :action_name
+ expose :target_type
+
+ expose :target do |todo, options|
+ todo_options = options.fetch(todo.target_type, {})
+ todo_target_class(todo.target_type).represent(todo.target, todo_options)
+ end
+
+ expose :target_url do |todo, options|
+ todo_target_url(todo)
+ end
+
+ expose :body
+ expose :state
+ expose :created_at
+
+ def todo_target_class(target_type)
+ # false as second argument prevents looking up in module hierarchy
+ # see also https://gitlab.com/gitlab-org/gitlab-foss/issues/59719
+ ::API::Entities.const_get(target_type, false)
+ end
+
+ def todo_target_url(todo)
+ target_type = todo.target_type.underscore
+ target_url = "#{todo.resource_parent.class.to_s.underscore}_#{target_type}_url"
+
+ Gitlab::Routing
+ .url_helpers
+ .public_send(target_url, todo.resource_parent, todo.target, anchor: todo_target_anchor(todo)) # rubocop:disable GitlabSecurity/PublicSend
+ end
+
+ def todo_target_anchor(todo)
+ "note_#{todo.note_id}" if todo.note_id?
+ end
+ end
+ end
+end
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index fdacfbe24d1..3d817065963 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -2781,6 +2781,45 @@ describe Repository do
end
end
+ describe '#create_from_bundle' do
+ let(:project) { create(:project) }
+ let(:repository) { project.repository }
+ let(:valid_bundle_path) { File.join(Dir.tmpdir, "repo-#{SecureRandom.hex}.bundle") }
+ let(:raw_repository) { repository.raw }
+
+ before do
+ allow(raw_repository).to receive(:create_from_bundle).and_return({})
+ end
+
+ after do
+ FileUtils.rm_rf(valid_bundle_path)
+ end
+
+ it 'calls out to the raw_repository to create a repo from bundle' do
+ expect(raw_repository).to receive(:create_from_bundle)
+
+ repository.create_from_bundle(valid_bundle_path)
+ end
+
+ it 'calls after_create' do
+ expect(repository).to receive(:after_create)
+
+ repository.create_from_bundle(valid_bundle_path)
+ end
+
+ context 'when exception is raised' do
+ before do
+ allow(raw_repository).to receive(:create_from_bundle).and_raise(::Gitlab::Git::BundleFile::InvalidBundleError)
+ end
+
+ it 'after_create is not executed' do
+ expect(repository).not_to receive(:after_create)
+
+ expect {repository.create_from_bundle(valid_bundle_path)}.to raise_error(::Gitlab::Git::BundleFile::InvalidBundleError)
+ end
+ end
+ end
+
describe "#blobs_metadata" do
let_it_be(:project) { create(:project, :repository) }
let(:repository) { project.repository }