Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2023-06-02 09:07:27 +00:00
parent f58c22e1cd
commit 7e8ecb5c00
33 changed files with 153 additions and 260 deletions

View File

@ -10,7 +10,6 @@ import BlobCiYamlSelector from './template_selectors/ci_yaml_selector';
import DockerfileSelector from './template_selectors/dockerfile_selector';
import GitignoreSelector from './template_selectors/gitignore_selector';
import LicenseSelector from './template_selectors/license_selector';
import MetricsDashboardSelector from './template_selectors/metrics_dashboard_selector';
export default class FileTemplateMediator {
constructor({ editor, currentAction, projectId }) {
@ -30,7 +29,6 @@ export default class FileTemplateMediator {
this.templateSelectors = [
GitignoreSelector,
BlobCiYamlSelector,
MetricsDashboardSelector,
DockerfileSelector,
LicenseSelector,
].map((TemplateSelectorClass) => new TemplateSelectorClass({ mediator: this }));

View File

@ -1,29 +0,0 @@
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
import FileTemplateSelector from '../file_template_selector';
export default class MetricsDashboardSelector extends FileTemplateSelector {
constructor({ mediator }) {
super(mediator);
this.config = {
key: 'metrics-dashboard-yaml',
name: '.metrics-dashboard.yml',
pattern: /(.metrics-dashboard.yml)/,
type: 'metrics_dashboard_ymls',
dropdown: '.js-metrics-dashboard-selector',
wrapper: '.js-metrics-dashboard-selector-wrap',
};
}
initDropdown() {
initDeprecatedJQueryDropdown(this.$dropdown, {
data: this.$dropdown.data('data'),
filterable: true,
selectable: true,
search: {
fields: ['name'],
},
clicked: (options) => this.reportSelectionName(options),
text: (item) => item.name,
});
}
}

View File

@ -18,10 +18,6 @@ export const templateTypes = () => [
name: __('Dockerfile'),
key: 'dockerfiles',
},
{
name: '.metrics-dashboard.yml',
key: 'metrics_dashboard_ymls',
},
];
export const showFileTemplatesBar = (_, getters, rootState) => (name) =>

View File

@ -170,8 +170,7 @@
.license-selector,
.gitignore-selector,
.gitlab-ci-yml-selector,
.dockerfile-selector,
.metrics-dashboard-selector {
.dockerfile-selector {
display: inline-block;
vertical-align: top;
font-family: $regular_font;

View File

@ -7,7 +7,6 @@ class TemplateFinder
dockerfiles: ::Gitlab::Template::DockerfileTemplate,
gitignores: ::Gitlab::Template::GitignoreTemplate,
gitlab_ci_ymls: ::Gitlab::Template::GitlabCiYmlTemplate,
metrics_dashboard_ymls: ::Gitlab::Template::MetricsDashboardTemplate,
issues: ::Gitlab::Template::IssueTemplate,
merge_requests: ::Gitlab::Template::MergeRequestTemplate
).freeze

View File

@ -141,10 +141,6 @@ module BlobHelper
@gitlab_ci_ymls ||= TemplateFinder.all_template_names(project, :gitlab_ci_ymls)
end
def metrics_dashboard_ymls(project)
@metrics_dashboard_ymls ||= TemplateFinder.all_template_names(project, :metrics_dashboard_ymls)
end
def dockerfile_names(project)
@dockerfile_names ||= TemplateFinder.all_template_names(project, :dockerfiles)
end

View File

@ -1666,9 +1666,7 @@ class User < ApplicationRecord
DELETION_DELAY_IN_DAYS = 7.days
def delete_async(deleted_by:, params: {})
is_deleting_own_record = deleted_by.id == id
if is_deleting_own_record && ::Feature.enabled?(:delay_delete_own_user)
if should_delay_delete?(deleted_by)
new_note = format(_("User deleted own account on %{timestamp}"), timestamp: Time.zone.now)
self.note = "#{new_note}\n#{note}".strip
@ -2351,6 +2349,11 @@ class User < ApplicationRecord
ban
end
def should_delay_delete?(deleted_by)
is_deleting_own_record = deleted_by.id == id
is_deleting_own_record && ::Feature.enabled?(:delay_delete_own_user)
end
def pbkdf2?
return false unless otp_backup_codes&.any?

View File

@ -4,8 +4,6 @@
= dropdown_tag(_("Apply a template"), options: { toggle_class: 'js-license-selector', dropdown_class: 'dropdown-menu-selectable', filter: true, placeholder: "Filter", data: { data: licenses_for_select(@project), project: @project.name, fullname: @project.namespace.human_name, qa_selector: 'license_dropdown' } })
.gitignore-selector.js-gitignore-selector-wrap.js-template-selector-wrap.hidden
= dropdown_tag(_("Apply a template"), options: { toggle_class: 'js-gitignore-selector', dropdown_class: 'dropdown-menu-selectable', filter: true, placeholder: "Filter", data: { data: gitignore_names(@project), qa_selector: 'gitignore_dropdown' } })
.metrics-dashboard-selector.js-metrics-dashboard-selector-wrap.js-template-selector-wrap.hidden
= dropdown_tag(_("Apply a template"), options: { toggle_class: 'js-metrics-dashboard-selector', dropdown_class: 'dropdown-menu-selectable', filter: true, placeholder: "Filter", data: { data: metrics_dashboard_ymls(@project), qa_selector: 'metrics_dashboard_dropdown' } })
#gitlab-ci-yml-selector.gitlab-ci-yml-selector.js-gitlab-ci-yml-selector-wrap.js-template-selector-wrap.hidden
= dropdown_tag(_("Apply a template"), options: { toggle_class: 'js-gitlab-ci-yml-selector', dropdown_class: 'dropdown-menu-selectable', filter: true, placeholder: "Filter", data: { data: gitlab_ci_ymls(@project), selected: params[:template], qa_selector: 'gitlab_ci_yml_dropdown' } })
.dockerfile-selector.js-dockerfile-selector-wrap.js-template-selector-wrap.hidden

View File

@ -70,6 +70,9 @@ JWT provides you with a secret key for you to use.
For more information on each configuration option refer to
the [OmniAuth JWT usage documentation](https://github.com/mbleigh/omniauth-jwt#usage).
WARNING:
Incorrectly configuring these settings can result in an insecure instance.
1. Change `YOUR_APP_SECRET` to the client secret and set `auth_url` to your redirect URL.
1. Save the configuration file.
1. For the changes to take effect:

View File

@ -199,7 +199,8 @@ This list of limitations only reflects the latest version of GitLab. If you are
- [Pages access control](../../user/project/pages/pages_access_control.md) doesn't work on secondaries. See [GitLab issue #9336](https://gitlab.com/gitlab-org/gitlab/-/issues/9336) for details.
- [GitLab chart with Geo](https://docs.gitlab.com/charts/advanced/geo/) does not support [Unified URLs](secondary_proxy/index.md#set-up-a-unified-url-for-geo-sites). See [GitLab issue #3522](https://gitlab.com/gitlab-org/charts/gitlab/-/issues/3522) for more details.
- [Disaster recovery](disaster_recovery/index.md) for multi-secondary sites causes downtime due to the complete re-synchronization and re-configuration of all non-promoted secondaries.
- For Git over SSH, secondary sites must use the same port as the primary. [GitLab issue #339262](https://gitlab.com/gitlab-org/gitlab/-/issues/339262) proposes to remove this limitation.
- For Git over SSH, to make the project clone URL display correctly regardless of which site you are browsing, secondary sites must use the same port as the primary. [GitLab issue #339262](https://gitlab.com/gitlab-org/gitlab/-/issues/339262) proposes to remove this limitation.
- Git push over SSH against a secondary site does not work for pushes over 1.86 GB. [GitLab issue #413109](https://gitlab.com/gitlab-org/gitlab/-/issues/413109) tracks this bug.
### Limitations on replication/verification
@ -275,7 +276,7 @@ For information on configuring Geo for multiple nodes, see [Geo for multiple ser
### Configuring Geo with Object Storage
For information on configuring Geo with object storage, see [Geo with Object storage](replication/object_storage.md).
For information on configuring Geo with Object storage, see [Geo with Object storage](replication/object_storage.md).
### Disaster Recovery

View File

@ -9,7 +9,7 @@ type: howto
Geo can be used in combination with Object Storage (AWS S3, or other compatible object storage).
Currently, **secondary** sites can use either:
**Secondary** sites can use one of the following:
- The same storage bucket as the **primary** site.
- A replicated storage bucket.

View File

@ -18,8 +18,8 @@ type: howto
- Ensure the **primary** site has a [GitLab Premium or Ultimate](https://about.gitlab.com/pricing/) subscription to unlock Geo. You only need one license for all the sites.
- Confirm the [requirements for running Geo](../index.md#requirements-for-running-geo) are met by all sites. For example, sites must use the same GitLab version, and sites must be able to communicate with each other over certain ports.
- Confirm the **primary** and **secondary** site storage configurations match. If the primary Geo site uses object storage, the secondary Geo site must use it too. See [Geo with Object storage] (../replication/object_storage.md) for more details.
- Ensure clocks are synchronized between the **primary** site and the **secondary** site. Synchronized clocks are required for Geo to function correctly. For example, if the clock drift between the **primary** and **secondary** sites exceeds 1 minute, replication will fail.
- Confirm the **primary** and **secondary** site storage configurations match. If the primary Geo site uses object storage, the secondary Geo site must use it too. For more information, see [Geo with Object storage](../replication/object_storage.md).
- Ensure clocks are synchronized between the **primary** site and the **secondary** site. Synchronized clocks are required for Geo to function correctly. For example, if the clock drift between the **primary** and **secondary** sites exceeds 1 minute, replication fails.
## Using Omnibus GitLab

View File

@ -1269,6 +1269,32 @@ Example response:
]
```
## Service Accounts **(PREMIUM)**
### Create Service Account User
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/407775) in GitLab 16.1.
Creates a service account user with an auto-generated email address and username.
```plaintext
POST /groups/:id/service_accounts
```
```shell
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/345/service_accounts"
```
Example response:
```json
{
"id": 57,
"username": "service_account_group_345_6018816a18e515214e0c34c2b33523fc",
"name": "Service account user"
}
```
## Hooks **(PREMIUM)**
Also called Group Hooks and Webhooks.

View File

@ -992,6 +992,20 @@ Example response:
}
```
## Create Service Account User **(PREMIUM)**
> Ability to create a service account user was [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/406782) in GitLab 16.1
Creates a service account user with an auto-generated email address and username.
```plaintext
POST /service_accounts
```
```shell
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/service_accounts"
```
## List user projects
See the [list of user projects](projects.md#list-user-projects).

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -128,6 +128,10 @@ The token generated when you create an agent for Kubernetes. Use **agent access
- secret token
- authentication token
## AI, artificial intelligence
Use **AI**. Do not spell out **artificial intelligence**.
## air gap, air-gapped
Use **offline environment** to describe installations that have physical barriers or security policies that prevent or limit internet access. Do not use **air gap**, **air gapped**, or **air-gapped**. For example:

View File

@ -43,7 +43,6 @@ are supported:
| `.gitignore` | `gitignore` | `.gitignore` |
| `.gitlab-ci.yml` | `gitlab-ci` | `.yml` |
| `LICENSE` | `LICENSE` | `.txt` |
| `metrics-dashboard.yml` | `metrics-dashboards` | `.yml` |
Each template must go in its respective subdirectory, have the correct
extension and not be empty. So, the hierarchy should look like this:
@ -62,9 +61,6 @@ extension and not be empty. So, the hierarchy should look like this:
|-- LICENSE
|-- custom_license.txt
|-- another_license.txt
|-- metrics-dashboards
|-- custom_metrics-dashboard.yml
|-- another_metrics-dashboard.yml
```
Your custom templates are displayed on the dropdown list when a new file is added through the GitLab UI:

View File

@ -2606,14 +2606,6 @@ deploy-test-target:
- environment_url.txt
```
<!--
### Target Container
The API Fuzzing template supports launching a docker container containing an API target using docker-in-docker.
TODO
-->
### Use OpenAPI with an invalid schema
There are cases where the document is autogenerated with an invalid schema or cannot be edited manually in a timely manner. In those scenarios, the API Fuzzing is able to perform a relaxed validation by setting the variable `FUZZAPI_OPENAPI_RELAXED_VALIDATION`. We recommend providing a fully compliant OpenAPI document to prevent unexpected behaviors.

View File

@ -107,7 +107,8 @@ Secret Detection can detect if a secret was added in one commit and removed in a
In a merge request, Secret Detection scans every commit made on the source branch. To use this
feature, you must use the [`latest` Secret Detection template](#templates), as it supports
[merge request pipelines](../../../ci/pipelines/merge_request_pipelines.md).
[merge request pipelines](../../../ci/pipelines/merge_request_pipelines.md). Secret Detection's
results are only available after the pipeline is completed.
## Templates
@ -116,7 +117,7 @@ provided with GitLab upgrades, allowing you to benefit from any improvements and
Available templates:
- [`Secret-Detection.gitlab-ci.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Jobs/Secret-Detection.gitlab-ci.yml): Stable version of the Secret Detection CI/CD template.
- [`Secret-Detection.gitlab-ci.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Jobs/Secret-Detection.gitlab-ci.yml): Stable, default version of the Secret Detection CI/CD template.
- [`Secret-Detection.latest.gitlab-ci.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Jobs/Secret-Detection.latest.gitlab-ci.yml): Latest version of the Secret Detection template.
WARNING:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 KiB

After

Width:  |  Height:  |  Size: 118 KiB

View File

@ -225,12 +225,12 @@ If you are receiving `HTTP 500: Internal Server Error` responses when publishing
# Consolidated Object Storage settings
gitlab_rails['object_store']['connection'] = {
# Other connection settings
`aws_signature_version` => '4'
'aws_signature_version' => '4'
}
# OR
# Storage-specific form settings
gitlab_rails['packages_object_store_connection'] = {
# Other connection settings
`aws_signature_version` => '4'
'aws_signature_version' => '4'
}
```

View File

@ -142,9 +142,12 @@ module API
@base_model ||= Gitlab::Database.database_base_models[database]
end
# Force progress evaluation to occur now while we're using the right connection
def present_entity(result)
present result,
with: ::API::Entities::BatchedBackgroundMigration
representation = entity_representation_for(::API::Entities::BatchedBackgroundMigration, result, {})
json_representation = Gitlab::Json.dump(representation)
body Gitlab::Json::PrecompiledJson.new(json_representation)
end
end
end

View File

@ -4,7 +4,7 @@ module API
class ProjectTemplates < ::API::Base
include PaginationParams
TEMPLATE_TYPES = %w[dockerfiles gitignores gitlab_ci_ymls licenses metrics_dashboard_ymls issues merge_requests].freeze
TEMPLATE_TYPES = %w[dockerfiles gitignores gitlab_ci_ymls licenses issues merge_requests].freeze
# The regex is needed to ensure a period (e.g. agpl-3.0)
# isn't confused with a format type. We also need to allow encoded
# values (e.g. C%2B%2B for C++), so allow % and + as well.
@ -16,7 +16,7 @@ module API
params do
requires :id, types: [String, Integer], desc: 'The ID or URL-encoded path of the project'
requires :type, type: String, values: TEMPLATE_TYPES, desc: 'The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses|metrics_dashboard_ymls|issues|merge_requests) of the template'
requires :type, type: String, values: TEMPLATE_TYPES, desc: 'The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses|issues|merge_requests) of the template'
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Get a list of templates available to this project' do
@ -32,8 +32,6 @@ module API
use :pagination
end
get ':id/templates/:type' do
bad_request! if params[:type] == 'metrics_dashboard_ymls' && Feature.enabled?(:remove_monitor_metrics)
templates = TemplateFinder.all_template_names(user_project, params[:type]).values.flatten
present paginate(::Kaminari.paginate_array(templates)), with: Entities::TemplatesList
@ -62,8 +60,6 @@ module API
end
get ':id/templates/:type/:name', requirements: TEMPLATE_NAMES_ENDPOINT_REQUIREMENTS do
bad_request! if params[:type] == 'metrics_dashboard_ymls' && Feature.enabled?(:remove_monitor_metrics)
begin
template = TemplateFinder.build(
params[:type],

View File

@ -18,6 +18,7 @@ module Gitlab
end
end
end
alias_method :each_db_connection, :each_database_connection
def each_model_connection(models, only_on: nil, &blk)
selected_databases = Array.wrap(only_on).map(&:to_sym)

View File

@ -40,7 +40,7 @@ module Gitlab
next if model < ::Gitlab::Database::SharedModel && !(model < TableWithoutModel)
model_connection_name = model.connection_db_config.name
Gitlab::Database::EachDatabase.each_database_connection do |connection, connection_name|
Gitlab::Database::EachDatabase.each_db_connection(include_shared: false) do |connection, connection_name|
if connection_name != model_connection_name
PartitionManager.new(model, connection: connection).sync_partitions
end

View File

@ -1110,6 +1110,30 @@ msgstr ""
msgid "%{start} to %{end}"
msgstr ""
msgid "%{statusStart}Dismissed%{statusEnd}"
msgstr ""
msgid "%{statusStart}Dismissed%{statusEnd} at %{projectLink}"
msgstr ""
msgid "%{statusStart}Dismissed%{statusEnd} on pipeline %{pipelineLink}"
msgstr ""
msgid "%{statusStart}Dismissed%{statusEnd} on pipeline %{pipelineLink} at %{projectLink}"
msgstr ""
msgid "%{statusStart}Dismissed%{statusEnd}: %{dismissalReason}"
msgstr ""
msgid "%{statusStart}Dismissed%{statusEnd}: %{dismissalReason} at %{projectLink}"
msgstr ""
msgid "%{statusStart}Dismissed%{statusEnd}: %{dismissalReason} on pipeline %{pipelineLink}"
msgstr ""
msgid "%{statusStart}Dismissed%{statusEnd}: %{dismissalReason} on pipeline %{pipelineLink} at %{projectLink}"
msgstr ""
msgid "%{strongOpen}Warning:%{strongClose} SAML group links can cause GitLab to automatically remove members from groups."
msgstr ""
@ -16095,15 +16119,6 @@ msgstr ""
msgid "Dismissed"
msgstr ""
msgid "Dismissed at %{projectLink}"
msgstr ""
msgid "Dismissed on pipeline %{pipelineLink}"
msgstr ""
msgid "Dismissed on pipeline %{pipelineLink} at %{projectLink}"
msgstr ""
msgid "Display"
msgstr ""

View File

@ -20,7 +20,6 @@ RSpec.describe TemplateFinder do
:dockerfiles | 'Binary'
:gitignores | 'Actionscript'
:gitlab_ci_ymls | 'Android'
:metrics_dashboard_ymls | 'Default'
end
with_them do
@ -112,7 +111,6 @@ RSpec.describe TemplateFinder do
:gitignores | described_class
:gitlab_ci_ymls | described_class
:licenses | ::LicenseTemplateFinder
:metrics_dashboard_ymls | described_class
:issues | described_class
:merge_requests | described_class
end
@ -123,16 +121,6 @@ RSpec.describe TemplateFinder do
it { is_expected.to be_a(expected_class) }
it { expect(finder.project).to eq(project) }
end
context 'when metrics dashboard is unavailable' do
before do
stub_feature_flags(remove_monitor_metrics: true)
end
subject(:finder) { described_class.build(:metrics_dashboard_ymls, project) }
it { is_expected.to be_nil }
end
end
describe '#execute' do
@ -178,7 +166,6 @@ RSpec.describe TemplateFinder do
:dockerfiles | 'Binary'
:gitignores | 'Actionscript'
:gitlab_ci_ymls | 'Android'
:metrics_dashboard_ymls | 'Default'
end
with_them do

View File

@ -5,7 +5,7 @@ import createState from '~/ide/stores/state';
describe('IDE file templates getters', () => {
describe('templateTypes', () => {
it('returns list of template types', () => {
expect(getters.templateTypes().length).toBe(5);
expect(getters.templateTypes().length).toBe(4);
});
});

View File

@ -60,14 +60,8 @@ describe('Job table app', () => {
handler = successHandler,
countHandler = countSuccessHandler,
mountFn = shallowMount,
data = {},
} = {}) => {
wrapper = mountFn(JobsTableApp, {
data() {
return {
...data,
};
},
provide: {
fullPath: projectPath,
},
@ -108,34 +102,28 @@ describe('Job table app', () => {
});
it('should refetch jobs query on fetchJobsByStatus event', async () => {
jest.spyOn(wrapper.vm.$apollo.queries.jobs, 'refetch').mockImplementation(jest.fn());
expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(0);
expect(successHandler).toHaveBeenCalledTimes(1);
await findTabs().vm.$emit('fetchJobsByStatus');
expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(1);
expect(successHandler).toHaveBeenCalledTimes(2);
});
it('avoids refetch jobs query when scope has not changed', async () => {
jest.spyOn(wrapper.vm.$apollo.queries.jobs, 'refetch').mockImplementation(jest.fn());
expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(0);
expect(successHandler).toHaveBeenCalledTimes(1);
await findTabs().vm.$emit('fetchJobsByStatus', null);
expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(0);
expect(successHandler).toHaveBeenCalledTimes(1);
});
it('should refetch jobs count query when the amount jobs and count do not match', async () => {
jest.spyOn(wrapper.vm.$apollo.queries.jobsCount, 'refetch').mockImplementation(jest.fn());
expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(0);
expect(countSuccessHandler).toHaveBeenCalledTimes(1);
// after applying filter a new count is fetched
findFilteredSearch().vm.$emit('filterJobsBySearch', [mockFailedSearchToken]);
expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(1);
expect(countSuccessHandler).toHaveBeenCalledTimes(2);
// tab is switched to `finished`, no count
await findTabs().vm.$emit('fetchJobsByStatus', ['FAILED', 'SUCCESS', 'CANCELED']);
@ -143,7 +131,7 @@ describe('Job table app', () => {
// tab is switched back to `all`, the old filter count has to be overwritten with new count
await findTabs().vm.$emit('fetchJobsByStatus', null);
expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(2);
expect(countSuccessHandler).toHaveBeenCalledTimes(3);
});
describe('when infinite scrolling is triggered', () => {
@ -261,25 +249,21 @@ describe('Job table app', () => {
it('refetches jobs query when filtering', async () => {
createComponent();
jest.spyOn(wrapper.vm.$apollo.queries.jobs, 'refetch').mockImplementation(jest.fn());
expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(0);
expect(successHandler).toHaveBeenCalledTimes(1);
await findFilteredSearch().vm.$emit('filterJobsBySearch', [mockFailedSearchToken]);
expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(1);
expect(successHandler).toHaveBeenCalledTimes(2);
});
it('refetches jobs count query when filtering', async () => {
createComponent();
jest.spyOn(wrapper.vm.$apollo.queries.jobsCount, 'refetch').mockImplementation(jest.fn());
expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(0);
expect(countSuccessHandler).toHaveBeenCalledTimes(1);
await findFilteredSearch().vm.$emit('filterJobsBySearch', [mockFailedSearchToken]);
expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(1);
expect(countSuccessHandler).toHaveBeenCalledTimes(2);
});
it('shows raw text warning when user inputs raw text', async () => {
@ -292,14 +276,14 @@ describe('Job table app', () => {
createComponent();
jest.spyOn(wrapper.vm.$apollo.queries.jobs, 'refetch').mockImplementation(jest.fn());
jest.spyOn(wrapper.vm.$apollo.queries.jobsCount, 'refetch').mockImplementation(jest.fn());
expect(successHandler).toHaveBeenCalledTimes(1);
expect(countSuccessHandler).toHaveBeenCalledTimes(1);
await findFilteredSearch().vm.$emit('filterJobsBySearch', ['raw text']);
expect(createAlert).toHaveBeenCalledWith(expectedWarning);
expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(0);
expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(0);
expect(successHandler).toHaveBeenCalledTimes(1);
expect(countSuccessHandler).toHaveBeenCalledTimes(1);
});
it('updates URL query string when filtering jobs by status', async () => {

View File

@ -112,6 +112,24 @@ RSpec.describe Gitlab::Database::Partitioning, feature_category: :database do
end
end
context 'without ci database' do
it 'only creates partitions for main database' do
skip_if_database_exists(:ci)
allow(Gitlab::Database::Partitioning::PartitionManager).to receive(:new).and_call_original
# Also, in the case where `ci` database is shared with `main` database,
# check that we do not run PartitionManager again for ci connection as
# that is redundant.
expect(Gitlab::Database::Partitioning::PartitionManager).not_to receive(:new)
.with(anything, connection: ci_connection).and_call_original
expect { described_class.sync_partitions(models) }
.to change { find_partitions(table_names.first, conn: main_connection).size }.from(0)
.and change { find_partitions(table_names.last, conn: main_connection).size }.from(0)
end
end
context 'when no partitioned models are given' do
it 'manages partitions for each registered model' do
described_class.register_models([models.first])

View File

@ -50,6 +50,27 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations, feature_category: :datab
show_migration
end
context 'when migration has completed jobs' do
let(:migration) do
Gitlab::Database::SharedModel.using_connection(ci_model.connection) do
create(:batched_background_migration, :active, total_tuple_count: 100)
end
end
let!(:batched_job) do
Gitlab::Database::SharedModel.using_connection(ci_model.connection) do
create(:batched_background_migration_job, :succeeded, batched_migration: migration, batch_size: 8)
end
end
it 'calculates the progress using the CI database' do
show_migration
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['progress']).to eq(8)
end
end
end
context 'when the database name does not exist' do

View File

@ -63,27 +63,6 @@ RSpec.describe API::ProjectTemplates, feature_category: :source_code_management
expect(json_response).to satisfy_one { |template| template['key'] == 'mit' }
end
it 'returns metrics_dashboard_ymls' do
get api("/projects/#{public_project.id}/templates/metrics_dashboard_ymls")
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(response).to match_response_schema('public_api/v4/template_list')
expect(json_response).to satisfy_one { |template| template['key'] == 'Default' }
end
context 'when metrics dashboard feature is unavailable' do
before do
stub_feature_flags(remove_monitor_metrics: true)
end
it 'returns 400 bad request like other unknown types' do
get api("/projects/#{public_project.id}/templates/metrics_dashboard_ymls")
expect(response).to have_gitlab_http_status(:bad_request)
end
end
it 'returns issue templates' do
get api("/projects/#{private_project.id}/templates/issues", developer)
@ -176,26 +155,6 @@ RSpec.describe API::ProjectTemplates, feature_category: :source_code_management
expect(json_response['name']).to eq('Android')
end
it 'returns a specific metrics_dashboard_yml' do
get api("/projects/#{public_project.id}/templates/metrics_dashboard_ymls/Default")
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/template')
expect(json_response['name']).to eq('Default')
end
context 'when metrics dashboard feature is unavailable' do
before do
stub_feature_flags(remove_monitor_metrics: true)
end
it 'returns 400 bad request like other unknown types' do
get api("/projects/#{public_project.id}/templates/metrics_dashboard_ymls/Default")
expect(response).to have_gitlab_http_status(:bad_request)
end
end
it 'returns a specific license' do
get api("/projects/#{public_project.id}/templates/licenses/mit")
@ -256,10 +215,6 @@ RSpec.describe API::ProjectTemplates, feature_category: :source_code_management
subject { get api("/projects/#{url_encoded_path}/templates/gitlab_ci_ymls/Android") }
end
it_behaves_like 'accepts project paths with dots' do
subject { get api("/projects/#{url_encoded_path}/templates/metrics_dashboard_ymls/Default") }
end
shared_examples 'path traversal attempt' do |template_type|
it 'rejects invalid filenames' do
get api("/projects/#{public_project.id}/templates/#{template_type}/%2e%2e%2fPython%2ea")

View File

@ -53,82 +53,6 @@ RSpec.describe Submodules::UpdateService, feature_category: :source_code_managem
end
context 'validations' do
context 'when submodule' do
context 'is empty' do
let(:submodule) { '' }
it_behaves_like 'returns error result' do
let(:error_message) { 'Invalid parameters' }
end
end
context 'is not present' do
let(:submodule) { nil }
it_behaves_like 'returns error result' do
let(:error_message) { 'Invalid parameters' }
end
end
context 'is invalid' do
let(:submodule) { 'VERSION' }
it_behaves_like 'returns error result' do
let(:error_message) { 'Invalid submodule path' }
end
end
context 'does not exist' do
let(:submodule) { 'non-existent-submodule' }
it_behaves_like 'returns error result' do
let(:error_message) { 'Invalid submodule path' }
end
end
context 'has traversal path' do
let(:submodule) { '../six' }
it_behaves_like 'returns error result' do
let(:error_message) { 'Invalid submodule path' }
end
end
end
context 'commit_sha' do
context 'is empty' do
let(:commit_sha) { '' }
it_behaves_like 'returns error result' do
let(:error_message) { 'Invalid parameters' }
end
end
context 'is not present' do
let(:commit_sha) { nil }
it_behaves_like 'returns error result' do
let(:error_message) { 'Invalid parameters' }
end
end
context 'is invalid' do
let(:commit_sha) { '1' }
it_behaves_like 'returns error result' do
let(:error_message) { 'Invalid parameters' }
end
end
context 'is the same as the current ref' do
let(:commit_sha) { current_sha }
it_behaves_like 'returns error result' do
let(:error_message) { "The submodule #{submodule} is already at #{commit_sha}" }
end
end
end
context 'branch_name' do
context 'is empty' do
let(:branch_name) { '' }
@ -138,14 +62,6 @@ RSpec.describe Submodules::UpdateService, feature_category: :source_code_managem
end
end
context 'is not present' do
let(:branch_name) { nil }
it_behaves_like 'returns error result' do
let(:error_message) { 'Invalid parameters' }
end
end
context 'does not exist' do
let(:branch_name) { 'non/existent-branch' }