Skip to content
Snippets Groups Projects
Commit 22e9af3c authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent c8e28a0b
No related branches found
No related tags found
No related merge requests found
Showing
with 478 additions and 175 deletions
Loading
@@ -91,7 +91,7 @@ Below we assume that you have administrative access as the `postgres`
Loading
@@ -91,7 +91,7 @@ Below we assume that you have administrative access as the `postgres`
user. First open a `psql` session as the `postgres` user: user. First open a `psql` session as the `postgres` user:
   
```shell ```shell
psql -h POSTGRESQL_SERVER -U postgres -d template1 /opt/gitlab/embedded/bin/psql -h POSTGRESQL_SERVER -U postgres -d template1
``` ```
   
Once you are connected, run the following command. Replace Once you are connected, run the following command. Replace
Loading
@@ -100,21 +100,21 @@ generated for the `praefect` SQL user:
Loading
@@ -100,21 +100,21 @@ generated for the `praefect` SQL user:
   
```sql ```sql
CREATE ROLE praefect WITH LOGIN CREATEDB PASSWORD 'PRAEFECT_SQL_PASSWORD'; CREATE ROLE praefect WITH LOGIN CREATEDB PASSWORD 'PRAEFECT_SQL_PASSWORD';
\q # exit psql \q
``` ```
   
Now connect as the `praefect` user to create the database. This has Now connect as the `praefect` user to create the database. This has
the side effect of verifying that you have access: the side effect of verifying that you have access:
   
```shell ```shell
psql -h POSTGRESQL_SERVER -U praefect -d template1 /opt/gitlab/embedded/bin/psql -h POSTGRESQL_SERVER -U praefect -d template1
``` ```
   
Once you have connected as the `praefect` user, run: Once you have connected as the `praefect` user, run:
   
```sql ```sql
CREATE DATABASE praefect_production WITH ENCODING=UTF8; CREATE DATABASE praefect_production WITH ENCODING=UTF8;
\q # quit psql \q
``` ```
   
