diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-03 00:07:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-03 00:07:10 +0300 |
commit | ec8cf3f7c8d9ac408a81af714db7a0640cf0199d (patch) | |
tree | cbe011f521781fe98c656330cb5f42703bd71c03 | |
parent | af833d9730dd367984b55ef02ccc3fe6eb83f0e4 (diff) |
Add latest changes from gitlab-org/gitlab@master
58 files changed, 254 insertions, 256 deletions
diff --git a/.rubocop_todo/layout/multiline_operation_indentation.yml b/.rubocop_todo/layout/multiline_operation_indentation.yml index d8311d1fc14..a000ec0dcda 100644 --- a/.rubocop_todo/layout/multiline_operation_indentation.yml +++ b/.rubocop_todo/layout/multiline_operation_indentation.yml @@ -67,40 +67,3 @@ Layout/MultilineOperationIndentation: - 'ee/lib/ee/sidebars/projects/menus/issues_menu.rb' - 'ee/lib/sidebars/groups/menus/analytics_menu.rb' - 'ee/spec/services/ci/create_pipeline_service/dast_configuration_spec.rb' - - 'lib/api/maven_packages.rb' - - 'lib/api/users.rb' - - 'lib/api/validations/validators/array_none_any.rb' - - 'lib/gitlab/ci/reports/security/finding_key.rb' - - 'lib/gitlab/database/load_balancing/connection_proxy.rb' - - 'lib/gitlab/database/query_analyzers/prevent_cross_database_modification.rb' - - 'lib/gitlab/error_tracking/error_repository/open_api_strategy.rb' - - 'lib/gitlab/git_access.rb' - - 'lib/gitlab/gl_repository/repo_type.rb' - - 'lib/gitlab/jwt_token.rb' - - 'lib/gitlab/kubernetes/helm/v2/install_command.rb' - - 'lib/gitlab/kubernetes/helm/v2/patch_command.rb' - - 'lib/gitlab/kubernetes/helm/v3/install_command.rb' - - 'lib/gitlab/kubernetes/helm/v3/patch_command.rb' - - 'lib/gitlab/pagination/cursor_based_keyset.rb' - - 'lib/gitlab/quick_actions/issue_and_merge_request_actions.rb' - - 'lib/gitlab/rack_attack/request.rb' - - 'lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb' - - 'lib/gitlab/sidekiq_status.rb' - - 'lib/gitlab/x509/signature.rb' - - 'lib/gitlab_edition.rb' - - 'lib/kramdown/converter/commonmark.rb' - - 'lib/sidebars/groups/menus/packages_registries_menu.rb' - - 'lib/sidebars/projects/menus/analytics_menu.rb' - - 'lib/sidebars/projects/menus/deployments_menu.rb' - - 'lib/sidebars/projects/menus/hidden_menu.rb' - - 'qa/qa/ee/page/group/roadmap.rb' - - 'qa/qa/page/component/snippet.rb' - - 'qa/qa/runtime/api/repository_storage_moves.rb' - - 'rubocop/migration_helpers.rb' - - 'spec/controllers/graphql_controller_spec.rb' - - 'spec/frontend/fixtures/tabs.rb' - - 'spec/lib/gitlab/ci/pipeline/seed/build_spec.rb' - - 'spec/services/ci/create_pipeline_service_spec.rb' - - 'spec/services/projects/import_export/export_service_spec.rb' - - 'spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb' - - 'spec/support/shared_examples/models/with_debian_distributions_shared_examples.rb' diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 995303a631a..f003cbb5fd4 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -35,8 +35,7 @@ class RegistrationsController < Devise::RegistrationsController end def create - set_user_state - set_custom_confirmation_token + set_resource_fields super do |new_user| accept_pending_invitations if new_user.persisted? @@ -211,7 +210,7 @@ class RegistrationsController < Devise::RegistrationsController Gitlab::Recaptcha.load_configurations! end - def set_user_state + def set_resource_fields return unless set_blocked_pending_approval? resource.state = User::BLOCKED_PENDING_APPROVAL_STATE @@ -251,10 +250,6 @@ class RegistrationsController < Devise::RegistrationsController # overridden by EE module end - def set_custom_confirmation_token - # overridden by EE module - end - def send_custom_confirmation_instructions # overridden by EE module end diff --git a/app/finders/clusters/agent_tokens_finder.rb b/app/finders/clusters/agent_tokens_finder.rb index c0d1f911d92..72692777bc6 100644 --- a/app/finders/clusters/agent_tokens_finder.rb +++ b/app/finders/clusters/agent_tokens_finder.rb @@ -4,20 +4,25 @@ module Clusters class AgentTokensFinder include FinderMethods - def initialize(agent, current_user) + def initialize(agent, current_user, params = {}) @agent = agent @current_user = current_user + @params = params end def execute return ::Clusters::AgentToken.none unless can_read_cluster_agents? - agent.agent_tokens + agent.agent_tokens.then { |agent_tokens| by_status(agent_tokens) } end private - attr_reader :agent, :current_user + attr_reader :agent, :current_user, :params + + def by_status(agent_tokens) + params[:status].present? ? agent_tokens.with_status(params[:status]) : agent_tokens + end def can_read_cluster_agents? current_user&.can?(:read_cluster, agent&.project) diff --git a/app/graphql/resolvers/clusters/agent_tokens_resolver.rb b/app/graphql/resolvers/clusters/agent_tokens_resolver.rb index 9740bc6bb6a..b7355a1752e 100644 --- a/app/graphql/resolvers/clusters/agent_tokens_resolver.rb +++ b/app/graphql/resolvers/clusters/agent_tokens_resolver.rb @@ -14,18 +14,7 @@ module Resolvers description: 'Status of the token.' def resolve(**args) - return ::Clusters::AgentToken.none unless can_read_agent_tokens? - - tokens = agent.agent_tokens - tokens = tokens.with_status(args[:status]) if args[:status].present? - - tokens - end - - private - - def can_read_agent_tokens? - current_user.can?(:read_cluster, project) + ::Clusters::AgentTokensFinder.new(agent, current_user, args).execute end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c2d3e25ed93..249b1ed6aaa 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -323,7 +323,8 @@ module ApplicationHelper class_names << 'epic-boards-page gl-overflow-auto' if current_controller?(:epic_boards) class_names << 'with-performance-bar' if performance_bar_enabled? class_names << system_message_class - class_names << 'logged-out-marketing-header' unless current_user + class_names << 'logged-out-marketing-header' if !current_user && ::Gitlab.com? + class_names end diff --git a/app/views/layouts/header/_default.html.haml b/app/views/layouts/header/_default.html.haml index 42ffd155647..47d8f5a447f 100644 --- a/app/views/layouts/header/_default.html.haml +++ b/app/views/layouts/header/_default.html.haml @@ -19,7 +19,11 @@ .gl-display-none.gl-sm-display-block = render "layouts/nav/top_nav" - else - = render 'layouts/header/marketing_links' + - if Gitlab.com? + = render 'layouts/header/marketing_links' + - else + .gl-display-none.gl-sm-display-block + = render "layouts/nav/top_nav" - if top_nav_show_search .navbar-collapse.gl-transition-medium.collapse.gl-mr-auto.global-search-container.hide-when-top-nav-responsive-open @@ -102,7 +106,7 @@ = sprite_icon('chevron-down', css_class: 'caret-down') .dropdown-menu.dropdown-menu-right = render 'layouts/header/help_dropdown' - - unless current_user + - if !current_user && Gitlab.com? %li.nav-item.gl-display-none.gl-sm-display-block = render "layouts/nav/top_nav" - if header_link?(:user_dropdown) @@ -118,11 +122,14 @@ = link_to admin_impersonation_path, class: 'nav-link impersonation-btn', method: :delete, title: _('Stop impersonation'), aria: { label: _('Stop impersonation') }, data: { toggle: 'tooltip', placement: 'bottom', container: 'body', qa_selector: 'stop_impersonation_link' } do = sprite_icon('incognito', size: 18) - if header_link?(:sign_in) - %li.nav-item.gl-display-none.gl-sm-display-block - = link_to _('Sign up now'), new_user_registration_path, class: 'gl-button btn btn-default btn-sign-in' - %li.nav-item.gl-display-none.gl-sm-display-block - = link_to _('Login'), new_session_path(:user, redirect_to_referer: 'yes') - = render 'layouts/header/sign_in_register_button', class: 'gl-sm-display-none' + - if Gitlab.com? + %li.nav-item.gl-display-none.gl-sm-display-block + = link_to _('Sign up now'), new_user_registration_path, class: 'gl-button btn btn-default btn-sign-in' + %li.nav-item.gl-display-none.gl-sm-display-block + = link_to _('Login'), new_session_path(:user, redirect_to_referer: 'yes') + = render 'layouts/header/sign_in_register_button', class: 'gl-sm-display-none' + - else + = render 'layouts/header/sign_in_register_button' %button.navbar-toggler.d-block.d-sm-none{ type: 'button', class: 'gl-border-none!', data: { testid: 'top-nav-responsive-toggle', qa_selector: 'mobile_navbar_button' } } %span.sr-only= _('Toggle navigation') diff --git a/db/migrate/20221111123146_add_onboarding_in_progress_to_users.rb b/db/migrate/20221111123146_add_onboarding_in_progress_to_users.rb new file mode 100644 index 00000000000..665760347bf --- /dev/null +++ b/db/migrate/20221111123146_add_onboarding_in_progress_to_users.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddOnboardingInProgressToUsers < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + # rubocop:disable Migration/AddColumnsToWideTables + def up + add_column :users, :onboarding_in_progress, :boolean, default: false, null: false + end + + def down + remove_column :users, :onboarding_in_progress + end + # rubocop:enable Migration/AddColumnsToWideTables +end diff --git a/db/migrate/20221111123147_add_onboarding_step_url_to_user_details.rb b/db/migrate/20221111123147_add_onboarding_step_url_to_user_details.rb new file mode 100644 index 00000000000..7b6c035e05a --- /dev/null +++ b/db/migrate/20221111123147_add_onboarding_step_url_to_user_details.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddOnboardingStepUrlToUserDetails < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + # rubocop:disable Migration/AddLimitToTextColumns + # limit is added in 20221111123148_add_text_limit_to_onboarding_step_url.rb + def up + add_column :user_details, :onboarding_step_url, :text + end + + def down + remove_column :user_details, :onboarding_step_url + end + # rubocop:enable Migration/AddLimitToTextColumns +end diff --git a/db/migrate/20221111123148_add_text_limit_to_onboarding_step_url.rb b/db/migrate/20221111123148_add_text_limit_to_onboarding_step_url.rb new file mode 100644 index 00000000000..cfd9f004131 --- /dev/null +++ b/db/migrate/20221111123148_add_text_limit_to_onboarding_step_url.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddTextLimitToOnboardingStepUrl < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + def up + add_text_limit :user_details, :onboarding_step_url, 2000 + end + + def down + remove_text_limit :user_details, :onboarding_step_url + end +end diff --git a/db/schema_migrations/20221111123146 b/db/schema_migrations/20221111123146 new file mode 100644 index 00000000000..176a6ac6bba --- /dev/null +++ b/db/schema_migrations/20221111123146 @@ -0,0 +1 @@ +9679ef7921014d7b6123bf33a3df6276ca3a187641487c11d1dad86aa58b59a6
\ No newline at end of file diff --git a/db/schema_migrations/20221111123147 b/db/schema_migrations/20221111123147 new file mode 100644 index 00000000000..f5c17b7e08f --- /dev/null +++ b/db/schema_migrations/20221111123147 @@ -0,0 +1 @@ +43c86e9b4c78f5335a3288c4bd40fbcd5559cc175f3619f5e62e779f8aafa126
\ No newline at end of file diff --git a/db/schema_migrations/20221111123148 b/db/schema_migrations/20221111123148 new file mode 100644 index 00000000000..d32b1627453 --- /dev/null +++ b/db/schema_migrations/20221111123148 @@ -0,0 +1 @@ +777d3e757eeec38ee9a29ed2e9f72631d3928d9d449db4327781ad8240ab7922
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 974f1d57064..ae31e2894cc 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -22398,9 +22398,11 @@ CREATE TABLE user_details ( location text DEFAULT ''::text NOT NULL, organization text DEFAULT ''::text NOT NULL, password_last_changed_at timestamp with time zone DEFAULT now() NOT NULL, + onboarding_step_url text, CONSTRAINT check_245664af82 CHECK ((char_length(webauthn_xid) <= 100)), CONSTRAINT check_444573ee52 CHECK ((char_length(skype) <= 500)), CONSTRAINT check_466a25be35 CHECK ((char_length(twitter) <= 500)), + CONSTRAINT check_4f51129940 CHECK ((char_length(onboarding_step_url) <= 2000)), CONSTRAINT check_7b246dad73 CHECK ((char_length(organization) <= 500)), CONSTRAINT check_7d6489f8f3 CHECK ((char_length(linkedin) <= 500)), CONSTRAINT check_7fe2044093 CHECK ((char_length(website_url) <= 500)), @@ -22691,6 +22693,7 @@ CREATE TABLE users ( user_type smallint, static_object_token_encrypted text, otp_secret_expires_at timestamp with time zone, + onboarding_in_progress boolean DEFAULT false NOT NULL, CONSTRAINT check_7bde697e8e CHECK ((char_length(static_object_token_encrypted) <= 255)) ); diff --git a/doc/development/service_ping/metrics_dictionary.md b/doc/development/service_ping/metrics_dictionary.md index 3439f581e7f..f7abf7b99fa 100644 --- a/doc/development/service_ping/metrics_dictionary.md +++ b/doc/development/service_ping/metrics_dictionary.md @@ -41,7 +41,7 @@ Each metric is defined in a separate YAML file consisting of a number of fields: | `value_type` | yes | `string`; one of [`string`, `number`, `boolean`, `object`](https://json-schema.org/understanding-json-schema/reference/type.html). | | `status` | yes | `string`; [status](#metric-statuses) of the metric, may be set to `active`, `removed`, `broken`. | | `time_frame` | yes | `string`; may be set to a value like `7d`, `28d`, `all`, `none`. | -| `data_source` | yes | `string`; may be set to a value like `database`, `redis`, `redis_hll`, `prometheus`, `system`. | +| `data_source` | yes | `string`; may be set to a value like `database`, `redis`, `redis_hll`, `prometheus`, `system`, `license`. | | `data_category` | yes | `string`; [categories](#data-category) of the metric, may be set to `operational`, `optional`, `subscription`, `standard`. The default value is `optional`.| | `instrumentation_class` | yes | `string`; [the class that implements the metric](metrics_instrumentation.md). | | `distribution` | yes | `array`; may be set to one of `ce, ee` or `ee`. The [distribution](https://about.gitlab.com/handbook/marketing/strategic-marketing/tiers/#definitions) where the tracked feature is available. | diff --git a/doc/user/infrastructure/iac/index.md b/doc/user/infrastructure/iac/index.md index 9158dd53114..f9891934067 100644 --- a/doc/user/infrastructure/iac/index.md +++ b/doc/user/infrastructure/iac/index.md @@ -72,10 +72,12 @@ To use a Terraform template: include: # To fetch the latest template, use: - template: Terraform.latest.gitlab-ci.yml + # To fetch the advanced latest template, use: + - template: Terraform/Base.latest.gitlab-ci.yml # To fetch the stable template, use: + - template: Terraform.gitlab-ci.yml + # To fetch the advanced stable template, use: - template: Terraform/Base.gitlab-ci.yml - # To fetch the advanced template, use: - - template: Terraform/Base.latest.gitlab-ci.yml ``` 1. Add the variables as described below: diff --git a/lib/api/maven_packages.rb b/lib/api/maven_packages.rb index 30cdaba76ba..638ce6dbedc 100644 --- a/lib/api/maven_packages.rb +++ b/lib/api/maven_packages.rb @@ -107,7 +107,7 @@ module API def fetch_package(file_name:, project: nil, group: nil) order_by_package_file = file_name.include?(::Packages::Maven::Metadata.filename) && - !params[:path].include?(::Packages::Maven::FindOrCreatePackageService::SNAPSHOT_TERM) + !params[:path].include?(::Packages::Maven::FindOrCreatePackageService::SNAPSHOT_TERM) ::Packages::Maven::PackageFinder.new( current_user, diff --git a/lib/api/users.rb b/lib/api/users.rb index 72c121bca03..2e9fd0d6dd1 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -333,12 +333,12 @@ module API not_found!('User') unless user conflict!('Email has already been taken') if params[:email] && - User.by_any_email(params[:email].downcase) - .where.not(id: user.id).exists? + User.by_any_email(params[:email].downcase) + .where.not(id: user.id).exists? conflict!('Username has already been taken') if params[:username] && - User.by_username(params[:username]) - .where.not(id: user.id).exists? + User.by_username(params[:username]) + .where.not(id: user.id).exists? user_params = declared_params(include_missing: false) admin_making_changes_for_another_user = (current_user != user) diff --git a/lib/api/validations/validators/array_none_any.rb b/lib/api/validations/validators/array_none_any.rb index 3732c1f575c..8c064eefbf2 100644 --- a/lib/api/validations/validators/array_none_any.rb +++ b/lib/api/validations/validators/array_none_any.rb @@ -8,7 +8,7 @@ module API value = params[attr_name] return if value.is_a?(Array) || - [IssuableFinder::Params::FILTER_NONE, IssuableFinder::Params::FILTER_ANY].include?(value.to_s.downcase) + [IssuableFinder::Params::FILTER_NONE, IssuableFinder::Params::FILTER_ANY].include?(value.to_s.downcase) raise Grape::Exceptions::Validation.new( params: [@scope.full_name(attr_name)], diff --git a/lib/gitlab/ci/reports/security/finding_key.rb b/lib/gitlab/ci/reports/security/finding_key.rb index ad047fbf904..d42a0ea5b2e 100644 --- a/lib/gitlab/ci/reports/security/finding_key.rb +++ b/lib/gitlab/ci/reports/security/finding_key.rb @@ -15,7 +15,7 @@ module Gitlab has_fingerprints? && other.has_fingerprints? && location_fingerprint == other.location_fingerprint && - identifier_fingerprint == other.identifier_fingerprint + identifier_fingerprint == other.identifier_fingerprint end def hash diff --git a/lib/gitlab/database/load_balancing/connection_proxy.rb b/lib/gitlab/database/load_balancing/connection_proxy.rb index 8799f8d8af8..f0343f9d8b5 100644 --- a/lib/gitlab/database/load_balancing/connection_proxy.rb +++ b/lib/gitlab/database/load_balancing/connection_proxy.rb @@ -95,7 +95,7 @@ module Gitlab # name - The name of the method to call on a connection object. def read_using_load_balancer(...) if current_session.use_primary? && - !current_session.use_replicas_for_read_queries? + !current_session.use_replicas_for_read_queries? @load_balancer.read_write do |connection| connection.send(...) end diff --git a/lib/gitlab/database/query_analyzers/prevent_cross_database_modification.rb b/lib/gitlab/database/query_analyzers/prevent_cross_database_modification.rb index 3b1751c863d..dd10e0d7992 100644 --- a/lib/gitlab/database/query_analyzers/prevent_cross_database_modification.rb +++ b/lib/gitlab/database/query_analyzers/prevent_cross_database_modification.rb @@ -165,8 +165,8 @@ module Gitlab def self.in_factory_bot_create? Rails.env.test? && caller_locations.any? do |l| l.path.end_with?('lib/factory_bot/evaluation.rb') && l.label == 'create' || - l.path.end_with?('lib/factory_bot/strategy/create.rb') || - l.path.end_with?('shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb') && l.label == 'create_existing_record' + l.path.end_with?('lib/factory_bot/strategy/create.rb') || + l.path.end_with?('shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb') && l.label == 'create_existing_record' end end end diff --git a/lib/gitlab/error_tracking/error_repository/open_api_strategy.rb b/lib/gitlab/error_tracking/error_repository/open_api_strategy.rb index cc822e4c10b..e168fa10630 100644 --- a/lib/gitlab/error_tracking/error_repository/open_api_strategy.rb +++ b/lib/gitlab/error_tracking/error_repository/open_api_strategy.rb @@ -228,7 +228,7 @@ module Gitlab def configured_api_url url = Gitlab::CurrentSettings.current_application_settings.error_tracking_api_url || - 'http://localhost:8080' + 'http://localhost:8080' Gitlab::UrlBlocker.validate!(url, schemes: %w[http https], allow_localhost: true) diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index da2a81983ec..344dd27589c 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -157,10 +157,10 @@ module Gitlab # for deploy tokens and builds def can_download? deploy_key_can_download_code? || - deploy_token_can_download? || - build_can_download? || - user_can_download? || - guest_can_download? + deploy_token_can_download? || + build_can_download? || + user_can_download? || + guest_can_download? end def check_container! @@ -339,7 +339,7 @@ module Gitlab def check_change_access! if changes == ANY can_push = deploy_key? || - user_can_push? || + user_can_push? || project&.any_branch_allows_collaboration?(user_access.user) unless can_push diff --git a/lib/gitlab/gl_repository/repo_type.rb b/lib/gitlab/gl_repository/repo_type.rb index 05278b2dd35..7792ef55b28 100644 --- a/lib/gitlab/gl_repository/repo_type.rb +++ b/lib/gitlab/gl_repository/repo_type.rb @@ -66,10 +66,10 @@ module Gitlab def valid?(repository_path) repository_path.end_with?(path_suffix) && - ( - !snippet? || - repository_path.match?(Gitlab::PathRegex.full_snippets_repository_path_regex) - ) + ( + !snippet? || + repository_path.match?(Gitlab::PathRegex.full_snippets_repository_path_regex) + ) end private diff --git a/lib/gitlab/jwt_token.rb b/lib/gitlab/jwt_token.rb index 11bc5479b6e..83aa7fa4a15 100644 --- a/lib/gitlab/jwt_token.rb +++ b/lib/gitlab/jwt_token.rb @@ -42,7 +42,7 @@ module Gitlab def ==(other) self.id == other.id && - self.payload == other.payload + self.payload == other.payload end def issued_at=(value) diff --git a/lib/gitlab/kubernetes/helm/v2/install_command.rb b/lib/gitlab/kubernetes/helm/v2/install_command.rb index 10e16723e45..c50db6bf177 100644 --- a/lib/gitlab/kubernetes/helm/v2/install_command.rb +++ b/lib/gitlab/kubernetes/helm/v2/install_command.rb @@ -36,13 +36,13 @@ module Gitlab # installation and uprade of applications def install_command command = ['helm', 'upgrade', name, chart] + - install_flag + - rollback_support_flag + - reset_values_flag + - optional_version_flag + - rbac_create_flag + - namespace_flag + - value_flag + install_flag + + rollback_support_flag + + reset_values_flag + + optional_version_flag + + rbac_create_flag + + namespace_flag + + value_flag command.shelljoin end diff --git a/lib/gitlab/kubernetes/helm/v2/patch_command.rb b/lib/gitlab/kubernetes/helm/v2/patch_command.rb index 2855e6444b1..40e56771e47 100644 --- a/lib/gitlab/kubernetes/helm/v2/patch_command.rb +++ b/lib/gitlab/kubernetes/helm/v2/patch_command.rb @@ -37,10 +37,10 @@ module Gitlab def upgrade_command command = ['helm', 'upgrade', name, chart] + - reuse_values_flag + - version_flag + - namespace_flag + - value_flag + reuse_values_flag + + version_flag + + namespace_flag + + value_flag command.shelljoin end diff --git a/lib/gitlab/kubernetes/helm/v3/install_command.rb b/lib/gitlab/kubernetes/helm/v3/install_command.rb index 20d17f49115..8d521f0dcd4 100644 --- a/lib/gitlab/kubernetes/helm/v3/install_command.rb +++ b/lib/gitlab/kubernetes/helm/v3/install_command.rb @@ -33,13 +33,13 @@ module Gitlab # installation and uprade of applications def install_command command = ['helm', 'upgrade', name, chart] + - install_flag + - rollback_support_flag + - reset_values_flag + - optional_version_flag + - rbac_create_flag + - namespace_flag + - value_flag + install_flag + + rollback_support_flag + + reset_values_flag + + optional_version_flag + + rbac_create_flag + + namespace_flag + + value_flag command.shelljoin end diff --git a/lib/gitlab/kubernetes/helm/v3/patch_command.rb b/lib/gitlab/kubernetes/helm/v3/patch_command.rb index 00f340591e7..1278e524bd2 100644 --- a/lib/gitlab/kubernetes/helm/v3/patch_command.rb +++ b/lib/gitlab/kubernetes/helm/v3/patch_command.rb @@ -34,10 +34,10 @@ module Gitlab def upgrade_command command = ['helm', 'upgrade', name, chart] + - reuse_values_flag + - version_flag + - namespace_flag + - value_flag + reuse_values_flag + + version_flag + + namespace_flag + + value_flag command.shelljoin end diff --git a/lib/gitlab/pagination/cursor_based_keyset.rb b/lib/gitlab/pagination/cursor_based_keyset.rb index 2d9fb0a50fc..199ec16d4df 100644 --- a/lib/gitlab/pagination/cursor_based_keyset.rb +++ b/lib/gitlab/pagination/cursor_based_keyset.rb @@ -22,7 +22,7 @@ module Gitlab def self.available?(cursor_based_request_context, relation) available_for_type?(relation) && - order_satisfied?(relation, cursor_based_request_context) + order_satisfied?(relation, cursor_based_request_context) end def self.enforced_for_type?(relation) diff --git a/lib/gitlab/quick_actions/issue_and_merge_request_actions.rb b/lib/gitlab/quick_actions/issue_and_merge_request_actions.rb index 8b1ff5d298a..e549ee2e43a 100644 --- a/lib/gitlab/quick_actions/issue_and_merge_request_actions.rb +++ b/lib/gitlab/quick_actions/issue_and_merge_request_actions.rb @@ -92,7 +92,7 @@ module Gitlab types Issue, MergeRequest condition do quick_action_target.supports_milestone? && - current_user.can?(:"set_#{quick_action_target.to_ability_name}_metadata", quick_action_target) && + current_user.can?(:"set_#{quick_action_target.to_ability_name}_metadata", quick_action_target) && find_milestones(project, state: 'active').any? end parse_params do |milestone_param| @@ -156,7 +156,7 @@ module Gitlab types Issue, MergeRequest condition do quick_action_target.supports_time_tracking? && - current_user.can?(:"admin_#{quick_action_target.to_ability_name}", project) + current_user.can?(:"admin_#{quick_action_target.to_ability_name}", project) end parse_params do |raw_duration| Gitlab::TimeTrackingFormatter.parse(raw_duration) @@ -179,7 +179,7 @@ module Gitlab types Issue, MergeRequest condition do quick_action_target.supports_time_tracking? && - current_user.can?(:"admin_#{quick_action_target.to_ability_name}", quick_action_target) + current_user.can?(:"admin_#{quick_action_target.to_ability_name}", quick_action_target) end parse_params do |raw_time_date| Gitlab::QuickActions::SpendTimeAndDateSeparator.new(raw_time_date).execute diff --git a/lib/gitlab/rack_attack/request.rb b/lib/gitlab/rack_attack/request.rb index 08a5ddb6ad1..d7abacb5b67 100644 --- a/lib/gitlab/rack_attack/request.rb +++ b/lib/gitlab/rack_attack/request.rb @@ -79,96 +79,96 @@ module Gitlab def throttle_unauthenticated_api? api_request? && - !should_be_skipped? && - !frontend_request? && - !throttle_unauthenticated_packages_api? && - !throttle_unauthenticated_files_api? && - !throttle_unauthenticated_deprecated_api? && - Gitlab::Throttle.settings.throttle_unauthenticated_api_enabled && - unauthenticated? + !should_be_skipped? && + !frontend_request? && + !throttle_unauthenticated_packages_api? && + !throttle_unauthenticated_files_api? && + !throttle_unauthenticated_deprecated_api? && + Gitlab::Throttle.settings.throttle_unauthenticated_api_enabled && + unauthenticated? end def throttle_unauthenticated_web? (web_request? || frontend_request?) && - !should_be_skipped? && - # TODO: Column will be renamed in https://gitlab.com/gitlab-org/gitlab/-/issues/340031 - Gitlab::Throttle.settings.throttle_unauthenticated_enabled && - unauthenticated? + !should_be_skipped? && + # TODO: Column will be renamed in https://gitlab.com/gitlab-org/gitlab/-/issues/340031 + Gitlab::Throttle.settings.throttle_unauthenticated_enabled && + unauthenticated? end def throttle_authenticated_api? api_request? && - !frontend_request? && - !throttle_authenticated_packages_api? && - !throttle_authenticated_files_api? && - !throttle_authenticated_deprecated_api? && - Gitlab::Throttle.settings.throttle_authenticated_api_enabled + !frontend_request? && + !throttle_authenticated_packages_api? && + !throttle_authenticated_files_api? && + !throttle_authenticated_deprecated_api? && + Gitlab::Throttle.settings.throttle_authenticated_api_enabled end def throttle_authenticated_web? (web_request? || frontend_request?) && - !throttle_authenticated_git_lfs? && - Gitlab::Throttle.settings.throttle_authenticated_web_enabled + !throttle_authenticated_git_lfs? && + Gitlab::Throttle.settings.throttle_authenticated_web_enabled end def throttle_unauthenticated_protected_paths? post? && - !should_be_skipped? && - protected_path? && - Gitlab::Throttle.protected_paths_enabled? && - unauthenticated? + !should_be_skipped? && + protected_path? && + Gitlab::Throttle.protected_paths_enabled? && + unauthenticated? end def throttle_authenticated_protected_paths_api? post? && - api_request? && - protected_path? && - Gitlab::Throttle.protected_paths_enabled? + api_request? && + protected_path? && + Gitlab::Throttle.protected_paths_enabled? end def throttle_authenticated_protected_paths_web? post? && - web_request? && - protected_path? && - Gitlab::Throttle.protected_paths_enabled? + web_request? && + protected_path? && + Gitlab::Throttle.protected_paths_enabled? end def throttle_unauthenticated_packages_api? packages_api_path? && - Gitlab::Throttle.settings.throttle_unauthenticated_packages_api_enabled && - unauthenticated? + Gitlab::Throttle.settings.throttle_unauthenticated_packages_api_enabled && + unauthenticated? end def throttle_authenticated_packages_api? packages_api_path? && - Gitlab::Throttle.settings.throttle_authenticated_packages_api_enabled + Gitlab::Throttle.settings.throttle_authenticated_packages_api_enabled end def throttle_authenticated_git_lfs? git_lfs_path? && - Gitlab::Throttle.settings.throttle_authenticated_git_lfs_enabled + Gitlab::Throttle.settings.throttle_authenticated_git_lfs_enabled end def throttle_unauthenticated_files_api? files_api_path? && - Gitlab::Throttle.settings.throttle_unauthenticated_files_api_enabled && - unauthenticated? + Gitlab::Throttle.settings.throttle_unauthenticated_files_api_enabled && + unauthenticated? end def throttle_authenticated_files_api? files_api_path? && - Gitlab::Throttle.settings.throttle_authenticated_files_api_enabled + Gitlab::Throttle.settings.throttle_authenticated_files_api_enabled end def throttle_unauthenticated_deprecated_api? deprecated_api_request? && - Gitlab::Throttle.settings.throttle_unauthenticated_deprecated_api_enabled && - unauthenticated? + Gitlab::Throttle.settings.throttle_unauthenticated_deprecated_api_enabled && + unauthenticated? end def throttle_authenticated_deprecated_api? deprecated_api_request? && - Gitlab::Throttle.settings.throttle_authenticated_deprecated_api_enabled + Gitlab::Throttle.settings.throttle_authenticated_deprecated_api_enabled end private diff --git a/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb b/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb index 357e9d41187..4f7cd340461 100644 --- a/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb +++ b/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb @@ -253,7 +253,7 @@ module Gitlab def with_redis if Feature.enabled?(:use_primary_and_secondary_stores_for_duplicate_jobs) || - Feature.enabled?(:use_primary_store_as_default_for_duplicate_jobs) + Feature.enabled?(:use_primary_store_as_default_for_duplicate_jobs) # TODO: Swap for Gitlab::Redis::SharedState after store transition # https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/923 Gitlab::Redis::DuplicateJobs.with { |redis| yield redis } diff --git a/lib/gitlab/sidekiq_status.rb b/lib/gitlab/sidekiq_status.rb index 17234bdf519..778d278146d 100644 --- a/lib/gitlab/sidekiq_status.rb +++ b/lib/gitlab/sidekiq_status.rb @@ -120,7 +120,7 @@ module Gitlab def self.with_redis if Feature.enabled?(:use_primary_and_secondary_stores_for_sidekiq_status) || - Feature.enabled?(:use_primary_store_as_default_for_sidekiq_status) + Feature.enabled?(:use_primary_store_as_default_for_sidekiq_status) # TODO: Swap for Gitlab::Redis::SharedState after store transition # https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/923 Gitlab::Redis::SidekiqStatus.with { |redis| yield redis } diff --git a/lib/gitlab/x509/signature.rb b/lib/gitlab/x509/signature.rb index 6eaa623fab6..d6bbb8bb2cb 100644 --- a/lib/gitlab/x509/signature.rb +++ b/lib/gitlab/x509/signature.rb @@ -38,9 +38,9 @@ module Gitlab def verification_status return :unverified if x509_certificate.nil? || - x509_certificate.revoked? || - !verified_signature || - signed_by_user.nil? + x509_certificate.revoked? || + !verified_signature || + signed_by_user.nil? if signed_by_user.verified_emails.include?(@email.downcase) && certificate_email.casecmp?(@email) :verified diff --git a/lib/gitlab_edition.rb b/lib/gitlab_edition.rb index 5e3ed35ace4..c3e58852498 100644 --- a/lib/gitlab_edition.rb +++ b/lib/gitlab_edition.rb @@ -49,7 +49,7 @@ module GitlabEdition # The behavior needs to be synchronised with # config/helpers/is_ee_env.js root.join('ee/app/models/license.rb').exist? && - !%w[true 1].include?(ENV['FOSS_ONLY'].to_s) + !%w[true 1].include?(ENV['FOSS_ONLY'].to_s) end def self.jh? @@ -57,8 +57,8 @@ module GitlabEdition @is_jh = ee? && - root.join('jh').exist? && - !%w[true 1].include?(ENV['EE_ONLY'].to_s) + root.join('jh').exist? && + !%w[true 1].include?(ENV['EE_ONLY'].to_s) end def self.ee diff --git a/lib/kramdown/converter/commonmark.rb b/lib/kramdown/converter/commonmark.rb index 33ec9dd1fbc..a903d541d81 100644 --- a/lib/kramdown/converter/commonmark.rb +++ b/lib/kramdown/converter/commonmark.rb @@ -21,9 +21,9 @@ module Kramdown res = super if [:ul, :dl, :ol, :codeblock].include?(el.type) && opts[:next] && - ([el.type, :codeblock].include?(opts[:next].type) || - (opts[:next].type == :blank && opts[:nnext] && - [el.type, :codeblock].include?(opts[:nnext].type))) + ([el.type, :codeblock].include?(opts[:next].type) || + (opts[:next].type == :blank && opts[:nnext] && + [el.type, :codeblock].include?(opts[:nnext].type))) # replace the end of block character res.sub!(/\^\n\n\z/m, "#{END_OF_BLOCK}\n\n") end @@ -43,7 +43,7 @@ module Kramdown if el.children.first && el.children.first.type == :p && !el.children.first.options[:transparent] if el.children.size == 1 && @stack.last.children.last == el && - (@stack.last.children.any? { |c| c.children.first.type != :p } || @stack.last.children.size == 1) + (@stack.last.children.any? { |c| c.children.first.type != :p } || @stack.last.children.size == 1) # replace the end of block character res.sub!(/\^\n\z/m, "#{END_OF_BLOCK}\n") end diff --git a/lib/security/weak_passwords.rb b/lib/security/weak_passwords.rb index 42b02132933..cfdb6ae8ffa 100644 --- a/lib/security/weak_passwords.rb +++ b/lib/security/weak_passwords.rb @@ -8,6 +8,9 @@ module Security # Substrings shorter than this may appear legitimately in a truly # random password. MINIMUM_SUBSTRING_SIZE = 4 + # Passwords of this length or more are more likely to randomly + # include a forbidden substring. + PASSWORD_SUBSTRING_CHECK_MAX_LENGTH = 64 class << self # Returns true when the password is on a list of weak passwords, @@ -72,7 +75,11 @@ module Security # Case-insensitively checks whether a password includes a dynamic # list of substrings. Substrings which are too short are not # predictable and may occur randomly, and therefore not checked. + # Similarly passwords which are long enough to inadvertently and + # randomly include a substring are not checked. def contains_predicatable_substring?(password, substrings) + return unless password.length < PASSWORD_SUBSTRING_CHECK_MAX_LENGTH + substrings = substrings.filter_map do |substring| substring.downcase if substring.length >= MINIMUM_SUBSTRING_SIZE end diff --git a/lib/sidebars/groups/menus/packages_registries_menu.rb b/lib/sidebars/groups/menus/packages_registries_menu.rb index 873f11f8a5b..e115ca669d4 100644 --- a/lib/sidebars/groups/menus/packages_registries_menu.rb +++ b/lib/sidebars/groups/menus/packages_registries_menu.rb @@ -51,8 +51,8 @@ module Sidebars def harbor_registry_menu_item if Feature.disabled?(:harbor_registry_integration) || - context.group.harbor_integration.nil? || - !context.group.harbor_integration.activated? + context.group.harbor_integration.nil? || + !context.group.harbor_integration.activated? return nil_menu_item(:harbor_registry) end @@ -66,7 +66,7 @@ module Sidebars def dependency_proxy_menu_item setting_does_not_exist_or_is_enabled = !context.group.dependency_proxy_setting || - context.group.dependency_proxy_setting.enabled + context.group.dependency_proxy_setting.enabled return nil_menu_item(:dependency_proxy) unless can?(context.current_user, :read_dependency_proxy, context.group) return nil_menu_item(:dependency_proxy) unless setting_does_not_exist_or_is_enabled diff --git a/lib/sidebars/projects/menus/analytics_menu.rb b/lib/sidebars/projects/menus/analytics_menu.rb index b9bcc3267d6..643b7ebcd5a 100644 --- a/lib/sidebars/projects/menus/analytics_menu.rb +++ b/lib/sidebars/projects/menus/analytics_menu.rb @@ -45,9 +45,9 @@ module Sidebars def ci_cd_analytics_menu_item if !context.project.feature_available?(:builds, context.current_user) || - !can?(context.current_user, :read_build, context.project) || - !can?(context.current_user, :read_ci_cd_analytics, context.project) || - context.project.empty_repo? + !can?(context.current_user, :read_build, context.project) || + !can?(context.current_user, :read_ci_cd_analytics, context.project) || + context.project.empty_repo? return ::Sidebars::NilMenuItem.new(item_id: :ci_cd_analytics) end diff --git a/lib/sidebars/projects/menus/deployments_menu.rb b/lib/sidebars/projects/menus/deployments_menu.rb index 9904d533f47..5f789748288 100644 --- a/lib/sidebars/projects/menus/deployments_menu.rb +++ b/lib/sidebars/projects/menus/deployments_menu.rb @@ -62,7 +62,7 @@ module Sidebars def releases_menu_item if !can?(context.current_user, :read_release, context.project) || - context.project.empty_repo? + context.project.empty_repo? return ::Sidebars::NilMenuItem.new(item_id: :releases) end diff --git a/lib/sidebars/projects/menus/hidden_menu.rb b/lib/sidebars/projects/menus/hidden_menu.rb index b334e137679..5db46a1279c 100644 --- a/lib/sidebars/projects/menus/hidden_menu.rb +++ b/lib/sidebars/projects/menus/hidden_menu.rb @@ -30,7 +30,7 @@ module Sidebars def graph_menu_item if !can?(context.current_user, :read_code, context.project) || - context.project.empty_repo? + context.project.empty_repo? return ::Sidebars::NilMenuItem.new(item_id: :graph) end @@ -73,7 +73,7 @@ module Sidebars def commits_menu_item if !can?(context.current_user, :read_code, context.project) || - context.project.empty_repo? + context.project.empty_repo? return ::Sidebars::NilMenuItem.new(item_id: :commits) end diff --git a/qa/qa/page/component/snippet.rb b/qa/qa/page/component/snippet.rb index 47ed1a9616b..4e1c7f3e2bb 100644 --- a/qa/qa/page/component/snippet.rb +++ b/qa/qa/page/component/snippet.rb @@ -170,7 +170,7 @@ module QA # wait for the page to reload after deletion wait_until(reload: false) do has_no_element?(:delete_snippet_button) && - has_no_element?(:snippet_action_button, action: 'Delete') + has_no_element?(:snippet_action_button, action: 'Delete') end end diff --git a/qa/qa/page/profile/two_factor_auth.rb b/qa/qa/page/profile/two_factor_auth.rb index 68154ee1852..44329a64eea 100644 --- a/qa/qa/page/profile/two_factor_auth.rb +++ b/qa/qa/page/profile/two_factor_auth.rb @@ -25,7 +25,7 @@ module QA def click_configure_it_later_button # TO DO: Investigate why button does not appear sometimes: # https://gitlab.com/gitlab-org/gitlab/-/issues/382698 - return unless has_element?(:configure_it_later_button, wait: 40) + return unless has_element?(:configure_it_later_button, wait: 60) click_element :configure_it_later_button wait_until(max_duration: 10, message: "Waiting for create a group page") do diff --git a/qa/qa/runtime/api/repository_storage_moves.rb b/qa/qa/runtime/api/repository_storage_moves.rb index fb8d70c0836..450b7cd5712 100644 --- a/qa/qa/runtime/api/repository_storage_moves.rb +++ b/qa/qa/runtime/api/repository_storage_moves.rb @@ -16,7 +16,7 @@ module QA QA::Runtime::Logger.debug("Move data: #{move}") move[:state] == status && - move[:destination_storage_name] == destination_storage + move[:destination_storage_name] == destination_storage end end diff --git a/rubocop/migration_helpers.rb b/rubocop/migration_helpers.rb index 89728183367..50d7b198931 100644 --- a/rubocop/migration_helpers.rb +++ b/rubocop/migration_helpers.rb @@ -66,7 +66,7 @@ module RuboCop def array_column?(node) node.each_descendant(:pair).any? do |pair_node| pair_node.child_nodes[0].value == :array && # Searching for a (pair (sym :array) (true)) node - pair_node.child_nodes[1].type == :true # RuboCop::AST::Node uses symbols for types, even when that is a :true + pair_node.child_nodes[1].type == :true # RuboCop::AST::Node uses symbols for types, even when that is a :true end end # rubocop:enable Lint/BooleanSymbol diff --git a/spec/contracts/provider_specs/helpers/provider/contract_source_helper_spec.rb b/spec/contracts/provider_specs/helpers/provider/contract_source_helper_spec.rb index 8b5ea522641..8bb3b577135 100644 --- a/spec/contracts/provider_specs/helpers/provider/contract_source_helper_spec.rb +++ b/spec/contracts/provider_specs/helpers/provider/contract_source_helper_spec.rb @@ -71,15 +71,18 @@ RSpec.describe Provider::ContractSourceHelper, feature_category: :not_owned do describe '#local_contract_location' do it 'returns the contract file path with the prefix path for a rake task' do - rake_task_relative_path = '/gitlab/spec/contracts/contracts/project' + rake_task_relative_path = '/spec/contracts/contracts/project' - expect(subject.local_contract_location(:rake, split_pact_helper_path)).to include(rake_task_relative_path) + rake_task_path = subject.local_contract_location(:rake, split_pact_helper_path) + + expect(rake_task_path).to include(rake_task_relative_path) + expect(rake_task_path).not_to include('../') end it 'returns the contract file path with the prefix path for a spec' do - rake_task_relative_path = '../contracts/project' + spec_relative_path = '../contracts/project' - expect(subject.local_contract_location(:spec, split_pact_helper_path)).to include(rake_task_relative_path) + expect(subject.local_contract_location(:spec, split_pact_helper_path)).to include(spec_relative_path) end end diff --git a/spec/controllers/graphql_controller_spec.rb b/spec/controllers/graphql_controller_spec.rb index 081e3169c3a..fe197fcac30 100644 --- a/spec/controllers/graphql_controller_spec.rb +++ b/spec/controllers/graphql_controller_spec.rb @@ -191,7 +191,7 @@ RSpec.describe GraphqlController do expected_message = "Authentication error: " \ "enable 2FA in your profile settings to continue using GitLab: %{mfa_help_page}" % - { mfa_help_page: controller.mfa_help_page_url } + { mfa_help_page: controller.mfa_help_page_url } expect(json_response).to eq({ 'errors' => [{ 'message' => expected_message }] }) end diff --git a/spec/features/user_sees_marketing_header_spec.rb b/spec/features/user_sees_marketing_header_spec.rb deleted file mode 100644 index eae964cec02..00000000000 --- a/spec/features/user_sees_marketing_header_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -require "spec_helper" - -RSpec.describe 'User sees experimental lmarketing header' do - let_it_be(:project) { create(:project, :public) } - - context 'when not logged in' do - it 'shows marketing header links', :aggregate_failures do - visit project_path(project) - - expect(page).to have_text "About GitLab" - expect(page).to have_text "Pricing" - expect(page).to have_text "Talk to an expert" - expect(page).to have_text "Sign up now" - expect(page).to have_text "Login" - end - end - - context 'when logged in' do - it 'does not show marketing header links', :aggregate_failures do - sign_in(create(:user)) - - visit project_path(project) - - expect(page).not_to have_text "About GitLab" - expect(page).not_to have_text "Pricing" - expect(page).not_to have_text "Talk to an expert" - end - end -end diff --git a/spec/finders/clusters/agent_tokens_finder_spec.rb b/spec/finders/clusters/agent_tokens_finder_spec.rb index b03bb7d2a4a..bd0668f9a43 100644 --- a/spec/finders/clusters/agent_tokens_finder_spec.rb +++ b/spec/finders/clusters/agent_tokens_finder_spec.rb @@ -5,23 +5,39 @@ require 'spec_helper' RSpec.describe Clusters::AgentTokensFinder do describe '#execute' do let_it_be(:project) { create(:project) } + let_it_be(:agent) { create(:cluster_agent, project: project) } let(:user) { create(:user, maintainer_projects: [project]) } - let(:agent) { create(:cluster_agent, project: project) } - let!(:matching_agent_tokens) do + let_it_be(:active_agent_tokens) do [ create(:cluster_agent_token, agent: agent), + create(:cluster_agent_token, agent: agent) + ] + end + + let_it_be(:revoked_agent_tokens) do + [ + create(:cluster_agent_token, :revoked, agent: agent), create(:cluster_agent_token, :revoked, agent: agent) ] end + let_it_be(:token_for_different_agent) { create(:cluster_agent_token, agent: create(:cluster_agent)) } + subject(:execute) { described_class.new(agent, user).execute } - it 'returns the tokens of the specified agent' do - # creating a token in a different agent to make sure it will not be included in the result - create(:cluster_agent_token, agent: create(:cluster_agent)) + it { is_expected.to match_array(active_agent_tokens + revoked_agent_tokens) } + + context 'when filtering by status=active' do + subject(:execute) { described_class.new(agent, user, status: 'active').execute } + + it { is_expected.to match_array(active_agent_tokens) } + end + + context 'when filtering by status=revoked' do + subject(:execute) { described_class.new(agent, user, status: 'revoked').execute } - expect(execute).to match_array(matching_agent_tokens) + it { is_expected.to match_array(revoked_agent_tokens) } end context 'when user does not have permission' do diff --git a/spec/frontend/fixtures/tabs.rb b/spec/frontend/fixtures/tabs.rb index 697ff1c7c20..57ecb32e289 100644 --- a/spec/frontend/fixtures/tabs.rb +++ b/spec/frontend/fixtures/tabs.rb @@ -11,14 +11,14 @@ RSpec.describe 'GlTabsBehavior', '(JavaScript fixtures)', type: :helper do it 'tabs/tabs.html' do tabs = gl_tabs_nav({ data: { testid: 'tabs' } }) do gl_tab_link_to('Foo', '#foo', item_active: true, data: { testid: 'foo-tab' }) + - gl_tab_link_to('Bar', '#bar', item_active: false, data: { testid: 'bar-tab' }) + - gl_tab_link_to('Qux', '#qux', item_active: false, data: { testid: 'qux-tab' }) + gl_tab_link_to('Bar', '#bar', item_active: false, data: { testid: 'bar-tab' }) + + gl_tab_link_to('Qux', '#qux', item_active: false, data: { testid: 'qux-tab' }) end panels = content_tag(:div, class: 'tab-content') do content_tag(:div, 'Foo', { id: 'foo', class: 'tab-pane active', data: { testid: 'foo-panel' } }) + - content_tag(:div, 'Bar', { id: 'bar', class: 'tab-pane', data: { testid: 'bar-panel' } }) + - content_tag(:div, 'Qux', { id: 'qux', class: 'tab-pane', data: { testid: 'qux-panel' } }) + content_tag(:div, 'Bar', { id: 'bar', class: 'tab-pane', data: { testid: 'bar-panel' } }) + + content_tag(:div, 'Qux', { id: 'qux', class: 'tab-pane', data: { testid: 'qux-panel' } }) end @tabs = tabs + panels diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 7571ae75ab5..ac811b46c39 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -555,25 +555,15 @@ RSpec.describe ApplicationHelper do end describe '#page_class' do - let_it_be(:expected_class) { 'logged-out-marketing-header' } - - let(:current_user) { nil } - - subject do + subject(:page_class) do helper.page_class.flatten end before do - allow(helper).to receive(:current_user) { current_user } + allow(helper).to receive(:current_user).and_return(nil) end - it { is_expected.to include(expected_class) } - - context 'when a user is logged in' do - let(:current_user) { create(:user) } - - it { is_expected.not_to include(expected_class) } - end + it { is_expected.not_to include('logged-out-marketing-header') } end describe '#dispensable_render' do diff --git a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb index ee95cf4d2f8..e552b9e9c0c 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb @@ -635,12 +635,12 @@ RSpec.describe Gitlab::Ci::Pipeline::Seed::Build do context 'non-matches' do where(:keyword, :source) do - %w[web trigger schedule api external].map { |source| ['pushes', source] } + - %w[push trigger schedule api external].map { |source| ['web', source] } + - %w[push web schedule api external].map { |source| ['triggers', source] } + - %w[push web trigger api external].map { |source| ['schedules', source] } + - %w[push web trigger schedule external].map { |source| ['api', source] } + - %w[push web trigger schedule api].map { |source| ['external', source] } + %w[web trigger schedule api external].map { |source| ['pushes', source] } + + %w[push trigger schedule api external].map { |source| ['web', source] } + + %w[push web schedule api external].map { |source| ['triggers', source] } + + %w[push web trigger api external].map { |source| ['schedules', source] } + + %w[push web trigger schedule external].map { |source| ['api', source] } + + %w[push web trigger schedule api].map { |source| ['external', source] } end with_them do diff --git a/spec/lib/security/weak_passwords_spec.rb b/spec/lib/security/weak_passwords_spec.rb index 9d12c352abf..afa9448e746 100644 --- a/spec/lib/security/weak_passwords_spec.rb +++ b/spec/lib/security/weak_passwords_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Security::WeakPasswords do +RSpec.describe Security::WeakPasswords, feature_category: :authentication_and_authorization do describe "#weak_for_user?" do using RSpec::Parameterized::TableSyntax @@ -34,6 +34,7 @@ RSpec.describe Security::WeakPasswords do "!@mCwEaKy" | true "A1B2pass" | true "A1B2C3jr" | false # jr is too short + "3e18a7f60a908e329958396d68131d39e1b66a03ea420725e2a0fce7cb17pass" | false # Password is >= 64 chars # Predictable username substrings "56d4ab689a" | true diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index afa9ab81851..8628e95ba80 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -79,11 +79,11 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes let(:accepted_n_plus_ones) do 1 + # SELECT "ci_instance_variables" - 1 + # INSERT INTO "ci_stages" - 1 + # SELECT "ci_builds".* FROM "ci_builds" - 1 + # INSERT INTO "ci_builds" - 1 + # INSERT INTO "ci_builds_metadata" - 1 # SELECT "taggings".* FROM "taggings" + 1 + # INSERT INTO "ci_stages" + 1 + # SELECT "ci_builds".* FROM "ci_builds" + 1 + # INSERT INTO "ci_builds" + 1 + # INSERT INTO "ci_builds_metadata" + 1 # SELECT "taggings".* FROM "taggings" end end end diff --git a/spec/services/projects/import_export/export_service_spec.rb b/spec/services/projects/import_export/export_service_spec.rb index 285687505e9..68456c1554d 100644 --- a/spec/services/projects/import_export/export_service_spec.rb +++ b/spec/services/projects/import_export/export_service_spec.rb @@ -216,7 +216,7 @@ RSpec.describe Projects::ImportExport::ExportService do it 'fails' do expected_message = "User with ID: %s does not have required permissions for Project: %s with ID: %s" % - [another_user.id, project.name, project.id] + [another_user.id, project.name, project.id] expect { service.execute }.to raise_error(Gitlab::ImportExport::Error).with_message(expected_message) end end diff --git a/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb index a28fefcfc58..286f10a186d 100644 --- a/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb +++ b/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb @@ -28,7 +28,7 @@ RSpec.shared_examples 'finalized background migration' do |worker_class| .new .select do |scheduled| scheduled.klass == worker_class.name && - scheduled.args.first == job_class_name + scheduled.args.first == job_class_name end expect(queued.size).to eq(0) end diff --git a/spec/support/shared_examples/models/with_debian_distributions_shared_examples.rb b/spec/support/shared_examples/models/with_debian_distributions_shared_examples.rb index e86f1e77447..d6071b20dca 100644 --- a/spec/support/shared_examples/models/with_debian_distributions_shared_examples.rb +++ b/spec/support/shared_examples/models/with_debian_distributions_shared_examples.rb @@ -9,9 +9,9 @@ RSpec.shared_examples 'model with Debian distributions' do it 'removes distribution files on removal' do distribution_file_paths = distributions.map do |distribution| [distribution.file.path] + - distribution.component_files.map do |component_file| - component_file.file.path - end + distribution.component_files.map do |component_file| + component_file.file.path + end end.flatten expect { subject.destroy! } |