diff options
31 files changed, 250 insertions, 75 deletions
diff --git a/app/assets/javascripts/issues/list/components/issues_list_app.vue b/app/assets/javascripts/issues/list/components/issues_list_app.vue index d90ca2f901d..021e3c867b0 100644 --- a/app/assets/javascripts/issues/list/components/issues_list_app.vue +++ b/app/assets/javascripts/issues/list/components/issues_list_app.vue @@ -867,7 +867,7 @@ export default { <li v-if="issuable.upvotes" v-gl-tooltip - class="issuable-upvotes gl-display-none gl-sm-display-block" + class="gl-display-none gl-sm-display-block" :title="$options.i18n.upvotes" data-testid="issuable-upvotes" > @@ -877,7 +877,7 @@ export default { <li v-if="issuable.downvotes" v-gl-tooltip - class="issuable-downvotes gl-display-none gl-sm-display-block" + class="gl-display-none gl-sm-display-block" :title="$options.i18n.downvotes" data-testid="issuable-downvotes" > diff --git a/app/assets/javascripts/vue_shared/issuable/list/components/issuable_item.vue b/app/assets/javascripts/vue_shared/issuable/list/components/issuable_item.vue index 30b7b073ac3..5b303b9a314 100644 --- a/app/assets/javascripts/vue_shared/issuable/list/components/issuable_item.vue +++ b/app/assets/javascripts/vue_shared/issuable/list/components/issuable_item.vue @@ -318,8 +318,8 @@ export default { <slot name="statistics"></slot> <li v-if="showDiscussions" - data-testid="issuable-discussions" - class="issuable-comments gl-display-none gl-sm-display-block" + class="gl-display-none gl-sm-display-block" + data-testid="issuable-comments" > <gl-link v-gl-tooltip.top diff --git a/app/models/users/phone_number_validation.rb b/app/models/users/phone_number_validation.rb index f6123c01fd0..b9e4e908ddd 100644 --- a/app/models/users/phone_number_validation.rb +++ b/app/models/users/phone_number_validation.rb @@ -31,11 +31,17 @@ module Users validates :telesign_reference_xid, length: { maximum: 255 } + scope :for_user, -> (user_id) { where(user_id: user_id) } + def self.related_to_banned_user?(international_dial_code, phone_number) joins(:banned_user).where( international_dial_code: international_dial_code, phone_number: phone_number ).exists? end + + def validated? + validated_at.present? + end end end diff --git a/app/views/search/results/_issuable.html.haml b/app/views/search/results/_issuable.html.haml index 36458a909fc..188ead4008e 100644 --- a/app/views/search/results/_issuable.html.haml +++ b/app/views/search/results/_issuable.html.haml @@ -13,7 +13,7 @@ = highlight_and_truncate_issuable(issuable, @search_term, @search_highlight) .col-sm-3.gl-mt-3.gl-sm-mt-0.gl-text-right - if issuable.respond_to?(:upvotes_count) && issuable.upvotes_count > 0 - %li.issuable-upvotes.gl-list-style-none + %li.gl-list-style-none %span.has-tooltip{ title: _('Upvotes') } = sprite_icon('thumb-up', css_class: "gl-vertical-align-middle") = issuable.upvotes_count diff --git a/app/views/shared/_issuable_meta_data.html.haml b/app/views/shared/_issuable_meta_data.html.haml index 01ab7bf9cd4..982d3b68792 100644 --- a/app/views/shared/_issuable_meta_data.html.haml +++ b/app/views/shared/_issuable_meta_data.html.haml @@ -6,23 +6,23 @@ - issuable_mr = @issuable_meta_data[issuable.id].merge_requests_count - if issuable_mr > 0 - %li.issuable-mr.gl-display-none.gl-sm-display-block.has-tooltip{ title: _('Related merge requests'), data: { testid: 'merge-requests' } } + %li.gl-display-none.gl-sm-display-block.has-tooltip{ title: _('Related merge requests'), data: { testid: 'merge-requests' } } = sprite_icon('merge-request', css_class: "gl-vertical-align-middle") = issuable_mr - if upvotes > 0 - %li.issuable-upvotes.gl-display-none.gl-sm-display-block.has-tooltip{ title: _('Upvotes') } + %li.gl-display-none.gl-sm-display-block.has-tooltip{ title: _('Upvotes'), data: { testid: 'issuable-upvotes' } } = sprite_icon('thumb-up', css_class: "gl-vertical-align-middle") = upvotes - if downvotes > 0 - %li.issuable-downvotes.gl-display-none.gl-sm-display-block.has-tooltip{ title: _('Downvotes') } + %li.gl-display-none.gl-sm-display-block.has-tooltip{ title: _('Downvotes'), data: { testid: 'issuable-downvotes' } } = sprite_icon('thumb-down', css_class: "gl-vertical-align-middle") = downvotes = render_if_exists 'shared/issuable/blocking_issues_count', issuable: issuable -%li.issuable-comments.gl-display-none.gl-sm-display-block - = link_to issuable_path, class: ['has-tooltip', ('no-comments' if note_count == 0)], title: _('Comments') do +%li.gl-display-none.gl-sm-display-block + = link_to issuable_path, class: ['has-tooltip', ('no-comments' if note_count == 0)], title: _('Comments'), data: { testid: 'issuable-comments' } do = sprite_icon('comments', css_class: 'gl-vertical-align-text-bottom') = note_count diff --git a/app/workers/database/batched_background_migration/ci_database_worker.rb b/app/workers/database/batched_background_migration/ci_database_worker.rb index b04db87631a..58b0f5496f4 100644 --- a/app/workers/database/batched_background_migration/ci_database_worker.rb +++ b/app/workers/database/batched_background_migration/ci_database_worker.rb @@ -7,6 +7,10 @@ module Database def self.tracking_database @tracking_database ||= Gitlab::Database::CI_DATABASE_NAME.to_sym end + + def execution_worker_class + @execution_worker_class ||= Database::BatchedBackgroundMigration::CiExecutionWorker + end end end end diff --git a/app/workers/database/batched_background_migration/ci_execution_worker.rb b/app/workers/database/batched_background_migration/ci_execution_worker.rb new file mode 100644 index 00000000000..89c70e29dda --- /dev/null +++ b/app/workers/database/batched_background_migration/ci_execution_worker.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Database + module BatchedBackgroundMigration + class CiExecutionWorker # rubocop:disable Scalability/IdempotentWorker + include ExecutionWorker + end + end +end diff --git a/app/workers/database/batched_background_migration/execution_worker.rb b/app/workers/database/batched_background_migration/execution_worker.rb index 098153c742f..6f8bcd849be 100644 --- a/app/workers/database/batched_background_migration/execution_worker.rb +++ b/app/workers/database/batched_background_migration/execution_worker.rb @@ -2,7 +2,7 @@ module Database module BatchedBackgroundMigration - class ExecutionWorker # rubocop:disable Scalability/IdempotentWorker + module ExecutionWorker include ExclusiveLeaseGuard include Gitlab::Utils::StrongMemoize diff --git a/app/workers/database/batched_background_migration/main_execution_worker.rb b/app/workers/database/batched_background_migration/main_execution_worker.rb new file mode 100644 index 00000000000..661496a86a9 --- /dev/null +++ b/app/workers/database/batched_background_migration/main_execution_worker.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Database + module BatchedBackgroundMigration + class MainExecutionWorker # rubocop:disable Scalability/IdempotentWorker + include ExecutionWorker + end + end +end diff --git a/app/workers/database/batched_background_migration/single_database_worker.rb b/app/workers/database/batched_background_migration/single_database_worker.rb index 0c7c51d5c0a..0ec67b59074 100644 --- a/app/workers/database/batched_background_migration/single_database_worker.rb +++ b/app/workers/database/batched_background_migration/single_database_worker.rb @@ -39,7 +39,7 @@ module Database unless base_model Sidekiq.logger.info( class: self.class.name, - database: self.class.tracking_database, + database: tracking_database, message: 'skipping migration execution for unconfigured database') return @@ -48,7 +48,7 @@ module Database if shares_db_config? Sidekiq.logger.info( class: self.class.name, - database: self.class.tracking_database, + database: tracking_database, message: 'skipping migration execution for database that shares database configuration with another database') return @@ -70,12 +70,16 @@ module Database end def run_active_migration - Database::BatchedBackgroundMigration::ExecutionWorker.new.perform(self.class.tracking_database, active_migration.id) + execution_worker_class.new.perform(tracking_database, active_migration.id) + end + + def tracking_database + self.class.tracking_database end def base_model strong_memoize(:base_model) do - Gitlab::Database.database_base_models[self.class.tracking_database] + Gitlab::Database.database_base_models[tracking_database] end end diff --git a/app/workers/database/batched_background_migration_worker.rb b/app/workers/database/batched_background_migration_worker.rb index 29804be832d..1450613dd89 100644 --- a/app/workers/database/batched_background_migration_worker.rb +++ b/app/workers/database/batched_background_migration_worker.rb @@ -7,5 +7,9 @@ module Database def self.tracking_database @tracking_database ||= Gitlab::Database::MAIN_DATABASE_NAME.to_sym end + + def execution_worker_class + @execution_worker_class ||= Database::BatchedBackgroundMigration::MainExecutionWorker + end end end diff --git a/db/post_migrate/20221117103015_add_async_index_author_id_created_at_on_merge_requests.rb b/db/post_migrate/20221117103015_add_async_index_author_id_created_at_on_merge_requests.rb new file mode 100644 index 00000000000..a45fdcccc27 --- /dev/null +++ b/db/post_migrate/20221117103015_add_async_index_author_id_created_at_on_merge_requests.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddAsyncIndexAuthorIdCreatedAtOnMergeRequests < Gitlab::Database::Migration[2.0] + INDEX_NAME = 'index_merge_requests_on_author_id_and_created_at' + + def up + prepare_async_index :merge_requests, %i[author_id created_at], name: INDEX_NAME + end + + def down + unprepare_async_index_by_name :merge_requests, INDEX_NAME + end +end diff --git a/db/schema_migrations/20221117103015 b/db/schema_migrations/20221117103015 new file mode 100644 index 00000000000..27244eb22e7 --- /dev/null +++ b/db/schema_migrations/20221117103015 @@ -0,0 +1 @@ +3e8cb08fd67a748a5ba77b495fb9700ff968af6e45d6fd024a4d2b09ba0c4d39
\ No newline at end of file diff --git a/doc/.vale/gitlab/spelling-exceptions.txt b/doc/.vale/gitlab/spelling-exceptions.txt index 0fc7c9703ac..ed3e2e62250 100644 --- a/doc/.vale/gitlab/spelling-exceptions.txt +++ b/doc/.vale/gitlab/spelling-exceptions.txt @@ -1,5 +1,6 @@ accessor accessors +ACLs Akismet Alertmanager Algolia @@ -15,6 +16,8 @@ anonymized Ansible Anthos Apdex +API +APIs Apparmor approvers architected @@ -22,12 +25,14 @@ architecting archiver Arel arity +armhf Artifactory Asana Asciidoctor asdf Assembla Atlassian +auditable auditability Auth0 Authentiq @@ -110,6 +115,7 @@ ChaosKube chatbot chatbots ChatOps +checksummable checksummed checksumming Chemlab @@ -117,10 +123,14 @@ Citrix Citus clonable Cloudwatch +clusterized +CMK +CMKs Cobertura Codeception Codepen Cognito +colocate colocated colocating compilable @@ -131,6 +141,8 @@ Consul Contentful Corosync Coursier +CPU +CPUs cron cronjob cronjobs @@ -202,6 +214,7 @@ downvotes Dpl Dreamweaver Ecto +eden ElastiCache Elasticsearch enablement @@ -209,6 +222,7 @@ enqueued enqueues enum enums +ESXi ETag Excon exfiltration @@ -231,6 +245,7 @@ Fio firewalled firewalling fixup +Flamegraph Flawfinder Flowdock Fluentd @@ -274,6 +289,7 @@ Grype Gzip Hackathon Haml +HAProxy hardcode hardcoded hardcodes @@ -294,6 +310,7 @@ hotfixes hotfixing http https +iCloud idempotence idmapper Iglu @@ -307,6 +324,7 @@ innersourcing interdependencies interdependency interruptible +IPs irker issuables Istio @@ -322,6 +340,8 @@ jQuery jsdom Jsonnet JupyterHub +JWT +JWTs Kaminari kanban kanbans @@ -339,6 +359,7 @@ Klar Knative Kramdown Kroki +kubeconfig Kubecost kubectl Kubernetes @@ -369,6 +390,7 @@ Mailgun Mailroom Makefile Makefiles +malloc Markdown markdownlint Marketo @@ -408,6 +430,7 @@ Monokai monorepo monorepos monospace +MRs multiline mutex nameserver @@ -440,11 +463,14 @@ onboarding OpenID OpenShift Opsgenie +OS +OSs outdent Overcommit Packagist parallelization parallelizations +passthrough passwordless Patroni performant @@ -524,6 +550,7 @@ rebased rebases rebasing reCAPTCHA +recoverability Redcarpet redirection redirections @@ -595,7 +622,9 @@ scalers scatterplot scatterplots Schemastore +scriptable scrollable +SELinux Semgrep Sendmail Sentry @@ -634,6 +663,7 @@ sparklines spidering Splunk SpotBugs +SSDs Stackdriver Stackprof starrer @@ -734,6 +764,7 @@ truthy Twilio Twitter TypeScript +TZInfo Ubuntu Udemy unapplied @@ -846,6 +877,7 @@ viewport viewports virtualized virtualizing +VMs Vue Vuex walkthrough @@ -853,6 +885,7 @@ walkthroughs WebdriverIO Webex webpack +WEBrick webserver Webservice websocket diff --git a/doc/administration/audit_event_streaming.md b/doc/administration/audit_event_streaming.md index 0c65f888722..8cb9493e15a 100644 --- a/doc/administration/audit_event_streaming.md +++ b/doc/administration/audit_event_streaming.md @@ -297,6 +297,8 @@ On self-managed GitLab, by default this feature is not available. To make it ava When this feature is enabled for a group, you can use an API to permit users to filter streamed audit events per destination. If the feature is enabled with no filters, the destination receives all audit events. +A streaming destination that has an event type filter set has a **filtered** (**{filter}**) label. + ### Use the API to add an event type filter Prerequisites: diff --git a/lib/atlassian/jira_connect.rb b/lib/atlassian/jira_connect.rb index 595cf0ac465..3ebed08280a 100644 --- a/lib/atlassian/jira_connect.rb +++ b/lib/atlassian/jira_connect.rb @@ -17,8 +17,16 @@ module Atlassian private def gitlab_host + return host_from_settings if Gitlab::CurrentSettings.jira_connect_proxy_url? + Gitlab.config.gitlab.host end + + def host_from_settings + uri = URI(Gitlab::CurrentSettings.jira_connect_proxy_url) + + uri.hostname + uri.path + end end end end diff --git a/lib/gitlab/application_rate_limiter.rb b/lib/gitlab/application_rate_limiter.rb index 507f94d87a5..d78722605bc 100644 --- a/lib/gitlab/application_rate_limiter.rb +++ b/lib/gitlab/application_rate_limiter.rb @@ -51,6 +51,7 @@ module Gitlab project_testing_integration: { threshold: 5, interval: 1.minute }, email_verification: { threshold: 10, interval: 10.minutes }, email_verification_code_send: { threshold: 10, interval: 1.hour }, + phone_verification_send_code: { threshold: 10, interval: 1.hour }, namespace_exists: { threshold: 20, interval: 1.minute }, fetch_google_ip_list: { threshold: 10, interval: 1.minute } }.freeze diff --git a/locale/gitlab.pot b/locale/gitlab.pot index abea652b88b..dbca0dcaca4 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -5623,6 +5623,9 @@ msgstr "" msgid "AuditStreams|Destination URL" msgstr "" +msgid "AuditStreams|Destination has filters applied. %{linkStart}What are filters?%{linkEnd}" +msgstr "" + msgid "AuditStreams|Destinations receive all audit event data" msgstr "" @@ -5668,6 +5671,9 @@ msgstr "" msgid "AuditStreams|Verification token" msgstr "" +msgid "AuditStreams|filtered" +msgstr "" + msgid "Aug" msgstr "" @@ -20425,7 +20431,7 @@ msgstr "" msgid "IdentityVerification|Phone number" msgstr "" -msgid "IdentityVerification|Phone number can't be blank." +msgid "IdentityVerification|Phone number is required." msgstr "" msgid "IdentityVerification|Phone number must be %{maxLength} digits or fewer." @@ -20482,6 +20488,9 @@ msgstr "" msgid "IdentityVerification|Verify your identity" msgstr "" +msgid "IdentityVerification|We've sent a verification code to +%{phoneNumber}" +msgstr "" + msgid "IdentityVerification|You can always verify your account at a later time to create a group." msgstr "" @@ -29749,6 +29758,9 @@ msgstr "" msgid "PhoneVerification|You've reached the maximum number of tries. Request a new code and try again." msgstr "" +msgid "PhoneVerification|You've reached the maximum number of tries. Wait %{interval} and try again." +msgstr "" + msgid "Pick a name" msgstr "" diff --git a/qa/qa/fixtures/package_managers/maven/group/settings_with_pat.xml.erb b/qa/qa/fixtures/package_managers/maven/group/settings_with_pat.xml.erb index 611c232819f..a2d3e7493ef 100644 --- a/qa/qa/fixtures/package_managers/maven/group/settings_with_pat.xml.erb +++ b/qa/qa/fixtures/package_managers/maven/group/settings_with_pat.xml.erb @@ -7,7 +7,7 @@ <httpHeaders> <property> <name>Private-Token</name> - <value><%= personal_access_token %></value> + <value>${PERSONAL_ACCESS_TOKEN}</value> </property> </httpHeaders> </configuration> diff --git a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/raw_variables_defined_in_yaml_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/raw_variables_defined_in_yaml_spec.rb index fe934e8c60f..a4849d47183 100644 --- a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/raw_variables_defined_in_yaml_spec.rb +++ b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/raw_variables_defined_in_yaml_spec.rb @@ -120,7 +120,7 @@ module QA testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/381486', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/381806', - only: { pipeline: %w[staging staging-canary] }, + only: { pipeline: %w[staging staging-canary staging-ref] }, type: :waiting_on } do before do diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb index aac8893ff2c..cda45efd828 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb @@ -1,9 +1,10 @@ # frozen_string_literal: true module QA - RSpec.describe 'Package', :skip_live_env, :orchestrated, :packages, :object_storage, :reliable, product_group: :package_registry do + RSpec.describe 'Package', :orchestrated, :packages, :object_storage, :reliable, product_group: :package_registry do describe 'Maven group level endpoint' do include Runtime::Fixtures + include Support::Helpers::MaskToken include_context 'packages registry qa scenario' let(:group_id) { 'com.gitlab.qa' } @@ -12,6 +13,18 @@ module QA let(:package_version) { '1.3.7' } let(:package_type) { 'maven' } + let(:group_deploy_token) do + Resource::GroupDeployToken.fabricate_via_api! do |deploy_token| + deploy_token.name = 'maven-group-deploy-token' + deploy_token.group = package_project.group + deploy_token.scopes = %w[ + read_repository + read_package_registry + write_package_registry + ] + end + end + context 'via maven' do where do { @@ -37,11 +50,13 @@ module QA let(:token) do case authentication_token_type when :personal_access_token - personal_access_token + use_ci_variable(name: 'PERSONAL_ACCESS_TOKEN', value: personal_access_token, project: package_project) + use_ci_variable(name: 'PERSONAL_ACCESS_TOKEN', value: personal_access_token, project: client_project) when :ci_job_token - '${env.CI_JOB_TOKEN}' + '${CI_JOB_TOKEN}' when :project_deploy_token - project_deploy_token.token + use_ci_variable(name: 'GROUP_DEPLOY_TOKEN', value: group_deploy_token.token, project: package_project) + use_ci_variable(name: 'GROUP_DEPLOY_TOKEN', value: group_deploy_token.token, project: client_project) end end @@ -121,8 +136,9 @@ module QA context 'duplication setting' do before do + use_ci_variable(name: 'PERSONAL_ACCESS_TOKEN', value: personal_access_token, project: package_project) + use_ci_variable(name: 'PERSONAL_ACCESS_TOKEN', value: personal_access_token, project: client_project) package_project.group.visit! - Page::Group::Menu.perform(&:go_to_package_settings) end @@ -132,16 +148,19 @@ module QA end it 'prevents users from publishing duplicates', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/377491' do - create_duplicated_package + create_package(package_project) + show_latest_deploy_job - push_duplicated_package + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 400) + end - client_project.visit! + Page::Project::Job::Show.perform(&:retry!) show_latest_deploy_job Page::Project::Job::Show.perform do |job| - expect(job).not_to be_successful(timeout: 800) + expect(job).not_to be_successful(timeout: 400) end end end @@ -152,52 +171,32 @@ module QA end it 'allows users to publish duplicates', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/377492' do - create_duplicated_package - - push_duplicated_package + create_package(package_project) show_latest_deploy_job Page::Project::Job::Show.perform do |job| - expect(job).to be_successful(timeout: 800) + expect(job).to be_successful(timeout: 400) end - end - end - def create_duplicated_package - settings_xml_with_pat = ERB.new(read_fixture('package_managers/maven/group', 'settings_with_pat.xml.erb')).result(binding) - pom_xml = ERB.new(read_fixture('package_managers/maven/group/producer', 'pom.xml.erb')).result(binding) - - with_fixtures([ - { - file_path: 'pom.xml', - content: pom_xml - }, - { - file_path: 'settings.xml', - content: settings_xml_with_pat - } - ]) do |dir| - Service::DockerRun::Maven.new(dir).publish! - end - - package_project.visit! + Page::Project::Job::Show.perform(&:retry!) - Page::Project::Menu.perform(&:click_packages_link) + show_latest_deploy_job - Page::Project::Packages::Index.perform do |index| - expect(index).to have_package(package_name) + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 400) + end end end - def push_duplicated_package + def create_package(project) Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do Resource::Repository::Commit.fabricate_via_api! do |commit| gitlab_ci_yaml = ERB.new(read_fixture('package_managers/maven/group/producer', 'gitlab_ci.yaml.erb')).result(binding) pom_xml = ERB.new(read_fixture('package_managers/maven/group/producer', 'pom.xml.erb')).result(binding) settings_xml_with_pat = ERB.new(read_fixture('package_managers/maven/group', 'settings_with_pat.xml.erb')).result(binding) - commit.project = client_project + commit.project = project commit.commit_message = 'Add .gitlab-ci.yml' commit.add_files( [ @@ -210,7 +209,7 @@ module QA end def show_latest_deploy_job - client_project.visit! + package_project.visit! Flow::Pipeline.visit_latest_pipeline diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_project_level_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_project_level_spec.rb index 8e1b0176f35..46c165ed806 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_project_level_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_project_level_spec.rb @@ -1,13 +1,14 @@ # frozen_string_literal: true module QA - RSpec.describe 'Package', :skip_live_env, :orchestrated, :packages, :object_storage, :reliable, + RSpec.describe 'Package', :orchestrated, :packages, :object_storage, :reliable, feature_flag: { name: 'maven_central_request_forwarding', scope: :global } do describe 'Maven project level endpoint', product_group: :package_registry do include Runtime::Fixtures + include Support::Helpers::MaskToken let(:group_id) { 'com.gitlab.qa' } let(:artifact_id) { "maven-#{SecureRandom.hex(8)}" } @@ -92,11 +93,11 @@ module QA let(:token) do case authentication_token_type when :personal_access_token - personal_access_token + use_ci_variable(name: 'PERSONAL_ACCESS_TOKEN', value: personal_access_token, project: package_project) when :ci_job_token - '${env.CI_JOB_TOKEN}' + '${CI_JOB_TOKEN}' when :project_deploy_token - project_deploy_token.token + use_ci_variable(name: 'PROJECT_DEPLOY_TOKEN', value: project_deploy_token.token, project: package_project) end end diff --git a/qa/qa/support/helpers/mask_token.rb b/qa/qa/support/helpers/mask_token.rb index 0c0af524c97..3aea77779ad 100644 --- a/qa/qa/support/helpers/mask_token.rb +++ b/qa/qa/support/helpers/mask_token.rb @@ -9,9 +9,8 @@ module QA ci_variable.project = project ci_variable.key = name ci_variable.value = value - ci_variable.protected = true end - "$#{name}" + "${#{name}}" end def use_group_ci_variable(name:, value:, group:) @@ -19,9 +18,8 @@ module QA ci_variable.group = group ci_variable.key = name ci_variable.value = value - ci_variable.protected = true end - "$#{name}" + "${#{name}}" end end end diff --git a/spec/features/issuables/issuable_list_spec.rb b/spec/features/issuables/issuable_list_spec.rb index a1e80586c05..48e7a1b59df 100644 --- a/spec/features/issuables/issuable_list_spec.rb +++ b/spec/features/issuables/issuable_list_spec.rb @@ -26,9 +26,9 @@ RSpec.describe 'issuable list', :js do it "counts upvotes, downvotes and notes count for each #{issuable_type.to_s.humanize}" do visit_issuable_list(issuable_type) - expect(first('.issuable-upvotes')).to have_content(1) - expect(first('.issuable-downvotes')).to have_content(1) - expect(first('.issuable-comments')).to have_content(2) + expect(first('[data-testid="issuable-upvotes"]')).to have_content(1) + expect(first('[data-testid="issuable-downvotes"]')).to have_content(1) + expect(first('[data-testid="issuable-comments"]')).to have_content(2) end it 'sorts labels alphabetically' do diff --git a/spec/frontend/vue_shared/issuable/list/components/issuable_item_spec.js b/spec/frontend/vue_shared/issuable/list/components/issuable_item_spec.js index e1c6020686c..2fac004875a 100644 --- a/spec/frontend/vue_shared/issuable/list/components/issuable_item_spec.js +++ b/spec/frontend/vue_shared/issuable/list/components/issuable_item_spec.js @@ -225,7 +225,7 @@ describe('IssuableItem', () => { }, }); - expect(wrapper.findByTestId('issuable-discussions').exists()).toBe(returnValue); + expect(wrapper.findByTestId('issuable-comments').exists()).toBe(returnValue); }, ); }); @@ -489,7 +489,7 @@ describe('IssuableItem', () => { it('renders discussions count', () => { wrapper = createComponent(); - const discussionsEl = wrapper.find('[data-testid="issuable-discussions"]'); + const discussionsEl = wrapper.findByTestId('issuable-comments'); expect(discussionsEl.exists()).toBe(true); expect(discussionsEl.findComponent(GlLink).attributes()).toMatchObject({ diff --git a/spec/lib/atlassian/jira_connect_spec.rb b/spec/lib/atlassian/jira_connect_spec.rb index d9c34e938b4..5a50832138b 100644 --- a/spec/lib/atlassian/jira_connect_spec.rb +++ b/spec/lib/atlassian/jira_connect_spec.rb @@ -25,5 +25,13 @@ RSpec.describe Atlassian::JiraConnect do expect(app_key).to eq('gitlab-jira-connect-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') end end + + context 'with jira_connect_proxy_url setting' do + before do + stub_application_setting(jira_connect_proxy_url: 'https://example.com') + end + + it { is_expected.to eq('gitlab-jira-connect-example.com') } + end end end diff --git a/spec/models/users/phone_number_validation_spec.rb b/spec/models/users/phone_number_validation_spec.rb index 2f0fd1d3ac9..7ab461a4346 100644 --- a/spec/models/users/phone_number_validation_spec.rb +++ b/spec/models/users/phone_number_validation_spec.rb @@ -78,4 +78,42 @@ RSpec.describe Users::PhoneNumberValidation do it { is_expected.to eq(false) } end end + + describe '#for_user' do + let_it_be(:user_1) { create(:user) } + let_it_be(:user_2) { create(:user) } + + let_it_be(:phone_number_record_1) { create(:phone_number_validation, user: user_1) } + let_it_be(:phone_number_record_2) { create(:phone_number_validation, user: user_2) } + + context 'when multiple records exist for multiple users' do + it 'returns the correct phone number record for user' do + records = described_class.for_user(user_1.id) + + expect(records.count).to be(1) + expect(records.first).to eq(phone_number_record_1) + end + end + end + + describe '#validated?' do + let_it_be(:user) { create(:user) } + let_it_be(:phone_number_record) { create(:phone_number_validation, user: user) } + + context 'when phone number record is not validated' do + it 'returns false' do + expect(phone_number_record.validated?).to be(false) + end + end + + context 'when phone number record is validated' do + before do + phone_number_record.update!(validated_at: Time.now.utc) + end + + it 'returns true' do + expect(phone_number_record.validated?).to be(true) + end + end + end end diff --git a/spec/workers/database/batched_background_migration/execution_worker_spec.rb b/spec/support/shared_examples/workers/batched_background_migration_execution_worker_shared_example.rb index 9a850a98f2f..706da49a829 100644 --- a/spec/workers/database/batched_background_migration/execution_worker_spec.rb +++ b/spec/support/shared_examples/workers/batched_background_migration_execution_worker_shared_example.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true -require 'spec_helper' - -RSpec.describe Database::BatchedBackgroundMigration::ExecutionWorker, :clean_gitlab_redis_shared_state do +RSpec.shared_examples 'batched background migrations execution worker' do include ExclusiveLeaseHelpers describe '#perform' do diff --git a/spec/support/shared_examples/workers/batched_background_migration_worker_shared_examples.rb b/spec/support/shared_examples/workers/batched_background_migration_worker_shared_examples.rb index 0be55fd2a3e..f918fdac9ad 100644 --- a/spec/support/shared_examples/workers/batched_background_migration_worker_shared_examples.rb +++ b/spec/support/shared_examples/workers/batched_background_migration_worker_shared_examples.rb @@ -145,6 +145,15 @@ RSpec.shared_examples 'it runs batched background migration jobs' do |tracking_d ) end + let(:execution_worker_class) do + case tracking_database + when :main + Database::BatchedBackgroundMigration::MainExecutionWorker + when :ci + Database::BatchedBackgroundMigration::CiExecutionWorker + end + end + before do allow(Gitlab::Database::BackgroundMigration::BatchedMigration).to receive(:active_migration) .with(connection: base_model.connection) @@ -161,7 +170,7 @@ RSpec.shared_examples 'it runs batched background migration jobs' do |tracking_d it 'sets the lease timeout to the minimum value' do expect_to_obtain_exclusive_lease(lease_key, timeout: minimum_timeout) - expect_next_instance_of(Database::BatchedBackgroundMigration::ExecutionWorker) do |worker| + expect_next_instance_of(execution_worker_class) do |worker| expect(worker).to receive(:perform).with(tracking_database, migration_id) end @@ -186,7 +195,7 @@ RSpec.shared_examples 'it runs batched background migration jobs' do |tracking_d base_model = Gitlab::Database.database_base_models[tracking_database] expect(Gitlab::Database::SharedModel).to receive(:using_connection).with(base_model.connection).and_yield - expect_next_instance_of(Database::BatchedBackgroundMigration::ExecutionWorker) do |worker| + expect_next_instance_of(execution_worker_class) do |worker| expect(worker).to receive(:perform).with(tracking_database, migration_id) end diff --git a/spec/workers/database/batched_background_migration/ci_execution_worker_spec.rb b/spec/workers/database/batched_background_migration/ci_execution_worker_spec.rb new file mode 100644 index 00000000000..ec77a15c7ef --- /dev/null +++ b/spec/workers/database/batched_background_migration/ci_execution_worker_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Database::BatchedBackgroundMigration::CiExecutionWorker, + :clean_gitlab_redis_shared_state, + feature_category: :database do + it_behaves_like 'batched background migrations execution worker' + end diff --git a/spec/workers/database/batched_background_migration/main_execution_worker_spec.rb b/spec/workers/database/batched_background_migration/main_execution_worker_spec.rb new file mode 100644 index 00000000000..42a3675f735 --- /dev/null +++ b/spec/workers/database/batched_background_migration/main_execution_worker_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Database::BatchedBackgroundMigration::MainExecutionWorker, + :clean_gitlab_redis_shared_state, + feature_category: :database do + it_behaves_like 'batched background migrations execution worker' + end |