#### Praefect #### Praefect
Loading
@@ -260,9 +260,17 @@ git_data_dirs({
Loading
@@ -260,9 +260,17 @@ git_data_dirs({
   
For more information on Gitaly server configuration, see our [Gitaly documentation](index.md#3-gitaly-server-configuration). For more information on Gitaly server configuration, see our [Gitaly documentation](index.md#3-gitaly-server-configuration).
   
When finished editing the configuration file for each Gitaly server, run the
reconfigure command to put changes into effect:
```shell
sudo gitlab-ctl reconfigure
```
When all Gitaly servers are configured, you can run the Praefect connection When all Gitaly servers are configured, you can run the Praefect connection
checker to verify Praefect can connect to all Gitaly servers in the Praefect checker to verify Praefect can connect to all Gitaly servers in the Praefect
config: config. This can be done by running the following command on the Praefect
server:
   
```shell ```shell
sudo /opt/gitlab/embedded/bin/praefect -config /var/opt/gitlab/praefect/config.toml dial-nodes sudo /opt/gitlab/embedded/bin/praefect -config /var/opt/gitlab/praefect/config.toml dial-nodes
Loading
Loading
Loading
@@ -396,3 +396,93 @@ export default () => {};
Loading
@@ -396,3 +396,93 @@ export default () => {};
``` ```
   
[vuex-docs]: https://vuex.vuejs.org [vuex-docs]: https://vuex.vuejs.org
### Two way data binding
When storing form data in Vuex, it is sometimes necessary to update the value stored. The store should never be mutated directly, and an action should be used instead.
In order to still use `v-model` in our code, we need to create computed properties in this form:
```javascript
export default {
computed: {
someValue: {
get() {
return this.$store.state.someValue;
},
set(value) {
this.$store.dispatch("setSomeValue", value);
}
}
}
};
```
An alternative is to use `mapState` and `mapActions`:
```javascript
export default {
computed: {
...mapState(['someValue']),
localSomeValue: {
get() {
return this.someValue;
},
set(value) {
this.setSomeValue(value)
}
}
},
methods: {
...mapActions(['setSomeValue'])
}
};
```
Adding a few of these properties becomes cumbersome, and makes the code more repetitive with more tests to write. To simplify this there is a helper in `~/vuex_shared/bindings.js`
The helper can be used like so:
```javascript
// this store is non-functional and only used to give context to the example
export default {
state: {
baz: '',
bar: '',
foo: ''
},
actions: {
updateBar() {...}
updateAll() {...}
},
getters: {
getFoo() {...}
}
}
```
```javascript
import { mapComputed } from '~/vuex_shared/bindings'
export default {
computed: {
/**
* @param {(string[]|Object[])} list - list of string matching state keys or list objects
* @param {string} list[].key - the key matching the key present in the vuex state
* @param {string} list[].getter - the name of the getter, leave it empty to not use a getter
* @param {string} list[].updateFn - the name of the action, leave it empty to use the default action
* @param {string} defaultUpdateFn - the default function to dispatch
* @param {string} root - optional key of the state where to search fo they keys described in list
* @returns {Object} a dictionary with all the computed properties generated
*/
...mapComputed(
[
'baz',
{ key: 'bar', updateFn: 'updateBar' }
{ key: 'foo', getter: 'getFoo' },
],
'updateAll',
),
}
}
```
`mapComputed` will then generate the appropriate computed properties that get the data from the store and dispatch the correct action when updated.
Loading
@@ -532,20 +532,24 @@ This is especially useful whenever it's showing 500 internal server error.
Loading
@@ -532,20 +532,24 @@ This is especially useful whenever it's showing 500 internal server error.
   
### Shared contexts ### Shared contexts
   
All shared contexts should be placed under `spec/support/shared_contexts/`. Shared contexts only used in one spec file can be declared inline.
Shared contexts can be placed in subfolder if they apply to a certain type of Any shared contexts used by more than one spec file:
specs only (e.g. features, requests etc.) but shouldn't be if they apply to
multiple type of specs. - Should be placed under `spec/support/shared_contexts/`.
- Can be placed in subfolder if they apply to a certain type of specs only
(e.g. features, requests etc.) but shouldn't be if they apply to multiple type of specs.
   
Each file should include only one context and have a descriptive name, e.g. Each file should include only one context and have a descriptive name, e.g.
`spec/support/shared_contexts/controllers/githubish_import_controller_shared_context.rb`. `spec/support/shared_contexts/controllers/githubish_import_controller_shared_context.rb`.
   
### Shared examples ### Shared examples
   
All shared examples should be placed under `spec/support/shared_examples/`. Shared examples only used in one spec file can be declared inline.
Shared examples can be placed in subfolder if they apply to a certain type of Any shared examples used by more than one spec file:
specs only (e.g. features, requests etc.) but shouldn't be if they apply to
multiple type of specs. - Should be placed under `spec/support/shared_examples/`.
- Can be placed in subfolder if they apply to a certain type of specs only
(e.g. features, requests etc.) but shouldn't be if they apply to multiple type of specs.
   
Each file should include only one context and have a descriptive name, e.g. Each file should include only one context and have a descriptive name, e.g.
`spec/support/shared_examples/controllers/githubish_import_controller_shared_example.rb`. `spec/support/shared_examples/controllers/githubish_import_controller_shared_example.rb`.
Loading
Loading
Loading
@@ -40,7 +40,7 @@ The various scanning tools and the vulnerabilities database are updated regularl
Loading
@@ -40,7 +40,7 @@ The various scanning tools and the vulnerabilities database are updated regularl
|:-------------------------------------------------------------|-------------------------------------------| |:-------------------------------------------------------------|-------------------------------------------|
| [Container Scanning](container_scanning/index.md) | Uses `clair` underneath and the latest `clair-db` version is used for each job run by running the [`latest` docker image tag](https://gitlab.com/gitlab-org/gitlab/blob/438a0a56dc0882f22bdd82e700554525f552d91b/lib/gitlab/ci/templates/Security/Container-Scanning.gitlab-ci.yml#L37). The `clair-db` database [is updated daily according to the author](https://github.com/arminc/clair-local-scan#clair-server-or-local). | | [Container Scanning](container_scanning/index.md) | Uses `clair` underneath and the latest `clair-db` version is used for each job run by running the [`latest` docker image tag](https://gitlab.com/gitlab-org/gitlab/blob/438a0a56dc0882f22bdd82e700554525f552d91b/lib/gitlab/ci/templates/Security/Container-Scanning.gitlab-ci.yml#L37). The `clair-db` database [is updated daily according to the author](https://github.com/arminc/clair-local-scan#clair-server-or-local). |
| [Dependency Scanning](dependency_scanning/index.md) | Relies on `bundler-audit` (for Rubygems), `retire.js` (for NPM packages) and `gemnasium` (GitLab's own tool for all libraries). `bundler-audit` and `retire.js` both fetch their vulnerabilities data from GitHub repositories, so vulnerabilities added to `ruby-advisory-db` and `retire.js` are immediately available. The tools themselves are updated once per month if there's a new version. The [Gemnasium DB](https://gitlab.com/gitlab-org/security-products/gemnasium-db) is updated at least once a week. | | [Dependency Scanning](dependency_scanning/index.md) | Relies on `bundler-audit` (for Rubygems), `retire.js` (for NPM packages) and `gemnasium` (GitLab's own tool for all libraries). `bundler-audit` and `retire.js` both fetch their vulnerabilities data from GitHub repositories, so vulnerabilities added to `ruby-advisory-db` and `retire.js` are immediately available. The tools themselves are updated once per month if there's a new version. The [Gemnasium DB](https://gitlab.com/gitlab-org/security-products/gemnasium-db) is updated at least once a week. |
| [Dynamic Application Security Testing (DAST)](dast/index.md) | Updated weekly on Sundays. The underlying tool, `zaproxy`, downloads fresh rules at startup. | | [Dynamic Application Security Testing (DAST)](dast/index.md) | The scanning engine is updated on a periodic basis. See the [version of the underlying tool `zaproxy`](https://gitlab.com/gitlab-org/security-products/dast/blob/master/Dockerfile#L1). The scanning rules are downloaded at the runtime of the scan. |
| [Static Application Security Testing (SAST)](sast/index.md) | Relies exclusively on [the tools GitLab is wrapping](sast/index.md#supported-languages-and-frameworks). The underlying analyzers are updated at least once per month if a relevant update is available. The vulnerabilities database is updated by the upstream tools. | | [Static Application Security Testing (SAST)](sast/index.md) | Relies exclusively on [the tools GitLab is wrapping](sast/index.md#supported-languages-and-frameworks). The underlying analyzers are updated at least once per month if a relevant update is available. The vulnerabilities database is updated by the upstream tools. |
   
You don't have to update GitLab to benefit from the latest vulnerabilities definitions, You don't have to update GitLab to benefit from the latest vulnerabilities definitions,
Loading
Loading
Loading
@@ -28,52 +28,87 @@ You should then be able to see the **Packages** section on the left sidebar.
Loading
@@ -28,52 +28,87 @@ You should then be able to see the **Packages** section on the left sidebar.
Before proceeding to authenticating with the GitLab NPM Registry, you should Before proceeding to authenticating with the GitLab NPM Registry, you should
get familiar with the package naming convention. get familiar with the package naming convention.
   
## Package naming convention ## Getting started
   
**Packages must be scoped in the root namespace of the project**. The package This section will cover installing NPM (or Yarn) and building a package for your
name may be anything but it is preferred that the project name be used unless JavaScript project. This is a quickstart if you are new to NPM packages. If you
it is not possible due to a naming collision. For example: are already using NPM and understand how to build your own packages, move on to
the [next section](#authenticating-to-the-gitlab-npm-registry).
   
| Project | Package | Supported | ### Installing NPM
| ---------------------- | ----------------------- | --------- |
| `foo/bar` | `@foo/bar` | Yes |
| `foo/bar/baz` | `@foo/baz` | Yes |
| `foo/bar/buz` | `@foo/anything` | Yes |
| `gitlab-org/gitlab` | `@gitlab-org/gitlab` | Yes |
| `gitlab-org/gitlab` | `@foo/bar` | No |
   
The regex that is used for naming is validating all package names from all package managers: Follow the instructions at [npmjs.com](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) to download and install Node.JS and
NPM to your local development environment.
Once installation is complete, verify you can use NPM in your terminal by
running:
   
```sh
npm --version
``` ```
/\A\@?(([\w\-\.\+]*)\/)*([\w\-\.]+)@?(([\w\-\.\+]*)\/)*([\w\-\.]*)\z/
You should see the NPM version printed in the output:
```
6.10.3
``` ```
   
It allows for capital letters, while NPM does not, and allows for almost all of the ### Installing Yarn
characters NPM allows with a few exceptions (`~` is not allowed).
   
NOTE: **Note:** Capital letters are needed because the scope is required to be You may want to install and use Yarn as an alternative to NPM. Follow the
identical to the top level namespace of the project. So, for example, if your instructions at [yarnpkg.com](https://yarnpkg.com/en/docs/install) to install on
project path is `My-Group/project-foo`, your package must be named `@My-Group/any-package-name`. your development environment.
`@my-group/any-package-name` will not work.
   
CAUTION: **When updating the path of a user/group or transferring a (sub)group/project:** Once installed, you can verify that Yarn is available with the following command:
If you update the root namespace of a project with NPM packages, your changes will be rejected. To be allowed to do that, make sure to remove any NPM package first. Don't forget to update your `.npmrc` files to follow the above naming convention and run `npm publish` if necessary.
   
Now, you can configure your project to authenticate with the GitLab NPM ```sh
Registry. yarn --version
```
You should see the version printed like so:
```
1.19.1
```
### Creating a project
Understanding how to create a full JavaScript project is outside the scope of
this guide but you can initialize a new empty package by creating and navigating
to an empty directory and using the following command:
```sh
npm init
```
Or if you're using Yarn:
```sh
yarn init
```
This will take you through a series of questions to produce a `package.json`
file, which is required for all NPM packages. The most important question is the
package name. NPM packages must [follow the naming convention](#package-naming-convention)
and be scoped to the project or group where the registry exists.
Once you have completed the setup, you are now ready to upload your package to
the GitLab registry. To get started, you will need to set up authentication then
configure GitLab as a remote registry.
   
## Authenticating to the GitLab NPM Registry ## Authenticating to the GitLab NPM Registry
   
If a project is private or you want to upload an NPM package to GitLab, If a project is private or you want to upload an NPM package to GitLab,
credentials will need to be provided for authentication. Support is available for [OAuth tokens](../../../api/oauth2.md#resource-owner-password-credentials-flow) or [personal access tokens](../../profile/personal_access_tokens.md). credentials will need to be provided for authentication. [Personal access tokens](../../profile/personal_access_tokens.md)
are preferred, but support is available for [OAuth tokens](../../../api/oauth2.md#resource-owner-password-credentials-flow).
   
CAUTION: **2FA is only supported with personal access tokens:** CAUTION: **2FA is only supported with personal access tokens:**
If you have 2FA enabled, you need to use a [personal access token](../../profile/personal_access_tokens.md) with OAuth headers with the scope set to `api`. Standard OAuth tokens won't be able to authenticate to the GitLab NPM Registry. If you have 2FA enabled, you need to use a [personal access token](../../profile/personal_access_tokens.md) with OAuth headers with the scope set to `api`. Standard OAuth tokens won't be able to authenticate to the GitLab NPM Registry.
   
### Authenticating with an OAuth token ### Authenticating with a personal access token
   
To authenticate with an [OAuth token](../../../api/oauth2.md#resource-owner-password-credentials-flow) To authenticate with a [personal access token](../../profile/personal_access_tokens.md),
or [personal access token](../../profile/personal_access_tokens.md), set your NPM configuration: set your NPM configuration:
   
```bash ```bash
# Set URL for your scoped packages. # Set URL for your scoped packages.
Loading
@@ -90,7 +125,7 @@ npm config set '//gitlab.com/api/v4/packages/npm/:_authToken' "<your_token>"
Loading
@@ -90,7 +125,7 @@ npm config set '//gitlab.com/api/v4/packages/npm/:_authToken' "<your_token>"
``` ```
   
Replace `<your_project_id>` with your project ID which can be found on the home page Replace `<your_project_id>` with your project ID which can be found on the home page
of your project and `<your_token>` with your OAuth or personal access token. of your project and `<your_token>` with your personal access token.
   
If you have a self-hosted GitLab installation, replace `gitlab.com` with your If you have a self-hosted GitLab installation, replace `gitlab.com` with your
domain name. domain name.
Loading
@@ -142,9 +177,9 @@ Before you will be able to upload a package, you need to specify the registry
Loading
@@ -142,9 +177,9 @@ Before you will be able to upload a package, you need to specify the registry
for NPM. To do this, add the following section to the bottom of `package.json`: for NPM. To do this, add the following section to the bottom of `package.json`:
   
```json ```json
"publishConfig": { "publishConfig": {
"@foo:registry":"https://gitlab.com/api/v4/projects/<your_project_id>/packages/npm/" "@foo:registry":"https://gitlab.com/api/v4/projects/<your_project_id>/packages/npm/"
} }
``` ```
   
Replace `<your_project_id>` with your project ID, which can be found on the home Replace `<your_project_id>` with your project ID, which can be found on the home
Loading
@@ -173,6 +208,93 @@ delete the existing package first. This aligns with npmjs.org's behavior, with
Loading
@@ -173,6 +208,93 @@ delete the existing package first. This aligns with npmjs.org's behavior, with
the exception that npmjs.org does not allow users to ever publish the same version the exception that npmjs.org does not allow users to ever publish the same version
more than once, even if it has been deleted. more than once, even if it has been deleted.
   
## Package naming convention
**Packages must be scoped in the root namespace of the project**. The package
name may be anything but it is preferred that the project name be used unless
it is not possible due to a naming collision. For example:
| Project | Package | Supported |
| ---------------------- | ----------------------- | --------- |
| `foo/bar` | `@foo/bar` | Yes |
| `foo/bar/baz` | `@foo/baz` | Yes |
| `foo/bar/buz` | `@foo/anything` | Yes |
| `gitlab-org/gitlab` | `@gitlab-org/gitlab` | Yes |
| `gitlab-org/gitlab` | `@foo/bar` | No |
The regex that is used for naming is validating all package names from all package managers:
```
/\A\@?(([\w\-\.\+]*)\/)*([\w\-\.]+)@?(([\w\-\.\+]*)\/)*([\w\-\.]*)\z/
```
It allows for capital letters, while NPM does not, and allows for almost all of the
characters NPM allows with a few exceptions (`~` is not allowed).
NOTE: **Note:** Capital letters are needed because the scope is required to be
identical to the top level namespace of the project. So, for example, if your
project path is `My-Group/project-foo`, your package must be named `@My-Group/any-package-name`.
`@my-group/any-package-name` will not work.
CAUTION: **When updating the path of a user/group or transferring a (sub)group/project:**
If you update the root namespace of a project with NPM packages, your changes will be rejected. To be allowed to do that, make sure to remove any NPM package first. Don't forget to update your `.npmrc` files to follow the above naming convention and run `npm publish` if necessary.
Now, you can configure your project to authenticate with the GitLab NPM
Registry.
## Installing a package
NPM packages are commonly installed using the the `npm` or `yarn` commands
inside a JavaScript project. If you haven't already, you will need to set the
URL for scoped packages. You can do this with the following command:
```sh
npm config set @foo:registry https://gitlab.com/api/v4/packages/npm/
```
You will need to replace `@foo` with your scope.
Next, you will need to ensure [authentication](#authenticating-to-the-gitlab-npm-registry)
is setup so you can successfully install the package. Once this has been
completed, you can run the following command inside your project to install a
package:
```sh
npm install @my-project-scope/my-package
```
Or if you're using Yarn:
```sh
yarn add @my-project-scope/my-package
```
## Removing a package
In the packages view of your project page, you can delete packages by clicking
the red trash icons or by clicking the **Delete** button on the package details
page.
## Publishing a package with CI/CD
To work with NPM commands within [GitLab CI](./../../../ci/README.md), you can use
`CI_JOB_TOKEN` in place of the personal access token in your commands.
A simple example `gitlab-ci.yml` file for publishing NPM packages:
```yml
image: node:latest
stages:
- deploy
deploy:
stage: deploy
script:
- echo '//gitlab.com/api/v4/projects/<your_project_id>/packages/npm/:_authToken=${CI_JOB_TOKEN}'>.npmrc
- npm publish
```
## Troubleshooting ## Troubleshooting
   
### Error running yarn with NPM registry ### Error running yarn with NPM registry
Loading
@@ -192,11 +314,11 @@ info If you think this is a bug, please open a bug report with the information p
Loading
@@ -192,11 +314,11 @@ info If you think this is a bug, please open a bug report with the information p
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command
``` ```
   
In this case, try adding this to your `.npmrc` file (and replace `<your_oauth_token>` In this case, try adding this to your `.npmrc` file (and replace `<your_token>`
with your OAuth or personal access token): with your personal access token):
   
```text ```text
//gitlab.com/api/v4/projects/:_authToken=<your_oauth_token> //gitlab.com/api/v4/projects/:_authToken=<your_token>
``` ```
   
### `npm publish` targets default NPM registry (`registry.npmjs.org`) ### `npm publish` targets default NPM registry (`registry.npmjs.org`)
Loading
@@ -220,8 +342,8 @@ should look like:
Loading
@@ -220,8 +342,8 @@ should look like:
And the `.npmrc` file should look like: And the `.npmrc` file should look like:
   
```ini ```ini
//gitlab.com/api/v4/projects/<your_project_id>/packages/npm/:_authToken=<your_oauth_token> //gitlab.com/api/v4/projects/<your_project_id>/packages/npm/:_authToken=<your_token>
//gitlab.com/api/v4/packages/npm/:_authToken=<your_oauth_token> //gitlab.com/api/v4/packages/npm/:_authToken=<your_token>
@foo:registry=https://gitlab.com/api/v4/packages/npm/ @foo:registry=https://gitlab.com/api/v4/packages/npm/
``` ```
   
Loading
Loading
Loading
@@ -101,11 +101,18 @@ module Banzai
Loading
@@ -101,11 +101,18 @@ module Banzai
   
def rebuild_relative_uri(uri) def rebuild_relative_uri(uri)
file_path = nested_file_path_if_exists(uri) file_path = nested_file_path_if_exists(uri)
resource_type = uri_type(file_path)
# Repository routes are under /-/ scope now.
# Since we craft a path without using route helpers we must
# ensure - is added here.
prefix = '-' if %w(tree blob raw commits).include?(resource_type.to_s)
   
uri.path = [ uri.path = [
relative_url_root, relative_url_root,
project.full_path, project.full_path,
uri_type(file_path), prefix,
resource_type,
Addressable::URI.escape(ref).gsub('#', '%23'), Addressable::URI.escape(ref).gsub('#', '%23'),
Addressable::URI.escape(file_path) Addressable::URI.escape(file_path)
].compact.join('/').squeeze('/').chomp('/') ].compact.join('/').squeeze('/').chomp('/')
Loading
Loading
Loading
@@ -28,7 +28,7 @@ module Gitlab
Loading
@@ -28,7 +28,7 @@ module Gitlab
end end
   
def extract_authn_context(document) def extract_authn_context(document)
REXML::XPath.first(document, "//*[name()='saml:AuthnStatement' or name()='saml2:AuthnStatement']/*[name()='saml:AuthnContext' or name()='saml2:AuthnContext']/*[name()='saml:AuthnContextClassRef' or name()='saml2:AuthnContextClassRef']/text()").to_s REXML::XPath.first(document, "//*[name()='saml:AuthnStatement' or name()='saml2:AuthnStatement' or name()='AuthnStatement']/*[name()='saml:AuthnContext' or name()='saml2:AuthnContext' or name()='AuthnContext']/*[name()='saml:AuthnContextClassRef' or name()='saml2:AuthnContextClassRef' or name()='AuthnContextClassRef']/text()").to_s
end end
end end
end end
Loading
Loading
Loading
@@ -17,7 +17,7 @@ module Gitlab
Loading
@@ -17,7 +17,7 @@ module Gitlab
# #
pipeline.stages = @command.stage_seeds.map(&:to_resource) pipeline.stages = @command.stage_seeds.map(&:to_resource)
   
if pipeline.stages.none? if stage_names.empty?
return error('No stages / jobs for this pipeline.') return error('No stages / jobs for this pipeline.')
end end
   
Loading
@@ -31,6 +31,15 @@ module Gitlab
Loading
@@ -31,6 +31,15 @@ module Gitlab
def break? def break?
pipeline.errors.any? pipeline.errors.any?
end end
private
def stage_names
# We filter out `.pre/.post` stages, as they alone are not considered
# a complete pipeline:
# https://gitlab.com/gitlab-org/gitlab/issues/198518
pipeline.stages.map(&:name) - ::Gitlab::Ci::Config::EdgeStagesInjector::EDGES
end
end end
end end
end end
Loading
Loading
Loading
@@ -12,10 +12,12 @@ module Gitlab
Loading
@@ -12,10 +12,12 @@ module Gitlab
def link_dependencies def link_dependencies
link_json('ImportPath') do |path| link_json('ImportPath') do |path|
case path case path
when %r{\A(?<repo>github\.com/#{REPO_REGEX})/(?<path>.+)\z}
"https://#{$~[:repo]}/tree/master/#{$~[:path]}"
when %r{\A(?<repo>gitlab\.com/#{NESTED_REPO_REGEX})\.git/(?<path>.+)\z}, when %r{\A(?<repo>gitlab\.com/#{NESTED_REPO_REGEX})\.git/(?<path>.+)\z},
%r{\A(?<repo>git(lab|hub)\.com/#{REPO_REGEX})/(?<path>.+)\z} %r{\A(?<repo>gitlab\.com/#{REPO_REGEX})/(?<path>.+)\z}
   
"https://#{$~[:repo]}/tree/master/#{$~[:path]}" "https://#{$~[:repo]}/-/tree/master/#{$~[:path]}"
when /\Agolang\.org/ when /\Agolang\.org/
"https://godoc.org/#{path}" "https://godoc.org/#{path}"
else else
Loading
Loading
Loading
@@ -60,7 +60,7 @@ module Gitlab
Loading
@@ -60,7 +60,7 @@ module Gitlab
end end
   
meta_import_tag = tag :meta, name: 'go-import', content: "#{import_prefix} git #{repository_url}" meta_import_tag = tag :meta, name: 'go-import', content: "#{import_prefix} git #{repository_url}"
meta_source_tag = tag :meta, name: 'go-source', content: "#{import_prefix} #{project_url} #{project_url}/tree/#{branch}{/dir} #{project_url}/blob/#{branch}{/dir}/{file}#L{line}" meta_source_tag = tag :meta, name: 'go-source', content: "#{import_prefix} #{project_url} #{project_url}/-/tree/#{branch}{/dir} #{project_url}/-/blob/#{branch}{/dir}/{file}#L{line}"
head_tag = content_tag :head, meta_import_tag + meta_source_tag head_tag = content_tag :head, meta_import_tag + meta_source_tag
html_tag = content_tag :html, head_tag + body_tag html_tag = content_tag :html, head_tag + body_tag
[html_tag, 200] [html_tag, 200]
Loading
Loading
Loading
@@ -11,18 +11,26 @@ module Gitlab
Loading
@@ -11,18 +11,26 @@ module Gitlab
Error = Class.new(StandardError) Error = Class.new(StandardError)
   
class << self class << self
# Retrieve GitLab Shell secret token
#
# @return [String] secret token
def secret_token def secret_token
@secret_token ||= begin @secret_token ||= begin
File.read(Gitlab.config.gitlab_shell.secret_file).chomp File.read(Gitlab.config.gitlab_shell.secret_file).chomp
end end
end end
   
# Ensure gitlab shell has a secret token stored in the secret_file
# if that was never generated, generate a new one
def ensure_secret_token! def ensure_secret_token!
return if File.exist?(File.join(Gitlab.config.gitlab_shell.path, '.gitlab_shell_secret')) return if File.exist?(File.join(Gitlab.config.gitlab_shell.path, '.gitlab_shell_secret'))
   
generate_and_link_secret_token generate_and_link_secret_token
end end
   
# Returns required GitLab shell version
#
# @return [String] version from the manifest file
def version_required def version_required
@version_required ||= File.read(Rails.root @version_required ||= File.read(Rails.root
.join('GITLAB_SHELL_VERSION')).strip .join('GITLAB_SHELL_VERSION')).strip
Loading
@@ -48,24 +56,31 @@ module Gitlab
Loading
@@ -48,24 +56,31 @@ module Gitlab
end end
end end
   
# Convenience methods for initializing a new repository with a Project model. # Initialize a new project repository using a Project model
#
# @param [Project] project
# @return [Boolean] whether repository could be created
def create_project_repository(project) def create_project_repository(project)
create_repository(project.repository_storage, project.disk_path, project.full_path) create_repository(project.repository_storage, project.disk_path, project.full_path)
end end
   
# Initialize a new wiki repository using a Project model
#
# @param [Project] project
# @return [Boolean] whether repository could be created
def create_wiki_repository(project) def create_wiki_repository(project)
create_repository(project.repository_storage, project.wiki.disk_path, project.wiki.full_path) create_repository(project.repository_storage, project.wiki.disk_path, project.wiki.full_path)
end end
   
# Init new repository # Init new repository
# #
# storage - the shard key # @example Create a repository
# disk_path - project disk path
# gl_project_path - project name
#
# Ex.
# create_repository("default", "path/to/gitlab-ci", "gitlab/gitlab-ci") # create_repository("default", "path/to/gitlab-ci", "gitlab/gitlab-ci")
# #
# @param [String] storage the shard key
# @param [String] disk_path project path on disk
# @param [String] gl_project_path project name
# @return [Boolean] whether repository could be created
def create_repository(storage, disk_path, gl_project_path) def create_repository(storage, disk_path, gl_project_path)
relative_path = disk_path.dup relative_path = disk_path.dup
relative_path << '.git' unless relative_path.end_with?('.git') relative_path << '.git' unless relative_path.end_with?('.git')
Loading
@@ -82,29 +97,39 @@ module Gitlab
Loading
@@ -82,29 +97,39 @@ module Gitlab
false false
end end
   
# Import wiki repository from external service
#
# @param [Project] project
# @param [Gitlab::LegacyGithubImport::WikiFormatter, Gitlab::BitbucketImport::WikiFormatter] wiki_formatter
# @return [Boolean] whether repository could be imported
def import_wiki_repository(project, wiki_formatter) def import_wiki_repository(project, wiki_formatter)
import_repository(project.repository_storage, wiki_formatter.disk_path, wiki_formatter.import_url, project.wiki.full_path) import_repository(project.repository_storage, wiki_formatter.disk_path, wiki_formatter.import_url, project.wiki.full_path)
end end
   
# Import project repository from external service
#
# @param [Project] project
# @return [Boolean] whether repository could be imported
def import_project_repository(project) def import_project_repository(project)
import_repository(project.repository_storage, project.disk_path, project.import_url, project.full_path) import_repository(project.repository_storage, project.disk_path, project.import_url, project.full_path)
end end
   
# Import repository # Import repository
# #
# storage - project's storage name # @example Import a repository
# name - project disk path # import_repository("nfs-file06", "gitlab/gitlab-ci", "https://gitlab.com/gitlab-org/gitlab-test.git", "gitlab/gitlab-ci")
# url - URL to import from
#
# Ex.
# import_repository("nfs-file06", "gitlab/gitlab-ci", "https://gitlab.com/gitlab-org/gitlab-test.git")
# #
def import_repository(storage, name, url, gl_project_path) # @param [String] storage project's storage name
# @param [String] disk_path project path on disk
# @param [String] url from external resource to import from
# @param [String] gl_project_path project name
# @return [Boolean] whether repository could be imported
def import_repository(storage, disk_path, url, gl_project_path)
if url.start_with?('.', '/') if url.start_with?('.', '/')
raise Error.new("don't use disk paths with import_repository: #{url.inspect}") raise Error.new("don't use disk paths with import_repository: #{url.inspect}")
end end
   
relative_path = "#{name}.git" relative_path = "#{disk_path}.git"
cmd = GitalyGitlabProjects.new(storage, relative_path, gl_project_path) cmd = GitalyGitlabProjects.new(storage, relative_path, gl_project_path)
   
success = cmd.import_project(url, git_timeout) success = cmd.import_project(url, git_timeout)
Loading
@@ -113,27 +138,31 @@ module Gitlab
Loading
@@ -113,27 +138,31 @@ module Gitlab
success success
end end
   
# storage - project's storage path # Move or rename a repository
# path - project disk path
# new_path - new project disk path
# #
# Ex. # @example Move/rename a repository
# mv_repository("/path/to/storage", "gitlab/gitlab-ci", "randx/gitlab-ci-new") # mv_repository("/path/to/storage", "gitlab/gitlab-ci", "randx/gitlab-ci-new")
def mv_repository(storage, path, new_path) #
return false if path.empty? || new_path.empty? # @param [String] storage project's storage path
# @param [String] disk_path current project path on disk
# @param [String] new_disk_path new project path on disk
# @return [Boolean] whether repository could be moved/renamed on disk
def mv_repository(storage, disk_path, new_disk_path)
return false if disk_path.empty? || new_disk_path.empty?
   
Gitlab::Git::Repository.new(storage, "#{path}.git", nil, nil).rename("#{new_path}.git") Gitlab::Git::Repository.new(storage, "#{disk_path}.git", nil, nil).rename("#{new_disk_path}.git")
   
true true
rescue => e rescue => e
Gitlab::ErrorTracking.track_exception(e, path: path, new_path: new_path, storage: storage) Gitlab::ErrorTracking.track_exception(e, path: disk_path, new_path: new_disk_path, storage: storage)
   
false false
end end
   
# Fork repository to new path # Fork repository to new path
# source_project - forked-from Project #
# target_project - forked-to Project # @param [Project] source_project forked-from Project
# @param [Project] target_project forked-to Project
def fork_repository(source_project, target_project) def fork_repository(source_project, target_project)
forked_from_relative_path = "#{source_project.disk_path}.git" forked_from_relative_path = "#{source_project.disk_path}.git"
fork_args = [target_project.repository_storage, "#{target_project.disk_path}.git", target_project.full_path] fork_args = [target_project.repository_storage, "#{target_project.disk_path}.git", target_project.full_path]
Loading
@@ -145,29 +174,32 @@ module Gitlab
Loading
@@ -145,29 +174,32 @@ module Gitlab
# for rm_namespace. Given the underlying implementation removes the name # for rm_namespace. Given the underlying implementation removes the name
# passed as second argument on the passed storage. # passed as second argument on the passed storage.
# #
# storage - project's storage path # @example Remove a repository
# name - project disk path
#
# Ex.
# remove_repository("/path/to/storage", "gitlab/gitlab-ci") # remove_repository("/path/to/storage", "gitlab/gitlab-ci")
def remove_repository(storage, name) #
return false if name.empty? # @param [String] storage project's storage path
# @param [String] disk_path current project path on disk
def remove_repository(storage, disk_path)
return false if disk_path.empty?
   
Gitlab::Git::Repository.new(storage, "#{name}.git", nil, nil).remove Gitlab::Git::Repository.new(storage, "#{disk_path}.git", nil, nil).remove
   
true true
rescue => e rescue => e
Rails.logger.warn("Repository does not exist: #{e} at: #{name}.git") # rubocop:disable Gitlab/RailsLogger Rails.logger.warn("Repository does not exist: #{e} at: #{disk_path}.git") # rubocop:disable Gitlab/RailsLogger
Gitlab::ErrorTracking.track_exception(e, path: name, storage: storage) Gitlab::ErrorTracking.track_exception(e, path: disk_path, storage: storage)
   
false false
end end
   
# Add new key to authorized_keys # Add new key to authorized_keys
# #
# Ex. # @example Add new key
# add_key("key-42", "sha-rsa ...") # add_key("key-42", "sha-rsa ...")
# #
# @param [String] key_id identifier of the key
# @param [String] key_content key content (public certificate)
# @return [Boolean] whether key could be added
def add_key(key_id, key_content) def add_key(key_id, key_content)
return unless self.authorized_keys_enabled? return unless self.authorized_keys_enabled?
   
Loading
@@ -176,39 +208,45 @@ module Gitlab
Loading
@@ -176,39 +208,45 @@ module Gitlab
   
# Batch-add keys to authorized_keys # Batch-add keys to authorized_keys
# #
# Ex. # @example
# batch_add_keys(Key.all) # batch_add_keys(Key.all)
#
# @param [Array<Key>] keys
# @return [Boolean] whether keys could be added
def batch_add_keys(keys) def batch_add_keys(keys)
return unless self.authorized_keys_enabled? return unless self.authorized_keys_enabled?
   
gitlab_authorized_keys.batch_add_keys(keys) gitlab_authorized_keys.batch_add_keys(keys)
end end
   
# Remove ssh key from authorized_keys # Remove SSH key from authorized_keys
# #
# Ex. # @example Remove a key
# remove_key("key-342") # remove_key("key-342")
# #
def remove_key(id, _ = nil) # @param [String] key_id
# @return [Boolean] whether key could be removed or not
def remove_key(key_id, _ = nil)
return unless self.authorized_keys_enabled? return unless self.authorized_keys_enabled?
   
gitlab_authorized_keys.rm_key(id) gitlab_authorized_keys.rm_key(key_id)
end end
   
# Remove all ssh keys from gitlab shell # Remove all SSH keys from gitlab shell
# #
# Ex. # @example Remove all keys
# remove_all_keys # remove_all_keys
# #
# @return [Boolean] whether keys could be removed or not
def remove_all_keys def remove_all_keys
return unless self.authorized_keys_enabled? return unless self.authorized_keys_enabled?
   
gitlab_authorized_keys.clear gitlab_authorized_keys.clear
end end
   
# Remove ssh keys from gitlab shell that are not in the DB # Remove SSH keys from gitlab shell that are not in the DB
# #
# Ex. # @example Remove keys not on the database
# remove_keys_not_found_in_db # remove_keys_not_found_in_db
# #
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
Loading
@@ -234,11 +272,12 @@ module Gitlab
Loading
@@ -234,11 +272,12 @@ module Gitlab
   
# Add empty directory for storing repositories # Add empty directory for storing repositories
# #
# Ex. # @example Add new namespace directory
# add_namespace("default", "gitlab") # add_namespace("default", "gitlab")
# #
# @param [String] storage project's storage path
# @param [String] name namespace name
def add_namespace(storage, name) def add_namespace(storage, name)
# https://gitlab.com/gitlab-org/gitlab-foss/issues/58012
Gitlab::GitalyClient.allow_n_plus_1_calls do Gitlab::GitalyClient.allow_n_plus_1_calls do
Gitlab::GitalyClient::NamespaceService.new(storage).add(name) Gitlab::GitalyClient::NamespaceService.new(storage).add(name)
end end
Loading
@@ -249,9 +288,11 @@ module Gitlab
Loading
@@ -249,9 +288,11 @@ module Gitlab
# Remove directory from repositories storage # Remove directory from repositories storage
# Every repository inside this directory will be removed too # Every repository inside this directory will be removed too
# #
# Ex. # @example Remove namespace directory
# rm_namespace("default", "gitlab") # rm_namespace("default", "gitlab")
# #
# @param [String] storage project's storage path
# @param [String] name namespace name
def rm_namespace(storage, name) def rm_namespace(storage, name)
Gitlab::GitalyClient::NamespaceService.new(storage).remove(name) Gitlab::GitalyClient::NamespaceService.new(storage).remove(name)
rescue GRPC::InvalidArgument => e rescue GRPC::InvalidArgument => e
Loading
@@ -261,9 +302,12 @@ module Gitlab
Loading
@@ -261,9 +302,12 @@ module Gitlab
   
# Move namespace directory inside repositories storage # Move namespace directory inside repositories storage
# #
# Ex. # @example Move/rename a namespace directory
# mv_namespace("/path/to/storage", "gitlab", "gitlabhq") # mv_namespace("/path/to/storage", "gitlab", "gitlabhq")
# #
# @param [String] storage project's storage path
# @param [String] old_name current namespace name
# @param [String] new_name new namespace name
def mv_namespace(storage, old_name, new_name) def mv_namespace(storage, old_name, new_name)
Gitlab::GitalyClient::NamespaceService.new(storage).rename(old_name, new_name) Gitlab::GitalyClient::NamespaceService.new(storage).rename(old_name, new_name)
rescue GRPC::InvalidArgument => e rescue GRPC::InvalidArgument => e
Loading
@@ -272,11 +316,17 @@ module Gitlab
Loading
@@ -272,11 +316,17 @@ module Gitlab
false false
end end
   
def url_to_repo(path) # Return a SSH url for a given project path
Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git" #
# @param [String] full_path project path (URL)
# @return [String] SSH URL
def url_to_repo(full_path)
Gitlab.config.gitlab_shell.ssh_path_prefix + "#{full_path}.git"
end end
   
# Return GitLab shell version # Return GitLab shell version
#
# @return [String] version
def version def version
gitlab_shell_version_file = "#{gitlab_shell_path}/VERSION" gitlab_shell_version_file = "#{gitlab_shell_path}/VERSION"
   
Loading
@@ -285,12 +335,23 @@ module Gitlab
Loading
@@ -285,12 +335,23 @@ module Gitlab
end end
end end
   
# Check if repository exists on disk
#
# @example Check if repository exists
# repository_exists?('default', 'gitlab-org/gitlab.git')
#
# @return [Boolean] whether repository exists or not
# @param [String] storage project's storage path
# @param [Object] dir_name repository dir name
def repository_exists?(storage, dir_name) def repository_exists?(storage, dir_name)
Gitlab::Git::Repository.new(storage, dir_name, nil, nil).exists? Gitlab::Git::Repository.new(storage, dir_name, nil, nil).exists?
rescue GRPC::Internal rescue GRPC::Internal
false false
end end
   
# Return hooks folder path used by projects
#
# @return [String] path
def hooks_path def hooks_path
File.join(gitlab_shell_path, 'hooks') File.join(gitlab_shell_path, 'hooks')
end end
Loading
Loading
Loading
@@ -10407,15 +10407,9 @@ msgstr ""
Loading
@@ -10407,15 +10407,9 @@ msgstr ""
msgid "Invocations" msgid "Invocations"
msgstr "" msgstr ""
   
msgid "Is"
msgstr ""
msgid "Is blocked by" msgid "Is blocked by"
msgstr "" msgstr ""
   
msgid "Is not"
msgstr ""
msgid "Is using license seat:" msgid "Is using license seat:"
msgstr "" msgstr ""
   
Loading
@@ -22464,6 +22458,9 @@ msgstr[1] ""
Loading
@@ -22464,6 +22458,9 @@ msgstr[1] ""
msgid "invalid milestone state `%{state}`" msgid "invalid milestone state `%{state}`"
msgstr "" msgstr ""
   
msgid "is"
msgstr ""
msgid "is an invalid IP address range" msgid "is an invalid IP address range"
msgstr "" msgstr ""
   
Loading
@@ -22479,6 +22476,9 @@ msgstr ""
Loading
@@ -22479,6 +22476,9 @@ msgstr ""
msgid "is invalid because there is upstream lock" msgid "is invalid because there is upstream lock"
msgstr "" msgstr ""
   
msgid "is not"
msgstr ""
msgid "is not a descendant of the Group owning the template" msgid "is not a descendant of the Group owning the template"
msgstr "" msgstr ""
   
Loading
Loading
Loading
@@ -28,7 +28,7 @@ describe AcmeChallengesController do
Loading
@@ -28,7 +28,7 @@ describe AcmeChallengesController do
let(:token) { acme_order.challenge_token } let(:token) { acme_order.challenge_token }
   
it 'renders not found' do it 'renders not found' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
   
Loading
@@ -37,7 +37,7 @@ describe AcmeChallengesController do
Loading
@@ -37,7 +37,7 @@ describe AcmeChallengesController do
let(:token) { 'wrongtoken' } let(:token) { 'wrongtoken' }
   
it 'renders not found' do it 'renders not found' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
Loading
Loading
Loading
@@ -156,7 +156,7 @@ describe ApplicationController do
Loading
@@ -156,7 +156,7 @@ describe ApplicationController do
it 'returns 200 response' do it 'returns 200 response' do
get :index, format: requested_format get :index, format: requested_format
   
expect(response).to have_gitlab_http_status 200 expect(response).to have_gitlab_http_status(:ok)
end end
end end
   
Loading
@@ -164,7 +164,7 @@ describe ApplicationController do
Loading
@@ -164,7 +164,7 @@ describe ApplicationController do
it 'returns 404 response' do it 'returns 404 response' do
get :index get :index
   
expect(response).to have_gitlab_http_status 404 expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
Loading
@@ -181,7 +181,7 @@ describe ApplicationController do
Loading
@@ -181,7 +181,7 @@ describe ApplicationController do
   
get :index get :index
   
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
   
it 'redirects to login page if not authenticated' do it 'redirects to login page if not authenticated' do
Loading
@@ -202,7 +202,7 @@ describe ApplicationController do
Loading
@@ -202,7 +202,7 @@ describe ApplicationController do
   
get :index, format: 'unknown' get :index, format: 'unknown'
   
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
Loading
@@ -489,7 +489,7 @@ describe ApplicationController do
Loading
@@ -489,7 +489,7 @@ describe ApplicationController do
it 'redirects if the user did not accept the terms' do it 'redirects if the user did not accept the terms' do
get :index get :index
   
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
   
it 'does not redirect when the user accepted terms' do it 'does not redirect when the user accepted terms' do
Loading
@@ -497,7 +497,7 @@ describe ApplicationController do
Loading
@@ -497,7 +497,7 @@ describe ApplicationController do
   
get :index get :index
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
Loading
@@ -581,21 +581,21 @@ describe ApplicationController do
Loading
@@ -581,21 +581,21 @@ describe ApplicationController do
it 'renders a 404 without a message' do it 'renders a 404 without a message' do
get :index get :index
   
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(response).to render_template('errors/not_found') expect(response).to render_template('errors/not_found')
end end
   
it 'renders a 403 when a message is passed to access denied' do it 'renders a 403 when a message is passed to access denied' do
get :index, params: { message: 'None shall pass' } get :index, params: { message: 'None shall pass' }
   
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
expect(response).to render_template('errors/access_denied') expect(response).to render_template('errors/access_denied')
end end
   
it 'renders a status passed to access denied' do it 'renders a status passed to access denied' do
get :index, params: { status: 401 } get :index, params: { status: 401 }
   
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
   
Loading
Loading
Loading
@@ -32,7 +32,7 @@ describe AutocompleteController do
Loading
@@ -32,7 +32,7 @@ describe AutocompleteController do
get(:users, params: { project_id: 'unknown' }) get(:users, params: { project_id: 'unknown' })
end end
   
it { expect(response).to have_gitlab_http_status(404) } it { expect(response).to have_gitlab_http_status(:not_found) }
end end
end end
   
Loading
@@ -61,7 +61,7 @@ describe AutocompleteController do
Loading
@@ -61,7 +61,7 @@ describe AutocompleteController do
get(:users, params: { group_id: 'unknown' }) get(:users, params: { group_id: 'unknown' })
end end
   
it { expect(response).to have_gitlab_http_status(404) } it { expect(response).to have_gitlab_http_status(:not_found) }
end end
end end
   
Loading
@@ -140,7 +140,7 @@ describe AutocompleteController do
Loading
@@ -140,7 +140,7 @@ describe AutocompleteController do
get(:users, params: { project_id: project.id }) get(:users, params: { project_id: project.id })
end end
   
it { expect(response).to have_gitlab_http_status(404) } it { expect(response).to have_gitlab_http_status(:not_found) }
end end
   
describe 'GET #users with unknown project' do describe 'GET #users with unknown project' do
Loading
@@ -148,7 +148,7 @@ describe AutocompleteController do
Loading
@@ -148,7 +148,7 @@ describe AutocompleteController do
get(:users, params: { project_id: 'unknown' }) get(:users, params: { project_id: 'unknown' })
end end
   
it { expect(response).to have_gitlab_http_status(404) } it { expect(response).to have_gitlab_http_status(:not_found) }
end end
   
describe 'GET #users with inaccessible group' do describe 'GET #users with inaccessible group' do
Loading
@@ -157,7 +157,7 @@ describe AutocompleteController do
Loading
@@ -157,7 +157,7 @@ describe AutocompleteController do
get(:users, params: { group_id: user.namespace.id }) get(:users, params: { group_id: user.namespace.id })
end end
   
it { expect(response).to have_gitlab_http_status(404) } it { expect(response).to have_gitlab_http_status(:not_found) }
end end
   
describe 'GET #users with no project' do describe 'GET #users with no project' do
Loading
@@ -372,7 +372,7 @@ describe AutocompleteController do
Loading
@@ -372,7 +372,7 @@ describe AutocompleteController do
it 'returns empty json' do it 'returns empty json' do
get :merge_request_target_branches, params: { project_id: project.id } get :merge_request_target_branches, params: { project_id: project.id }
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_empty expect(json_response).to be_empty
end end
end end
Loading
@@ -383,7 +383,7 @@ describe AutocompleteController do
Loading
@@ -383,7 +383,7 @@ describe AutocompleteController do
   
get :merge_request_target_branches, params: { project_id: project.id } get :merge_request_target_branches, params: { project_id: project.id }
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_empty expect(json_response).to be_empty
end end
end end
Loading
@@ -404,7 +404,7 @@ describe AutocompleteController do
Loading
@@ -404,7 +404,7 @@ describe AutocompleteController do
   
get :merge_request_target_branches, params: params get :merge_request_target_branches, params: params
   
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response).to eq({ 'error' => 'At least one of group_id or project_id must be specified' }) expect(json_response).to eq({ 'error' => 'At least one of group_id or project_id must be specified' })
end end
end end
Loading
@@ -416,7 +416,7 @@ describe AutocompleteController do
Loading
@@ -416,7 +416,7 @@ describe AutocompleteController do
   
get :merge_request_target_branches, params: { project_id: project.id } get :merge_request_target_branches, params: { project_id: project.id }
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to contain_exactly({ 'title' => 'feature' }) expect(json_response).to contain_exactly({ 'title' => 'feature' })
end end
end end
Loading
@@ -433,7 +433,7 @@ describe AutocompleteController do
Loading
@@ -433,7 +433,7 @@ describe AutocompleteController do
   
get :merge_request_target_branches, params: { group_id: group.id } get :merge_request_target_branches, params: { group_id: group.id }
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to contain_exactly({ 'title' => 'feature' }) expect(json_response).to contain_exactly({ 'title' => 'feature' })
end end
end end
Loading
Loading
Loading
@@ -9,7 +9,7 @@ describe ChaosController do
Loading
@@ -9,7 +9,7 @@ describe ChaosController do
   
get :leakmem get :leakmem
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
   
it 'call synchronously with params' do it 'call synchronously with params' do
Loading
@@ -17,7 +17,7 @@ describe ChaosController do
Loading
@@ -17,7 +17,7 @@ describe ChaosController do
   
get :leakmem, params: { memory_mb: 1, duration_s: 2 } get :leakmem, params: { memory_mb: 1, duration_s: 2 }
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
   
it 'calls asynchronously' do it 'calls asynchronously' do
Loading
@@ -25,7 +25,7 @@ describe ChaosController do
Loading
@@ -25,7 +25,7 @@ describe ChaosController do
   
get :leakmem, params: { async: 1 } get :leakmem, params: { async: 1 }
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
   
Loading
@@ -35,7 +35,7 @@ describe ChaosController do
Loading
@@ -35,7 +35,7 @@ describe ChaosController do
   
get :cpu_spin get :cpu_spin
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
   
it 'calls synchronously with params' do it 'calls synchronously with params' do
Loading
@@ -43,7 +43,7 @@ describe ChaosController do
Loading
@@ -43,7 +43,7 @@ describe ChaosController do
   
get :cpu_spin, params: { duration_s: 3 } get :cpu_spin, params: { duration_s: 3 }
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
   
it 'calls asynchronously' do it 'calls asynchronously' do
Loading
@@ -51,7 +51,7 @@ describe ChaosController do
Loading
@@ -51,7 +51,7 @@ describe ChaosController do
   
get :cpu_spin, params: { async: 1 } get :cpu_spin, params: { async: 1 }
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
   
Loading
@@ -61,7 +61,7 @@ describe ChaosController do
Loading
@@ -61,7 +61,7 @@ describe ChaosController do
   
get :db_spin get :db_spin
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
   
it 'calls synchronously with params' do it 'calls synchronously with params' do
Loading
@@ -69,7 +69,7 @@ describe ChaosController do
Loading
@@ -69,7 +69,7 @@ describe ChaosController do
   
get :db_spin, params: { duration_s: 4, interval_s: 5 } get :db_spin, params: { duration_s: 4, interval_s: 5 }
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
   
it 'calls asynchronously' do it 'calls asynchronously' do
Loading
@@ -77,7 +77,7 @@ describe ChaosController do
Loading
@@ -77,7 +77,7 @@ describe ChaosController do
   
get :db_spin, params: { async: 1 } get :db_spin, params: { async: 1 }
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
   
Loading
@@ -87,7 +87,7 @@ describe ChaosController do
Loading
@@ -87,7 +87,7 @@ describe ChaosController do
   
get :sleep get :sleep
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
   
it 'calls synchronously with params' do it 'calls synchronously with params' do
Loading
@@ -95,7 +95,7 @@ describe ChaosController do
Loading
@@ -95,7 +95,7 @@ describe ChaosController do
   
get :sleep, params: { duration_s: 5 } get :sleep, params: { duration_s: 5 }
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
   
it 'calls asynchronously' do it 'calls asynchronously' do
Loading
@@ -103,7 +103,7 @@ describe ChaosController do
Loading
@@ -103,7 +103,7 @@ describe ChaosController do
   
get :sleep, params: { async: 1 } get :sleep, params: { async: 1 }
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
   
Loading
@@ -113,7 +113,7 @@ describe ChaosController do
Loading
@@ -113,7 +113,7 @@ describe ChaosController do
   
get :kill get :kill
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
   
it 'calls asynchronously' do it 'calls asynchronously' do
Loading
@@ -121,7 +121,7 @@ describe ChaosController do
Loading
@@ -121,7 +121,7 @@ describe ChaosController do
   
get :kill, params: { async: 1 } get :kill, params: { async: 1 }
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
Loading
@@ -72,7 +72,7 @@ describe MetricsDashboard do
Loading
@@ -72,7 +72,7 @@ describe MetricsDashboard do
   
it 'includes project_blob_path only for project dashboards' do it 'includes project_blob_path only for project dashboards' do
expect(system_dashboard['project_blob_path']).to be_nil expect(system_dashboard['project_blob_path']).to be_nil
expect(project_dashboard['project_blob_path']).to eq("/#{project.namespace.path}/#{project.name}/blob/master/.gitlab/dashboards/test.yml") expect(project_dashboard['project_blob_path']).to eq("/#{project.namespace.path}/#{project.name}/-/blob/master/.gitlab/dashboards/test.yml")
end end
   
describe 'project permissions' do describe 'project permissions' do
Loading
Loading
Loading
@@ -39,7 +39,7 @@ describe GraphqlController do
Loading
@@ -39,7 +39,7 @@ describe GraphqlController do
it 'returns 200 when user can access API' do it 'returns 200 when user can access API' do
post :execute post :execute
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
   
it 'returns access denied template when user cannot access API' do it 'returns access denied template when user cannot access API' do
Loading
@@ -59,7 +59,7 @@ describe GraphqlController do
Loading
@@ -59,7 +59,7 @@ describe GraphqlController do
it 'returns 200' do it 'returns 200' do
post :execute post :execute
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
Loading
Loading
Loading
@@ -136,7 +136,7 @@ describe GroupsController do
Loading
@@ -136,7 +136,7 @@ describe GroupsController do
   
get :activity, params: { id: group.to_param }, format: :json get :activity, params: { id: group.to_param }, format: :json
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['count']).to eq(3) expect(json_response['count']).to eq(3)
expect(assigns(:projects).limit_value).to be_nil expect(assigns(:projects).limit_value).to be_nil
end end
Loading
@@ -151,7 +151,7 @@ describe GroupsController do
Loading
@@ -151,7 +151,7 @@ describe GroupsController do
post :create, params: { group: { name: 'new_group', path: "new_group" } } post :create, params: { group: { name: 'new_group', path: "new_group" } }
end.to change { Group.count }.by(1) end.to change { Group.count }.by(1)
   
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
   
context 'authorization' do context 'authorization' do
Loading
@@ -162,7 +162,7 @@ describe GroupsController do
Loading
@@ -162,7 +162,7 @@ describe GroupsController do
post :create, params: { group: { name: 'new_group', path: "new_group" } } post :create, params: { group: { name: 'new_group', path: "new_group" } }
end.to change { Group.count }.by(1) end.to change { Group.count }.by(1)
   
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
   
Loading
@@ -367,7 +367,7 @@ describe GroupsController do
Loading
@@ -367,7 +367,7 @@ describe GroupsController do
it 'updates the path successfully' do it 'updates the path successfully' do
post :update, params: { id: group.to_param, group: { path: 'new_path' } } post :update, params: { id: group.to_param, group: { path: 'new_path' } }
   
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(controller).to set_flash[:notice] expect(controller).to set_flash[:notice]
end end
   
Loading
@@ -382,7 +382,7 @@ describe GroupsController do
Loading
@@ -382,7 +382,7 @@ describe GroupsController do
it 'updates the project_creation_level successfully' do it 'updates the project_creation_level successfully' do
post :update, params: { id: group.to_param, group: { project_creation_level: ::Gitlab::Access::MAINTAINER_PROJECT_ACCESS } } post :update, params: { id: group.to_param, group: { project_creation_level: ::Gitlab::Access::MAINTAINER_PROJECT_ACCESS } }
   
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(group.reload.project_creation_level).to eq(::Gitlab::Access::MAINTAINER_PROJECT_ACCESS) expect(group.reload.project_creation_level).to eq(::Gitlab::Access::MAINTAINER_PROJECT_ACCESS)
end end
   
Loading
@@ -397,7 +397,7 @@ describe GroupsController do
Loading
@@ -397,7 +397,7 @@ describe GroupsController do
post :update, params: { id: group.to_param, group: { name: 'new_name' } } post :update, params: { id: group.to_param, group: { name: 'new_name' } }
   
expect(controller).to set_flash[:notice] expect(controller).to set_flash[:notice]
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(group.reload.name).to eq('new_name') expect(group.reload.name).to eq('new_name')
end end
   
Loading
@@ -405,7 +405,7 @@ describe GroupsController do
Loading
@@ -405,7 +405,7 @@ describe GroupsController do
post :update, params: { id: group.to_param, group: { path: 'new_path' } } post :update, params: { id: group.to_param, group: { path: 'new_path' } }
   
expect(assigns(:group).errors[:base].first).to match(/Docker images in their Container Registry/) expect(assigns(:group).errors[:base].first).to match(/Docker images in their Container Registry/)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
Loading
@@ -468,7 +468,7 @@ describe GroupsController do
Loading
@@ -468,7 +468,7 @@ describe GroupsController do
it 'does not redirect' do it 'does not redirect' do
get :issues, params: { id: group.to_param } get :issues, params: { id: group.to_param }
   
expect(response).not_to have_gitlab_http_status(301) expect(response).not_to have_gitlab_http_status(:moved_permanently)
end end
end end
   
Loading
@@ -487,7 +487,7 @@ describe GroupsController do
Loading
@@ -487,7 +487,7 @@ describe GroupsController do
it 'does not redirect' do it 'does not redirect' do
get :show, params: { id: group.to_param } get :show, params: { id: group.to_param }
   
expect(response).not_to have_gitlab_http_status(301) expect(response).not_to have_gitlab_http_status(:moved_permanently)
end end
end end
   
Loading
@@ -554,13 +554,13 @@ describe GroupsController do
Loading
@@ -554,13 +554,13 @@ describe GroupsController do
it 'does not 404' do it 'does not 404' do
post :update, params: { id: group.to_param.upcase, group: { path: 'new_path' } } post :update, params: { id: group.to_param.upcase, group: { path: 'new_path' } }
   
expect(response).not_to have_gitlab_http_status(404) expect(response).not_to have_gitlab_http_status(:not_found)
end end
   
it 'does not redirect to the correct casing' do it 'does not redirect to the correct casing' do
post :update, params: { id: group.to_param.upcase, group: { path: 'new_path' } } post :update, params: { id: group.to_param.upcase, group: { path: 'new_path' } }
   
expect(response).not_to have_gitlab_http_status(301) expect(response).not_to have_gitlab_http_status(:moved_permanently)
end end
end end
   
Loading
@@ -570,7 +570,7 @@ describe GroupsController do
Loading
@@ -570,7 +570,7 @@ describe GroupsController do
it 'returns not found' do it 'returns not found' do
post :update, params: { id: redirect_route.path, group: { path: 'new_path' } } post :update, params: { id: redirect_route.path, group: { path: 'new_path' } }
   
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
Loading
@@ -580,13 +580,13 @@ describe GroupsController do
Loading
@@ -580,13 +580,13 @@ describe GroupsController do
it 'does not 404' do it 'does not 404' do
delete :destroy, params: { id: group.to_param.upcase } delete :destroy, params: { id: group.to_param.upcase }
   
expect(response).not_to have_gitlab_http_status(404) expect(response).not_to have_gitlab_http_status(:not_found)
end end
   
it 'does not redirect to the correct casing' do it 'does not redirect to the correct casing' do
delete :destroy, params: { id: group.to_param.upcase } delete :destroy, params: { id: group.to_param.upcase }
   
expect(response).not_to have_gitlab_http_status(301) expect(response).not_to have_gitlab_http_status(:moved_permanently)
end end
end end
   
Loading
@@ -596,7 +596,7 @@ describe GroupsController do
Loading
@@ -596,7 +596,7 @@ describe GroupsController do
it 'returns not found' do it 'returns not found' do
delete :destroy, params: { id: redirect_route.path } delete :destroy, params: { id: redirect_route.path }
   
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
Loading
@@ -693,7 +693,7 @@ describe GroupsController do
Loading
@@ -693,7 +693,7 @@ describe GroupsController do
end end
   
it 'is denied' do it 'is denied' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
   
Loading
@@ -755,13 +755,13 @@ describe GroupsController do
Loading
@@ -755,13 +755,13 @@ describe GroupsController do
it 'is successful' do it 'is successful' do
get :show, params: { id: group.to_param } get :show, params: { id: group.to_param }
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
   
it 'does not allow other formats' do it 'does not allow other formats' do
get :show, params: { id: group.to_param }, format: :atom get :show, params: { id: group.to_param }, format: :atom
   
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
   
Loading
@@ -769,7 +769,7 @@ describe GroupsController do
Loading
@@ -769,7 +769,7 @@ describe GroupsController do
it 'is successful' do it 'is successful' do
get :edit, params: { id: group.to_param } get :edit, params: { id: group.to_param }
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
   
Loading
@@ -777,7 +777,7 @@ describe GroupsController do
Loading
@@ -777,7 +777,7 @@ describe GroupsController do
it 'is successful' do it 'is successful' do
get :new get :new
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
   
Loading
@@ -786,7 +786,7 @@ describe GroupsController do
Loading
@@ -786,7 +786,7 @@ describe GroupsController do
get :index get :index
   
# Redirects to the dashboard # Redirects to the dashboard
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
   
Loading
@@ -810,7 +810,7 @@ describe GroupsController do
Loading
@@ -810,7 +810,7 @@ describe GroupsController do
it 'deletes the group' do it 'deletes the group' do
delete :destroy, params: { id: group.to_param } delete :destroy, params: { id: group.to_param }
   
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
end end
Loading
Loading
Loading
@@ -101,7 +101,7 @@ describe HealthCheckController, :request_store do
Loading
@@ -101,7 +101,7 @@ describe HealthCheckController, :request_store do
it 'supports failure plaintext response' do it 'supports failure plaintext response' do
get :index get :index
   
expect(response).to have_gitlab_http_status(500) expect(response).to have_gitlab_http_status(:internal_server_error)
expect(response.content_type).to eq 'text/plain' expect(response.content_type).to eq 'text/plain'
expect(response.body).to include('The server is on fire') expect(response.body).to include('The server is on fire')
end end
Loading
@@ -109,7 +109,7 @@ describe HealthCheckController, :request_store do
Loading
@@ -109,7 +109,7 @@ describe HealthCheckController, :request_store do
it 'supports failure json response' do it 'supports failure json response' do
get :index, format: :json get :index, format: :json
   
expect(response).to have_gitlab_http_status(500) expect(response).to have_gitlab_http_status(:internal_server_error)
expect(response.content_type).to eq 'application/json' expect(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be false expect(json_response['healthy']).to be false
expect(json_response['message']).to include('The server is on fire') expect(json_response['message']).to include('The server is on fire')
Loading
@@ -118,7 +118,7 @@ describe HealthCheckController, :request_store do
Loading
@@ -118,7 +118,7 @@ describe HealthCheckController, :request_store do
it 'supports failure xml response' do it 'supports failure xml response' do
get :index, format: :xml get :index, format: :xml
   
expect(response).to have_gitlab_http_status(500) expect(response).to have_gitlab_http_status(:internal_server_error)
expect(response.content_type).to eq 'application/xml' expect(response.content_type).to eq 'application/xml'
expect(xml_response['healthy']).to be false expect(xml_response['healthy']).to be false
expect(xml_response['message']).to include('The server is on fire') expect(xml_response['message']).to include('The server is on fire')
Loading
@@ -127,7 +127,7 @@ describe HealthCheckController, :request_store do
Loading
@@ -127,7 +127,7 @@ describe HealthCheckController, :request_store do
it 'supports failure responses for specific checks' do it 'supports failure responses for specific checks' do
get :index, params: { checks: 'email' }, format: :json get :index, params: { checks: 'email' }, format: :json
   
expect(response).to have_gitlab_http_status(500) expect(response).to have_gitlab_http_status(:internal_server_error)
expect(response.content_type).to eq 'application/json' expect(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be false expect(json_response['healthy']).to be false
expect(json_response['message']).to include('Email is on fire') expect(json_response['message']).to include('Email is on fire')
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment