summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-03 03:11:15 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-03 03:11:15 +0000
commit8d94a37915dfc305c8217fe7e8e4d00928aa88cf (patch)
tree6ba2fd8147149daa2f0b696fe07bec12bc2a78a5 /qa
parenta0754ad291e60e9411897ae4e05e01a600037ee9 (diff)
downloadgitlab-ce-8d94a37915dfc305c8217fe7e8e4d00928aa88cf.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rwxr-xr-xqa/gdk/launch2
-rw-r--r--qa/qa/specs/features/browser_ui/1_manage/login/log_in_with_2fa_spec.rb7
-rw-r--r--qa/qa/specs/helpers/context_selector.rb68
-rw-r--r--qa/spec/specs/helpers/context_selector_spec.rb14
4 files changed, 68 insertions, 23 deletions
diff --git a/qa/gdk/launch b/qa/gdk/launch
index 8ad2ce7e5ad..5d123906f04 100755
--- a/qa/gdk/launch
+++ b/qa/gdk/launch
@@ -37,4 +37,4 @@ bundle install --jobs=$(nproc) --retry=3 --quiet
# Run the tests
bundle exec rake "knapsack:download[test]"
-bundle exec bin/qa Test::Instance::All http://gdk.test:3000 -- $RSPEC_ARGS || true
+bundle exec bin/qa Test::Instance::All http://gdk.test:3000 -- $RSPEC_ARGS
diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/log_in_with_2fa_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/log_in_with_2fa_spec.rb
index cf9282c1149..54fb2aca990 100644
--- a/qa/qa/specs/features/browser_ui/1_manage/login/log_in_with_2fa_spec.rb
+++ b/qa/qa/specs/features/browser_ui/1_manage/login/log_in_with_2fa_spec.rb
@@ -43,7 +43,12 @@ module QA
it(
'allows enforcing 2FA via UI and logging in with 2FA',
- testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347931'
+ testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347931',
+ quarantine: {
+ type: :bug,
+ only: { condition: -> { QA::Runtime::Env.super_sidebar_enabled? } },
+ issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/409336'
+ }
) do
enforce_two_factor_authentication_on_group(group)
diff --git a/qa/qa/specs/helpers/context_selector.rb b/qa/qa/specs/helpers/context_selector.rb
index 59ab7c9722e..2527895dc4d 100644
--- a/qa/qa/specs/helpers/context_selector.rb
+++ b/qa/qa/specs/helpers/context_selector.rb
@@ -10,7 +10,11 @@ module QA
def except?(*options)
return false if Runtime::Env.ci_job_name.blank? && options.any? { |o| o.is_a?(Hash) && o[:job].present? }
- return false if Runtime::Env.ci_project_name.blank? && options.any? { |o| o.is_a?(Hash) && o[:pipeline].present? }
+
+ return false if Runtime::Env.ci_project_name.blank? && options.any? do |o|
+ o.is_a?(Hash) && o[:pipeline].present?
+ end
+
return false if Runtime::Scenario.attributes[:gitlab_address].blank?
context_matches?(*options)
@@ -34,24 +38,13 @@ module QA
opts.merge!(option)
if option[:pipeline].present?
- return true if Runtime::Env.ci_project_name.blank?
-
- return pipeline_matches?(option[:pipeline])
-
+ return evaluate_pipeline_context(option[:pipeline])
elsif option[:job].present?
- return true if Runtime::Env.ci_job_name.blank?
-
- return job_matches?(option[:job])
-
+ return evaluate_job_context(option[:job])
+ elsif !option[:condition].nil?
+ return evaluate_generic_condition(option[:condition])
elsif option[:subdomain].present?
- opts[:subdomain] = case option[:subdomain]
- when Array
- "(#{option[:subdomain].join("|")})\\."
- when Regexp
- option[:subdomain]
- else
- "(#{option[:subdomain]})\\."
- end
+ opts[:subdomain] = evaluate_subdomain_context(option[:subdomain])
end
end
@@ -60,6 +53,43 @@ module QA
alias_method :dot_com?, :context_matches?
+ private
+
+ def evaluate_pipeline_context(pipeline)
+ return true if Runtime::Env.ci_project_name.blank?
+
+ pipeline_matches?(pipeline)
+ end
+
+ def evaluate_job_context(job)
+ return true if Runtime::Env.ci_job_name.blank?
+
+ job_matches?(job)
+ end
+
+ def evaluate_generic_condition(condition)
+ return condition.call if condition.respond_to?(:call)
+
+ condition
+ end
+
+ def evaluate_subdomain_context(option)
+ case option
+ when Array
+ "(#{option.join('|')})\\."
+ when Regexp
+ option
+ else
+ "(#{option})\\."
+ end
+ end
+
+ def pipeline_matches?(pipeline_to_run_in)
+ Array(pipeline_to_run_in).any? do |pipeline|
+ pipeline.to_s.casecmp?(pipeline_from_project_name(Runtime::Env.ci_project_name))
+ end
+ end
+
def job_matches?(job_patterns)
Array(job_patterns).any? do |job|
pattern = job.is_a?(Regexp) ? job : Regexp.new(job)
@@ -68,10 +98,6 @@ module QA
end
end
- def pipeline_matches?(pipeline_to_run_in)
- Array(pipeline_to_run_in).any? { |pipeline| pipeline.to_s.casecmp?(pipeline_from_project_name(Runtime::Env.ci_project_name)) }
- end
-
def pipeline_from_project_name(project_name)
project_name.to_s.start_with?('gitlab-qa') ? Runtime::Env.default_branch : project_name
end
diff --git a/qa/spec/specs/helpers/context_selector_spec.rb b/qa/spec/specs/helpers/context_selector_spec.rb
index 9e46933542e..3c09f938684 100644
--- a/qa/spec/specs/helpers/context_selector_spec.rb
+++ b/qa/spec/specs/helpers/context_selector_spec.rb
@@ -132,6 +132,20 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do
end
end
+ context 'with generic condition context matcher' do
+ it 'matches truthy lambda condition result' do
+ expect(described_class.context_matches?(condition: -> { true })).to be_truthy
+ end
+
+ it 'matches truthy condition result' do
+ expect(described_class.context_matches?(condition: true)).to be_truthy
+ end
+
+ it 'skips falsey condition result' do
+ expect(described_class.context_matches?(condition: false)).to be_falsey
+ end
+ end
+
it 'returns false for mismatching' do
QA::Runtime::Scenario.define(:gitlab_address, "https://staging.gitlab.com")