Commit 5d516cbc authored by Tetiana Chupryna's avatar Tetiana Chupryna Committed by Kamil Trzciński

Remove authorization from /managed_licenses

parent ed982e9f
...@@ -10,7 +10,7 @@ GET /projects/:id/managed_licenses ...@@ -10,7 +10,7 @@ GET /projects/:id/managed_licenses
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
| --------- | ------- | -------- | --------------------- | | --------- | ------- | -------- | --------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user | | `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
```bash ```bash
curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/1/managed_licenses curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/1/managed_licenses
......
...@@ -77,7 +77,7 @@ The following table depicts the various user permission levels in a project. ...@@ -77,7 +77,7 @@ The following table depicts the various user permission levels in a project.
| Update a container registry | | | ✓ | ✓ | ✓ | | Update a container registry | | | ✓ | ✓ | ✓ |
| Remove a container registry image | | | ✓ | ✓ | ✓ | | Remove a container registry image | | | ✓ | ✓ | ✓ |
| Create/edit/delete project milestones | | | ✓ | ✓ | ✓ | | Create/edit/delete project milestones | | | ✓ | ✓ | ✓ |
| View approved/blacklisted licenses **[ULTIMATE]** | | | ✓ | ✓ | ✓ | | View approved/blacklisted licenses **[ULTIMATE]** | ✓ | ✓ | ✓ | ✓ | ✓ |
| Use security dashboard **[ULTIMATE]** | | | ✓ | ✓ | ✓ | | Use security dashboard **[ULTIMATE]** | | | ✓ | ✓ | ✓ |
| Dismiss vulnerability **[ULTIMATE]** | | | ✓ | ✓ | ✓ | | Dismiss vulnerability **[ULTIMATE]** | | | ✓ | ✓ | ✓ |
| Apply code change suggestions | | | ✓ | ✓ | ✓ | | Apply code change suggestions | | | ✓ | ✓ | ✓ |
......
---
title: Remove authorization from /managed_licenses
merge_request: 8541
author:
type: changed
...@@ -4,7 +4,7 @@ module API ...@@ -4,7 +4,7 @@ module API
class ManagedLicenses < Grape::API class ManagedLicenses < Grape::API
include PaginationParams include PaginationParams
before { authenticate! } before { authenticate! unless route.settings[:skip_authentication] }
helpers do helpers do
# Make the software license policy specified by id in the request available # Make the software license policy specified by id in the request available
...@@ -31,6 +31,7 @@ module API ...@@ -31,6 +31,7 @@ module API
desc 'Get project software license policies' do desc 'Get project software license policies' do
success Entities::ManagedLicense success Entities::ManagedLicense
end end
route_setting :skip_authentication, true
params do params do
use :pagination use :pagination
end end
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
describe API::ManagedLicenses do describe API::ManagedLicenses do
let(:project) do let(:project) do
create(:project).tap do |p| create(:project, :public).tap do |p|
@software_license_policy = create(:software_license_policy, project: p) @software_license_policy = create(:software_license_policy, project: p)
end end
end end
...@@ -74,11 +74,30 @@ describe API::ManagedLicenses do ...@@ -74,11 +74,30 @@ describe API::ManagedLicenses do
end end
end end
context 'unauthorized user' do context 'with unauthorized user' do
it 'does not return project managed licenses' do it 'returns project managed licenses for public project' do
get api("/projects/#{project.id}/managed_licenses") get api("/projects/#{project.id}/managed_licenses")
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(200)
expect(response).to match_response_schema('managed_licenses', dir: 'ee')
end
it 'responses with 404 Not Found for not existing project' do
get api("/projects/0/managed_licenses")
expect(response).to have_gitlab_http_status(404)
end
context 'when project is private' do
before do
project.update!(visibility_level: 'private')
end
it 'responses with 404 Not Found' do
get api("/projects/#{project.id}/managed_licenses")
expect(response).to have_gitlab_http_status(404)
end
end end
end end
end end
......
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