diff options
-rw-r--r-- | .gitlab/issue_templates/Geo Replicate a new Git repository type.md | 7 | ||||
-rw-r--r-- | app/controllers/profiles/two_factor_auths_controller.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/checks/branch_check.rb | 1 | ||||
-rw-r--r-- | spec/controllers/profiles/two_factor_auths_controller_spec.rb | 26 | ||||
-rw-r--r-- | spec/lib/gitlab/checks/branch_check_spec.rb | 9 | ||||
-rw-r--r-- | spec/services/ci/job_artifacts/create_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/spec_helper.rb | 11 |
7 files changed, 57 insertions, 1 deletions
diff --git a/.gitlab/issue_templates/Geo Replicate a new Git repository type.md b/.gitlab/issue_templates/Geo Replicate a new Git repository type.md index 0d822945798..ee4cb270536 100644 --- a/.gitlab/issue_templates/Geo Replicate a new Git repository type.md +++ b/.gitlab/issue_templates/Geo Replicate a new Git repository type.md @@ -365,6 +365,10 @@ That's all of the required database changes. ::Gitlab::GitAccessCoolWidget end + def self.no_repo_message + git_access_class.error_message(:no_repo) + end + # The feature flag follows the format `geo_#{replicable_name}_replication`, # so here it would be `geo_cool_widget_replication` def self.replication_enabled_by_default? @@ -403,6 +407,9 @@ That's all of the required database changes. ``` - [ ] Make sure a Geo secondary site can request and download Cool Widgets on the Geo primary site. You may need to make some changes to `Gitlab::GitAccessCoolWidget`. For example, see [this change for Group-level Wikis](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54914/diffs?commit_id=0f2b36f66697b4addbc69bd377ee2818f648dd33). + +- [ ] Make sure a Geo secondary site can replicate Cool Widgets where repository does not exist on the Geo primary site. The only way to know about this is to parse the error text. You may need to make some changes to `Gitlab::CoolWidgetReplicator.no_repo_message` to return the proper error message. For example, see [this change for Group-level Wikis](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74133). + - [ ] Generate the feature flag definition file by running the feature flag command and following the command prompts: ```shell diff --git a/app/controllers/profiles/two_factor_auths_controller.rb b/app/controllers/profiles/two_factor_auths_controller.rb index e0b5d6be155..1968fa81b29 100644 --- a/app/controllers/profiles/two_factor_auths_controller.rb +++ b/app/controllers/profiles/two_factor_auths_controller.rb @@ -147,7 +147,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController end def current_password_required? - !current_user.password_automatically_set? + !current_user.password_automatically_set? && current_user.allow_password_authentication_for_web? end def build_qr_code diff --git a/lib/gitlab/checks/branch_check.rb b/lib/gitlab/checks/branch_check.rb index cfff6e919dc..237a6bbb0f2 100644 --- a/lib/gitlab/checks/branch_check.rb +++ b/lib/gitlab/checks/branch_check.rb @@ -40,6 +40,7 @@ module Gitlab private def prohibited_branch_checks + return if deletion? return unless Feature.enabled?(:prohibit_hexadecimal_branch_names, project, default_enabled: true) if branch_name =~ /\A\h{40}\z/ diff --git a/spec/controllers/profiles/two_factor_auths_controller_spec.rb b/spec/controllers/profiles/two_factor_auths_controller_spec.rb index e57bd5be937..48331d74dcc 100644 --- a/spec/controllers/profiles/two_factor_auths_controller_spec.rb +++ b/spec/controllers/profiles/two_factor_auths_controller_spec.rb @@ -62,6 +62,32 @@ RSpec.describe Profiles::TwoFactorAuthsController do expect(flash[:alert]).to be_nil end end + + context 'when password authentication is disabled' do + before do + stub_application_setting(password_authentication_enabled_for_web: false) + end + + it 'does not require the current password', :aggregate_failures do + go + + expect(response).not_to redirect_to(redirect_path) + expect(flash[:alert]).to be_nil + end + end + + context 'when the user is an LDAP user' do + before do + allow(user).to receive(:ldap_user?).and_return(true) + end + + it 'does not require the current password', :aggregate_failures do + go + + expect(response).not_to redirect_to(redirect_path) + expect(flash[:alert]).to be_nil + end + end end describe 'GET show' do diff --git a/spec/lib/gitlab/checks/branch_check_spec.rb b/spec/lib/gitlab/checks/branch_check_spec.rb index 3086cb1bd33..f503759f3f8 100644 --- a/spec/lib/gitlab/checks/branch_check_spec.rb +++ b/spec/lib/gitlab/checks/branch_check_spec.rb @@ -32,6 +32,15 @@ RSpec.describe Gitlab::Checks::BranchCheck do expect { subject.validate! }.not_to raise_error end + context "deleting a hexadecimal branch" do + let(:newrev) { "0000000000000000000000000000000000000000" } + let(:ref) { "refs/heads/267208abfe40e546f5e847444276f7d43a39503e" } + + it "doesn't prohibit the deletion of a hexadecimal branch name" do + expect { subject.validate! }.not_to raise_error + end + end + context "the feature flag is disabled" do it "doesn't prohibit a 40-character hexadecimal branch name" do stub_feature_flags(prohibit_hexadecimal_branch_names: false) diff --git a/spec/services/ci/job_artifacts/create_service_spec.rb b/spec/services/ci/job_artifacts/create_service_spec.rb index e6d9f208096..c4657d138f7 100644 --- a/spec/services/ci/job_artifacts/create_service_spec.rb +++ b/spec/services/ci/job_artifacts/create_service_spec.rb @@ -24,6 +24,8 @@ RSpec.describe Ci::JobArtifacts::CreateService do def file_to_upload(path, params = {}) upload = Tempfile.new('upload') FileUtils.copy(path, upload.path) + # This is a workaround for https://github.com/docker/for-linux/issues/1015 + FileUtils.touch(upload.path) UploadedFile.new(upload.path, **params) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c8664598691..f3dce375ae4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -465,3 +465,14 @@ Rugged::Settings['search_path_global'] = Rails.root.join('tmp/tests').to_s # Initialize FactoryDefault to use create_default helper TestProf::FactoryDefault.init + +module TouchRackUploadedFile + def initialize_from_file_path(path) + super + + # This is a no-op workaround for https://github.com/docker/for-linux/issues/1015 + File.utime @tempfile.atime, @tempfile.mtime, @tempfile.path # rubocop:disable Gitlab/ModuleWithInstanceVariables + end +end + +Rack::Test::UploadedFile.prepend(TouchRackUploadedFile) |