Commit 411012c4 authored by Reuben Pereira's avatar Reuben Pereira

Merge branch '18792-allow-update-by-api1' into 'master'

Allow public projects API to modify container_registry_access_level

See merge request gitlab-org/gitlab!62662
parents 0b06542b 123c561f
...@@ -149,7 +149,8 @@ When the user is authenticated and `simple` is not set this returns something li ...@@ -149,7 +149,8 @@ When the user is authenticated and `simple` is not set this returns something li
"snippets_enabled": false, "snippets_enabled": false,
"can_create_merge_request_in": true, "can_create_merge_request_in": true,
"resolve_outdated_diff_discussions": false, "resolve_outdated_diff_discussions": false,
"container_registry_enabled": false, "container_registry_enabled": false, // deprecated, use container_registry_access_level instead
"container_registry_access_level": "disabled",
"created_at": "2013-09-30T13:46:02Z", "created_at": "2013-09-30T13:46:02Z",
"last_activity_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z",
"creator_id": 3, "creator_id": 3,
...@@ -238,7 +239,8 @@ When the user is authenticated and `simple` is not set this returns something li ...@@ -238,7 +239,8 @@ When the user is authenticated and `simple` is not set this returns something li
"snippets_enabled": false, "snippets_enabled": false,
"can_create_merge_request_in": true, "can_create_merge_request_in": true,
"resolve_outdated_diff_discussions": false, "resolve_outdated_diff_discussions": false,
"container_registry_enabled": false, "container_registry_enabled": false, // deprecated, use container_registry_access_level instead
"container_registry_access_level": "disabled",
"created_at": "2013-09-30T13:46:02Z", "created_at": "2013-09-30T13:46:02Z",
"last_activity_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z",
"creator_id": 3, "creator_id": 3,
...@@ -425,7 +427,8 @@ GET /users/:user_id/projects ...@@ -425,7 +427,8 @@ GET /users/:user_id/projects
"snippets_enabled": false, "snippets_enabled": false,
"can_create_merge_request_in": true, "can_create_merge_request_in": true,
"resolve_outdated_diff_discussions": false, "resolve_outdated_diff_discussions": false,
"container_registry_enabled": false, "container_registry_enabled": false, // deprecated, use container_registry_access_level instead
"container_registry_access_level": "disabled",
"created_at": "2013-09-30T13:46:02Z", "created_at": "2013-09-30T13:46:02Z",
"last_activity_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z",
"creator_id": 3, "creator_id": 3,
...@@ -514,7 +517,8 @@ GET /users/:user_id/projects ...@@ -514,7 +517,8 @@ GET /users/:user_id/projects
"snippets_enabled": false, "snippets_enabled": false,
"can_create_merge_request_in": true, "can_create_merge_request_in": true,
"resolve_outdated_diff_discussions": false, "resolve_outdated_diff_discussions": false,
"container_registry_enabled": false, "container_registry_enabled": false, // deprecated, use container_registry_access_level instead
"container_registry_access_level": "disabled",
"created_at": "2013-09-30T13:46:02Z", "created_at": "2013-09-30T13:46:02Z",
"last_activity_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z",
"creator_id": 3, "creator_id": 3,
...@@ -663,7 +667,8 @@ Example response: ...@@ -663,7 +667,8 @@ Example response:
"snippets_enabled": false, "snippets_enabled": false,
"can_create_merge_request_in": true, "can_create_merge_request_in": true,
"resolve_outdated_diff_discussions": false, "resolve_outdated_diff_discussions": false,
"container_registry_enabled": false, "container_registry_enabled": false, // deprecated, use container_registry_access_level instead
"container_registry_access_level": "disabled",
"created_at": "2013-09-30T13:46:02Z", "created_at": "2013-09-30T13:46:02Z",
"last_activity_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z",
"creator_id": 3, "creator_id": 3,
...@@ -745,7 +750,8 @@ Example response: ...@@ -745,7 +750,8 @@ Example response:
"snippets_enabled": false, "snippets_enabled": false,
"can_create_merge_request_in": true, "can_create_merge_request_in": true,
"resolve_outdated_diff_discussions": false, "resolve_outdated_diff_discussions": false,
"container_registry_enabled": false, "container_registry_enabled": false, // deprecated, use container_registry_access_level instead
"container_registry_access_level": "disabled",
"created_at": "2013-09-30T13:46:02Z", "created_at": "2013-09-30T13:46:02Z",
"last_activity_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z",
"creator_id": 3, "creator_id": 3,
...@@ -871,7 +877,8 @@ GET /projects/:id ...@@ -871,7 +877,8 @@ GET /projects/:id
"snippets_enabled": false, "snippets_enabled": false,
"can_create_merge_request_in": true, "can_create_merge_request_in": true,
"resolve_outdated_diff_discussions": false, "resolve_outdated_diff_discussions": false,
"container_registry_enabled": false, "container_registry_enabled": false, // deprecated, use container_registry_access_level instead
"container_registry_access_level": "disabled",
"container_expiration_policy": { "container_expiration_policy": {
"cadence": "7d", "cadence": "7d",
"enabled": false, "enabled": false,
...@@ -1181,7 +1188,8 @@ POST /projects ...@@ -1181,7 +1188,8 @@ POST /projects
| `builds_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. | | `builds_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. |
| `ci_config_path` | string | **{dotted-circle}** No | The path to CI configuration file. | | `ci_config_path` | string | **{dotted-circle}** No | The path to CI configuration file. |
| `container_expiration_policy_attributes` | hash | **{dotted-circle}** No | Update the image cleanup policy for this project. Accepts: `cadence` (string), `keep_n` (integer), `older_than` (string), `name_regex` (string), `name_regex_delete` (string), `name_regex_keep` (string), `enabled` (boolean). Valid values for `cadence` are: `1d` (every day), `7d` (every week), `14d` (every two weeks), `1month` (every month), or `3month` (every quarter). | | `container_expiration_policy_attributes` | hash | **{dotted-circle}** No | Update the image cleanup policy for this project. Accepts: `cadence` (string), `keep_n` (integer), `older_than` (string), `name_regex` (string), `name_regex_delete` (string), `name_regex_keep` (string), `enabled` (boolean). Valid values for `cadence` are: `1d` (every day), `7d` (every week), `14d` (every two weeks), `1month` (every month), or `3month` (every quarter). |
| `container_registry_enabled` | boolean | **{dotted-circle}** No | Enable container registry for this project. | | `container_registry_enabled` | boolean | **{dotted-circle}** No | _(Deprecated)_ Enable container registry for this project. Use `container_registry_access_level` instead. |
| `container_registry_access_level` | string | **{dotted-circle}** No | Set visibility of container registry, for this project, to one of `disabled`, `private` or `enabled`. |
| `default_branch` | string | **{dotted-circle}** No | The [default branch](../user/project/repository/branches/default.md) name. Requires `initialize_with_readme` to be `true`. | | `default_branch` | string | **{dotted-circle}** No | The [default branch](../user/project/repository/branches/default.md) name. Requires `initialize_with_readme` to be `true`. |
| `description` | string | **{dotted-circle}** No | Short project description. | | `description` | string | **{dotted-circle}** No | Short project description. |
| `emails_disabled` | boolean | **{dotted-circle}** No | Disable email notifications. | | `emails_disabled` | boolean | **{dotted-circle}** No | Disable email notifications. |
...@@ -1256,7 +1264,8 @@ POST /projects/user/:user_id ...@@ -1256,7 +1264,8 @@ POST /projects/user/:user_id
| `build_timeout` | integer | **{dotted-circle}** No | The maximum amount of time, in seconds, that a job can run. | | `build_timeout` | integer | **{dotted-circle}** No | The maximum amount of time, in seconds, that a job can run. |
| `builds_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. | | `builds_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. |
| `ci_config_path` | string | **{dotted-circle}** No | The path to CI configuration file. | | `ci_config_path` | string | **{dotted-circle}** No | The path to CI configuration file. |
| `container_registry_enabled` | boolean | **{dotted-circle}** No | Enable container registry for this project. | | `container_registry_enabled` | boolean | **{dotted-circle}** No | _(Deprecated)_ Enable container registry for this project. Use `container_registry_access_level` instead. |
| `container_registry_access_level` | string | **{dotted-circle}** No | Set visibility of container registry, for this project, to one of `disabled`, `private` or `enabled`. |
| `description` | string | **{dotted-circle}** No | Short project description. | | `description` | string | **{dotted-circle}** No | Short project description. |
| `default_branch` | string | **{dotted-circle}** No | The [default branch](../user/project/repository/branches/default.md) name. Requires `initialize_with_readme` to be `true`. | | `default_branch` | string | **{dotted-circle}** No | The [default branch](../user/project/repository/branches/default.md) name. Requires `initialize_with_readme` to be `true`. |
| `emails_disabled` | boolean | **{dotted-circle}** No | Disable email notifications. | | `emails_disabled` | boolean | **{dotted-circle}** No | Disable email notifications. |
...@@ -1333,7 +1342,8 @@ PUT /projects/:id ...@@ -1333,7 +1342,8 @@ PUT /projects/:id
| `ci_default_git_depth` | integer | **{dotted-circle}** No | Default number of revisions for [shallow cloning](../ci/pipelines/settings.md#limit-the-number-of-changes-fetched-during-clone). | | `ci_default_git_depth` | integer | **{dotted-circle}** No | Default number of revisions for [shallow cloning](../ci/pipelines/settings.md#limit-the-number-of-changes-fetched-during-clone). |
| `ci_forward_deployment_enabled` | boolean | **{dotted-circle}** No | When a new deployment job starts, [skip older deployment jobs](../ci/pipelines/settings.md#skip-outdated-deployment-jobs) that are still pending | | `ci_forward_deployment_enabled` | boolean | **{dotted-circle}** No | When a new deployment job starts, [skip older deployment jobs](../ci/pipelines/settings.md#skip-outdated-deployment-jobs) that are still pending |
| `container_expiration_policy_attributes` | hash | **{dotted-circle}** No | Update the image cleanup policy for this project. Accepts: `cadence` (string), `keep_n` (integer), `older_than` (string), `name_regex` (string), `name_regex_delete` (string), `name_regex_keep` (string), `enabled` (boolean). | | `container_expiration_policy_attributes` | hash | **{dotted-circle}** No | Update the image cleanup policy for this project. Accepts: `cadence` (string), `keep_n` (integer), `older_than` (string), `name_regex` (string), `name_regex_delete` (string), `name_regex_keep` (string), `enabled` (boolean). |
| `container_registry_enabled` | boolean | **{dotted-circle}** No | Enable container registry for this project. | | `container_registry_enabled` | boolean | **{dotted-circle}** No | _(Deprecated)_ Enable container registry for this project. Use `container_registry_access_level` instead. |
| `container_registry_access_level` | string | **{dotted-circle}** No | Set visibility of container registry, for this project, to one of `disabled`, `private` or `enabled`. |
| `default_branch` | string | **{dotted-circle}** No | The [default branch](../user/project/repository/branches/default.md) name. | | `default_branch` | string | **{dotted-circle}** No | The [default branch](../user/project/repository/branches/default.md) name. |
| `description` | string | **{dotted-circle}** No | Short project description. | | `description` | string | **{dotted-circle}** No | Short project description. |
| `emails_disabled` | boolean | **{dotted-circle}** No | Disable email notifications. | | `emails_disabled` | boolean | **{dotted-circle}** No | Disable email notifications. |
...@@ -1473,7 +1483,8 @@ Example responses: ...@@ -1473,7 +1483,8 @@ Example responses:
"snippets_enabled": false, "snippets_enabled": false,
"can_create_merge_request_in": true, "can_create_merge_request_in": true,
"resolve_outdated_diff_discussions": false, "resolve_outdated_diff_discussions": false,
"container_registry_enabled": false, "container_registry_enabled": false, // deprecated, use container_registry_access_level instead
"container_registry_access_level": "disabled",
"created_at": "2013-09-30T13:46:02Z", "created_at": "2013-09-30T13:46:02Z",
"last_activity_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z",
"creator_id": 3, "creator_id": 3,
...@@ -1565,7 +1576,8 @@ Example response: ...@@ -1565,7 +1576,8 @@ Example response:
"snippets_enabled": false, "snippets_enabled": false,
"can_create_merge_request_in": true, "can_create_merge_request_in": true,
"resolve_outdated_diff_discussions": false, "resolve_outdated_diff_discussions": false,
"container_registry_enabled": false, "container_registry_enabled": false, // deprecated, use container_registry_access_level instead
"container_registry_access_level": "disabled",
"created_at": "2013-09-30T13:46:02Z", "created_at": "2013-09-30T13:46:02Z",
"last_activity_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z",
"creator_id": 3, "creator_id": 3,
...@@ -1663,7 +1675,8 @@ Example response: ...@@ -1663,7 +1675,8 @@ Example response:
"snippets_enabled": false, "snippets_enabled": false,
"can_create_merge_request_in": true, "can_create_merge_request_in": true,
"resolve_outdated_diff_discussions": false, "resolve_outdated_diff_discussions": false,
"container_registry_enabled": false, "container_registry_enabled": false, // deprecated, use container_registry_access_level instead
"container_registry_access_level": "disabled",
"created_at": "2013-09-30T13:46:02Z", "created_at": "2013-09-30T13:46:02Z",
"last_activity_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z",
"creator_id": 3, "creator_id": 3,
...@@ -1841,7 +1854,8 @@ Example response: ...@@ -1841,7 +1854,8 @@ Example response:
"snippets_enabled": false, "snippets_enabled": false,
"can_create_merge_request_in": true, "can_create_merge_request_in": true,
"resolve_outdated_diff_discussions": false, "resolve_outdated_diff_discussions": false,
"container_registry_enabled": false, "container_registry_enabled": false, // deprecated, use container_registry_access_level instead
"container_registry_access_level": "disabled",
"created_at": "2013-09-30T13:46:02Z", "created_at": "2013-09-30T13:46:02Z",
"last_activity_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z",
"creator_id": 3, "creator_id": 3,
...@@ -1960,7 +1974,8 @@ Example response: ...@@ -1960,7 +1974,8 @@ Example response:
"snippets_enabled": false, "snippets_enabled": false,
"can_create_merge_request_in": true, "can_create_merge_request_in": true,
"resolve_outdated_diff_discussions": false, "resolve_outdated_diff_discussions": false,
"container_registry_enabled": false, "container_registry_enabled": false, // deprecated, use container_registry_access_level instead
"container_registry_access_level": "disabled",
"created_at": "2013-09-30T13:46:02Z", "created_at": "2013-09-30T13:46:02Z",
"last_activity_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z",
"creator_id": 3, "creator_id": 3,
...@@ -2563,7 +2578,8 @@ Example response: ...@@ -2563,7 +2578,8 @@ Example response:
"archived": false, "archived": false,
"visibility": "private", "visibility": "private",
"resolve_outdated_diff_discussions": false, "resolve_outdated_diff_discussions": false,
"container_registry_enabled": true, "container_registry_enabled": true, // deprecated, use container_registry_access_level instead
"container_registry_access_level": "enabled",
"container_expiration_policy": { "container_expiration_policy": {
"cadence": "7d", "cadence": "7d",
"enabled": false, "enabled": false,
......
...@@ -71,6 +71,7 @@ module API ...@@ -71,6 +71,7 @@ module API
expose(:pages_access_level) { |project, options| project.project_feature.string_access_level(:pages) } expose(:pages_access_level) { |project, options| project.project_feature.string_access_level(:pages) }
expose(:operations_access_level) { |project, options| project.project_feature.string_access_level(:operations) } expose(:operations_access_level) { |project, options| project.project_feature.string_access_level(:operations) }
expose(:analytics_access_level) { |project, options| project.project_feature.string_access_level(:analytics) } expose(:analytics_access_level) { |project, options| project.project_feature.string_access_level(:analytics) }
expose(:container_registry_access_level) { |project, options| project.project_feature.string_access_level(:container_registry) }
expose :emails_disabled expose :emails_disabled
expose :shared_runners_enabled expose :shared_runners_enabled
......
...@@ -35,13 +35,14 @@ module API ...@@ -35,13 +35,14 @@ module API
optional :pages_access_level, type: String, values: %w(disabled private enabled public), desc: 'Pages access level. One of `disabled`, `private`, `enabled` or `public`' optional :pages_access_level, type: String, values: %w(disabled private enabled public), desc: 'Pages access level. One of `disabled`, `private`, `enabled` or `public`'
optional :operations_access_level, type: String, values: %w(disabled private enabled), desc: 'Operations access level. One of `disabled`, `private` or `enabled`' optional :operations_access_level, type: String, values: %w(disabled private enabled), desc: 'Operations access level. One of `disabled`, `private` or `enabled`'
optional :analytics_access_level, type: String, values: %w(disabled private enabled), desc: 'Analytics access level. One of `disabled`, `private` or `enabled`' optional :analytics_access_level, type: String, values: %w(disabled private enabled), desc: 'Analytics access level. One of `disabled`, `private` or `enabled`'
optional :container_registry_access_level, type: String, values: %w(disabled private enabled), desc: 'Controls visibility of the container registry. One of `disabled`, `private` or `enabled`. `private` will make the container registry accessible only to project members (reporter role and above). `enabled` will make the container registry accessible to everyone who has access to the project. `disabled` will disable the container registry'
optional :emails_disabled, type: Boolean, desc: 'Disable email notifications' optional :emails_disabled, type: Boolean, desc: 'Disable email notifications'
optional :show_default_award_emojis, type: Boolean, desc: 'Show default award emojis' optional :show_default_award_emojis, type: Boolean, desc: 'Show default award emojis'
optional :shared_runners_enabled, type: Boolean, desc: 'Flag indication if shared runners are enabled for that project' optional :shared_runners_enabled, type: Boolean, desc: 'Flag indication if shared runners are enabled for that project'
optional :resolve_outdated_diff_discussions, type: Boolean, desc: 'Automatically resolve merge request diffs discussions on lines changed with a push' optional :resolve_outdated_diff_discussions, type: Boolean, desc: 'Automatically resolve merge request diffs discussions on lines changed with a push'
optional :remove_source_branch_after_merge, type: Boolean, desc: 'Remove the source branch by default after merge' optional :remove_source_branch_after_merge, type: Boolean, desc: 'Remove the source branch by default after merge'
optional :container_registry_enabled, type: Boolean, desc: 'Flag indication if the container registry is enabled for that project' optional :container_registry_enabled, type: Boolean, desc: 'Deprecated: Use :container_registry_access_level instead. Flag indication if the container registry is enabled for that project'
optional :container_expiration_policy_attributes, type: Hash do optional :container_expiration_policy_attributes, type: Hash do
use :optional_container_expiration_policy_params use :optional_container_expiration_policy_params
end end
...@@ -124,7 +125,7 @@ module API ...@@ -124,7 +125,7 @@ module API
:ci_config_path, :ci_config_path,
:ci_default_git_depth, :ci_default_git_depth,
:ci_forward_deployment_enabled, :ci_forward_deployment_enabled,
:container_registry_enabled, :container_registry_access_level,
:container_expiration_policy_attributes, :container_expiration_policy_attributes,
:default_branch, :default_branch,
:description, :description,
...@@ -169,7 +170,8 @@ module API ...@@ -169,7 +170,8 @@ module API
:jobs_enabled, :jobs_enabled,
:merge_requests_enabled, :merge_requests_enabled,
:wiki_enabled, :wiki_enabled,
:snippets_enabled :snippets_enabled,
:container_registry_enabled
] ]
end end
......
...@@ -121,7 +121,6 @@ project_feature: ...@@ -121,7 +121,6 @@ project_feature:
- project_id - project_id
- requirements_access_level - requirements_access_level
- security_and_compliance_access_level - security_and_compliance_access_level
- container_registry_access_level
- updated_at - updated_at
computed_attributes: computed_attributes:
- issues_enabled - issues_enabled
......
...@@ -207,6 +207,18 @@ RSpec.describe API::Projects do ...@@ -207,6 +207,18 @@ RSpec.describe API::Projects do
let(:current_user) { user } let(:current_user) { user }
end end
it 'includes container_registry_access_level', :aggregate_failures do
project.project_feature.update!(container_registry_access_level: ProjectFeature::DISABLED)
get api('/projects', user)
project_response = json_response.find { |p| p['id'] == project.id }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Array
expect(project_response['container_registry_access_level']).to eq('disabled')
expect(project_response['container_registry_enabled']).to eq(false)
end
context 'when some projects are in a group' do context 'when some projects are in a group' do
before do before do
create(:project, :public, group: create(:group)) create(:project, :public, group: create(:group))
...@@ -1042,7 +1054,7 @@ RSpec.describe API::Projects do ...@@ -1042,7 +1054,7 @@ RSpec.describe API::Projects do
expect(response).to have_gitlab_http_status(:bad_request) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "assigns attributes to project" do it "assigns attributes to project", :aggregate_failures do
project = attributes_for(:project, { project = attributes_for(:project, {
path: 'camelCasePath', path: 'camelCasePath',
issues_enabled: false, issues_enabled: false,
...@@ -1064,6 +1076,7 @@ RSpec.describe API::Projects do ...@@ -1064,6 +1076,7 @@ RSpec.describe API::Projects do
}).tap do |attrs| }).tap do |attrs|
attrs[:operations_access_level] = 'disabled' attrs[:operations_access_level] = 'disabled'
attrs[:analytics_access_level] = 'disabled' attrs[:analytics_access_level] = 'disabled'
attrs[:container_registry_access_level] = 'private'
end end
post api('/projects', user), params: project post api('/projects', user), params: project
...@@ -1071,7 +1084,10 @@ RSpec.describe API::Projects do ...@@ -1071,7 +1084,10 @@ RSpec.describe API::Projects do
expect(response).to have_gitlab_http_status(:created) expect(response).to have_gitlab_http_status(:created)
project.each_pair do |k, v| project.each_pair do |k, v|
next if %i[has_external_issue_tracker has_external_wiki issues_enabled merge_requests_enabled wiki_enabled storage_version].include?(k) next if %i[
has_external_issue_tracker has_external_wiki issues_enabled merge_requests_enabled wiki_enabled storage_version
container_registry_access_level
].include?(k)
expect(json_response[k.to_s]).to eq(v) expect(json_response[k.to_s]).to eq(v)
end end
...@@ -1083,6 +1099,18 @@ RSpec.describe API::Projects do ...@@ -1083,6 +1099,18 @@ RSpec.describe API::Projects do
expect(project.project_feature.wiki_access_level).to eq(ProjectFeature::DISABLED) expect(project.project_feature.wiki_access_level).to eq(ProjectFeature::DISABLED)
expect(project.operations_access_level).to eq(ProjectFeature::DISABLED) expect(project.operations_access_level).to eq(ProjectFeature::DISABLED)
expect(project.project_feature.analytics_access_level).to eq(ProjectFeature::DISABLED) expect(project.project_feature.analytics_access_level).to eq(ProjectFeature::DISABLED)
expect(project.project_feature.container_registry_access_level).to eq(ProjectFeature::PRIVATE)
end
it 'assigns container_registry_enabled to project', :aggregate_failures do
project = attributes_for(:project, { container_registry_enabled: true })
post api('/projects', user), params: project
expect(response).to have_gitlab_http_status(:created)
expect(json_response['container_registry_enabled']).to eq(true)
expect(json_response['container_registry_access_level']).to eq('enabled')
expect(Project.find_by(path: project[:path]).container_registry_access_level).to eq(ProjectFeature::ENABLED)
end end
it 'creates a project using a template' do it 'creates a project using a template' do
...@@ -1340,6 +1368,14 @@ RSpec.describe API::Projects do ...@@ -1340,6 +1368,14 @@ RSpec.describe API::Projects do
expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id) expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id)
end end
it 'includes container_registry_access_level', :aggregate_failures do
get api("/users/#{user4.id}/projects/", user)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Array
expect(json_response.first.keys).to include('container_registry_access_level')
end
context 'and using id_after' do context 'and using id_after' do
let!(:another_public_project) { create(:project, :public, name: 'another_public_project', creator_id: user4.id, namespace: user4.namespace) } let!(:another_public_project) { create(:project, :public, name: 'another_public_project', creator_id: user4.id, namespace: user4.namespace) }
...@@ -1649,6 +1685,59 @@ RSpec.describe API::Projects do ...@@ -1649,6 +1685,59 @@ RSpec.describe API::Projects do
expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_truthy expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_truthy
end end
context 'container_registry_enabled' do
using RSpec::Parameterized::TableSyntax
where(:container_registry_enabled, :container_registry_access_level) do
true | ProjectFeature::ENABLED
false | ProjectFeature::DISABLED
end
with_them do
it 'setting container_registry_enabled also sets container_registry_access_level', :aggregate_failures do
project_attributes = attributes_for(:project).tap do |attrs|
attrs[:container_registry_enabled] = container_registry_enabled
end
post api("/projects/user/#{user.id}", admin), params: project_attributes
project = Project.find_by(path: project_attributes[:path])
expect(response).to have_gitlab_http_status(:created)
expect(json_response['container_registry_access_level']).to eq(ProjectFeature.str_from_access_level(container_registry_access_level))
expect(json_response['container_registry_enabled']).to eq(container_registry_enabled)
expect(project.container_registry_access_level).to eq(container_registry_access_level)
expect(project.container_registry_enabled).to eq(container_registry_enabled)
end
end
end
context 'container_registry_access_level' do
using RSpec::Parameterized::TableSyntax
where(:container_registry_access_level, :container_registry_enabled) do
'enabled' | true
'private' | true
'disabled' | false
end
with_them do
it 'setting container_registry_access_level also sets container_registry_enabled', :aggregate_failures do
project_attributes = attributes_for(:project).tap do |attrs|
attrs[:container_registry_access_level] = container_registry_access_level
end
post api("/projects/user/#{user.id}", admin), params: project_attributes
project = Project.find_by(path: project_attributes[:path])
expect(response).to have_gitlab_http_status(:created)
expect(json_response['container_registry_access_level']).to eq(container_registry_access_level)
expect(json_response['container_registry_enabled']).to eq(container_registry_enabled)
expect(project.container_registry_access_level).to eq(ProjectFeature.access_level_from_str(container_registry_access_level))
expect(project.container_registry_enabled).to eq(container_registry_enabled)
end
end
end
end end
describe "POST /projects/:id/uploads/authorize" do describe "POST /projects/:id/uploads/authorize" do
...@@ -2034,6 +2123,7 @@ RSpec.describe API::Projects do ...@@ -2034,6 +2123,7 @@ RSpec.describe API::Projects do
expect(json_response['jobs_enabled']).to be_present expect(json_response['jobs_enabled']).to be_present
expect(json_response['snippets_enabled']).to be_present expect(json_response['snippets_enabled']).to be_present
expect(json_response['container_registry_enabled']).to be_present expect(json_response['container_registry_enabled']).to be_present
expect(json_response['container_registry_access_level']).to be_present
expect(json_response['created_at']).to be_present expect(json_response['created_at']).to be_present
expect(json_response['last_activity_at']).to be_present expect(json_response['last_activity_at']).to be_present
expect(json_response['shared_runners_enabled']).to be_present expect(json_response['shared_runners_enabled']).to be_present
...@@ -2125,6 +2215,7 @@ RSpec.describe API::Projects do ...@@ -2125,6 +2215,7 @@ RSpec.describe API::Projects do
expect(json_response['resolve_outdated_diff_discussions']).to eq(project.resolve_outdated_diff_discussions) expect(json_response['resolve_outdated_diff_discussions']).to eq(project.resolve_outdated_diff_discussions)
expect(json_response['remove_source_branch_after_merge']).to be_truthy expect(json_response['remove_source_branch_after_merge']).to be_truthy
expect(json_response['container_registry_enabled']).to be_present expect(json_response['container_registry_enabled']).to be_present
expect(json_response['container_registry_access_level']).to be_present
expect(json_response['created_at']).to be_present expect(json_response['created_at']).to be_present
expect(json_response['last_activity_at']).to be_present expect(json_response['last_activity_at']).to be_present
expect(json_response['shared_runners_enabled']).to be_present expect(json_response['shared_runners_enabled']).to be_present
...@@ -2951,6 +3042,14 @@ RSpec.describe API::Projects do ...@@ -2951,6 +3042,14 @@ RSpec.describe API::Projects do
end end
end end
it 'sets container_registry_access_level', :aggregate_failures do
put api("/projects/#{project.id}", user), params: { container_registry_access_level: 'private' }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['container_registry_access_level']).to eq('private')
expect(Project.find_by(path: project[:path]).container_registry_access_level).to eq(ProjectFeature::PRIVATE)
end
it 'returns 400 when nothing sent' do it 'returns 400 when nothing sent' do
project_param = {} project_param = {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment