Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
ba06d3edb0
commit
c793bb6303
10 changed files with 84 additions and 24 deletions
|
@ -353,16 +353,17 @@ class Integration < ApplicationRecord
|
||||||
end
|
end
|
||||||
private_class_method :instance_level_integration
|
private_class_method :instance_level_integration
|
||||||
|
|
||||||
def self.create_from_active_default_integrations(scope, association)
|
# Returns the number of successfully saved integrations
|
||||||
group_ids = sorted_ancestors(scope).select(:id)
|
# Duplicate integrations are excluded from this count by their validations.
|
||||||
|
def self.create_from_active_default_integrations(owner, association)
|
||||||
|
group_ids = sorted_ancestors(owner).select(:id)
|
||||||
array = group_ids.to_sql.present? ? "array(#{group_ids.to_sql})" : 'ARRAY[]'
|
array = group_ids.to_sql.present? ? "array(#{group_ids.to_sql})" : 'ARRAY[]'
|
||||||
|
order = Arel.sql("type_new ASC, array_position(#{array}::bigint[], #{table_name}.group_id), instance DESC")
|
||||||
|
|
||||||
from_union([
|
from_union([active.where(instance: true), active.where(group_id: group_ids, inherit_from_id: nil)])
|
||||||
active.where(instance: true),
|
.order(order)
|
||||||
active.where(group_id: group_ids, inherit_from_id: nil)
|
.group_by(&:type)
|
||||||
]).order(Arel.sql("type_new ASC, array_position(#{array}::bigint[], #{table_name}.group_id), instance DESC")).group_by(&:type).each do |type, records|
|
.count { |type, parents| build_from_integration(parents.first, association => owner.id).save }
|
||||||
build_from_integration(records.first, association => scope.id).save
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.inherited_descendants_from_self_or_ancestors_from(integration)
|
def self.inherited_descendants_from_self_or_ancestors_from(integration)
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
= _('To add the entry manually, provide the following details to the application on your phone.')
|
= _('To add the entry manually, provide the following details to the application on your phone.')
|
||||||
%p.gl-mt-0.gl-mb-0
|
%p.gl-mt-0.gl-mb-0
|
||||||
= _('Account: %{account}') % { account: @account_string }
|
= _('Account: %{account}') % { account: @account_string }
|
||||||
%p.gl-mt-0.gl-mb-0{ data: { qa_selector: 'otp_secret_content' } }
|
%p.gl-mt-0.gl-mb-0.two-factor-secret{ data: { qa_selector: 'otp_secret_content' } }
|
||||||
= _('Key: %{key}') %{ key: current_user.otp_secret.scan(/.{4}/).join(' ') }
|
= _('Key: %{key}') %{ key: current_user.otp_secret.scan(/.{4}/).join(' ') }
|
||||||
%p.two-factor-new-manual-content
|
%p.two-factor-new-manual-content
|
||||||
= _('Time based: Yes')
|
= _('Time based: Yes')
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
---
|
|
||||||
name: ci_validate_job_length
|
|
||||||
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/73599
|
|
||||||
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/344665
|
|
||||||
milestone: '14.5'
|
|
||||||
type: development
|
|
||||||
group: group::pipeline authoring
|
|
||||||
default_enabled: true
|
|
|
@ -111,9 +111,10 @@ You can't use these keywords as job names:
|
||||||
- `false`
|
- `false`
|
||||||
- `nil`
|
- `nil`
|
||||||
|
|
||||||
Job names must be 255 characters or less. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/342800)
|
Job names must be 255 characters or less.
|
||||||
in GitLab 14.5, [with a feature flag](../../administration/feature_flags.md) named `ci_validate_job_length`.
|
|
||||||
Enabled by default. To disable it, ask an administrator to [disable the feature flag](../../administration/feature_flags.md).
|
> - [Enabled on GitLab.com](https://gitlab.com/gitlab-org/gitlab/-/issues/342800) in GitLab 14.5.
|
||||||
|
> - [Generally available](https://gitlab.com/gitlab-org/gitlab/-/issues/344665) in GitLab 14.10.[Feature flag <ci_validate_job_length>](https://gitlab.com/gitlab-org/gitlab/-/issues/344665) removed.
|
||||||
|
|
||||||
Use unique names for your jobs. If multiple jobs have the same name,
|
Use unique names for your jobs. If multiple jobs have the same name,
|
||||||
only one is added to the pipeline, and it's difficult to predict which one is chosen.
|
only one is added to the pipeline, and it's difficult to predict which one is chosen.
|
||||||
|
|
|
@ -23,7 +23,7 @@ module Gitlab
|
||||||
validates :config, presence: true
|
validates :config, presence: true
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
validates :name, type: Symbol
|
validates :name, type: Symbol
|
||||||
validates :name, length: { maximum: 255 }, if: -> { ::Feature.enabled?(:ci_validate_job_length, default_enabled: :yaml) }
|
validates :name, length: { maximum: 255 }
|
||||||
|
|
||||||
validates :config, disallowed_keys: {
|
validates :config, disallowed_keys: {
|
||||||
in: %i[only except start_in],
|
in: %i[only except start_in],
|
||||||
|
|
|
@ -289,9 +289,10 @@ module Gitlab
|
||||||
ObjectStoreSettings::SUPPORTED_TYPES.collect do |type|
|
ObjectStoreSettings::SUPPORTED_TYPES.collect do |type|
|
||||||
section_setting = config.try(type)
|
section_setting = config.try(type)
|
||||||
|
|
||||||
next unless section_setting
|
next unless section_setting && section_setting['enabled']
|
||||||
|
|
||||||
object_store_setting = section_setting['object_store']
|
# Use #to_h to avoid Settingslogic bug: https://gitlab.com/gitlab-org/gitlab/-/issues/286873
|
||||||
|
object_store_setting = section_setting['object_store']&.to_h
|
||||||
|
|
||||||
next unless object_store_setting && object_store_setting['enabled']
|
next unless object_store_setting && object_store_setting['enabled']
|
||||||
|
|
||||||
|
|
|
@ -839,7 +839,15 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions do
|
||||||
|
|
||||||
expect(page).to have_current_path(profile_two_factor_auth_path, ignore_query: true)
|
expect(page).to have_current_path(profile_two_factor_auth_path, ignore_query: true)
|
||||||
|
|
||||||
fill_in 'pin_code', with: user.reload.current_otp
|
# Use the secret shown on the page to generate the OTP that will be entered.
|
||||||
|
# This detects issues wherein a new secret gets generated after the
|
||||||
|
# page is shown.
|
||||||
|
wait_for_requests
|
||||||
|
|
||||||
|
otp_secret = page.find('.two-factor-secret').text.gsub('Key:', '').delete(' ')
|
||||||
|
current_otp = ROTP::TOTP.new(otp_secret).now
|
||||||
|
|
||||||
|
fill_in 'pin_code', with: current_otp
|
||||||
fill_in 'current_password', with: user.password
|
fill_in 'current_password', with: user.password
|
||||||
|
|
||||||
click_button 'Register with two-factor app'
|
click_button 'Register with two-factor app'
|
||||||
|
|
|
@ -167,6 +167,7 @@ RSpec.describe Gitlab::ImportExport::CommandLineUtil do
|
||||||
context 'for object_storage uri' do
|
context 'for object_storage uri' do
|
||||||
let(:enabled_object_storage_setting) do
|
let(:enabled_object_storage_setting) do
|
||||||
{
|
{
|
||||||
|
'enabled' => true,
|
||||||
'object_store' =>
|
'object_store' =>
|
||||||
{
|
{
|
||||||
'enabled' => true,
|
'enabled' => true,
|
||||||
|
|
|
@ -43,6 +43,7 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do
|
||||||
let(:import_url) { "#{host}/external-diffs/merge_request_diffs/mr-1/diff-1" }
|
let(:import_url) { "#{host}/external-diffs/merge_request_diffs/mr-1/diff-1" }
|
||||||
let(:enabled_object_storage_setting) do
|
let(:enabled_object_storage_setting) do
|
||||||
{
|
{
|
||||||
|
'enabled' => true,
|
||||||
'object_store' =>
|
'object_store' =>
|
||||||
{
|
{
|
||||||
'enabled' => true,
|
'enabled' => true,
|
||||||
|
@ -81,6 +82,49 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do
|
||||||
let(:expected_hostname) { nil }
|
let(:expected_hostname) { nil }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when LFS object storage is enabled' do
|
||||||
|
let(:lfs_config) do
|
||||||
|
{
|
||||||
|
'enabled' => lfs_enabled,
|
||||||
|
# This nesting of Settingslogic is necessary to trigger the bug
|
||||||
|
'object_store' => Settingslogic.new({ 'enabled' => true })
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:config) do
|
||||||
|
{
|
||||||
|
'gitlab' => Gitlab.config.gitlab,
|
||||||
|
'repositories' => { 'storages' => { 'default' => 'test' } },
|
||||||
|
'lfs' => Settingslogic.new(lfs_config)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:host) { 'http://127.0.0.1:9000' }
|
||||||
|
let(:settings) { Settingslogic.new(config) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
allow(Gitlab).to receive(:config).and_return(settings)
|
||||||
|
# Triggers Settingslogic bug: https://gitlab.com/gitlab-org/gitlab/-/issues/286873
|
||||||
|
settings.repositories.storages.default
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when LFS is disabled' do
|
||||||
|
let(:lfs_enabled) { false }
|
||||||
|
|
||||||
|
it 'raises an error' do
|
||||||
|
expect { subject }.to raise_error(described_class::BlockedUrlError)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when LFS is enabled with no connection endpoint' do
|
||||||
|
let(:lfs_enabled) { true }
|
||||||
|
|
||||||
|
it 'raises an error' do
|
||||||
|
expect { subject }.to raise_error(described_class::BlockedUrlError)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when allow_object_storage is false' do
|
context 'when allow_object_storage is false' do
|
||||||
|
|
|
@ -473,6 +473,18 @@ RSpec.describe Integration do
|
||||||
expect(project.reload.integrations.first.inherit_from_id).to eq(group_integration.id)
|
expect(project.reload.integrations.first.inherit_from_id).to eq(group_integration.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'there are multiple inheritable integrations, and a duplicate' do
|
||||||
|
let!(:group_integration_2) { create(:jenkins_integration, :group, group: group) }
|
||||||
|
let!(:group_integration_3) { create(:datadog_integration, :instance) }
|
||||||
|
let!(:duplicate) { create(:jenkins_integration, project: project) }
|
||||||
|
|
||||||
|
it 'returns the number of successfully created integrations' do
|
||||||
|
expect(described_class.create_from_active_default_integrations(project, :project_id)).to eq 2
|
||||||
|
|
||||||
|
expect(project.reload.integrations.size).to eq(3)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'passing a group' do
|
context 'passing a group' do
|
||||||
let!(:subgroup) { create(:group, parent: group) }
|
let!(:subgroup) { create(:group, parent: group) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue