Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4057f938
Commit
4057f938
authored
Dec 06, 2021
by
Tetiana Chupryna
Committed by
Russell Dickenson
Dec 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deprecate legacy policy approval status in API
parent
fbd35cb2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
10 deletions
+49
-10
doc/api/managed_licenses.md
doc/api/managed_licenses.md
+7
-4
ee/lib/api/managed_licenses.rb
ee/lib/api/managed_licenses.rb
+4
-4
ee/spec/requests/api/managed_licenses_spec.rb
ee/spec/requests/api/managed_licenses_spec.rb
+38
-2
No files found.
doc/api/managed_licenses.md
View file @
4057f938
...
@@ -6,6 +6,9 @@ info: To determine the technical writer assigned to the Stage/Group associated w
...
@@ -6,6 +6,9 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# Managed Licenses API **(ULTIMATE)**
# Managed Licenses API **(ULTIMATE)**
WARNING:
"approval" and "blacklisted" approval statuses are deprecated and scheduled to be changed to "allowed" and "denied" in GitLab 15.0.
## List managed licenses
## List managed licenses
Get all managed licenses for a given project.
Get all managed licenses for a given project.
...
@@ -78,10 +81,10 @@ POST /projects/:id/managed_licenses
...
@@ -78,10 +81,10 @@ POST /projects/:id/managed_licenses
| ------------- | ------- | -------- | ---------------------------- |
| ------------- | ------- | -------- | ---------------------------- |
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
index.md#namespaced-path-encoding
)
owned by the authenticated user |
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
index.md#namespaced-path-encoding
)
owned by the authenticated user |
|
`name`
| string | yes | The name of the managed license |
|
`name`
| string | yes | The name of the managed license |
|
`approval_status`
| string | yes | The approval status
. "approved" or "blacklisted"
|
|
`approval_status`
| string | yes | The approval status
of the license. "allowed" or "denied". "blacklisted" and "approved" are deprecated.
|
```
shell
```
shell
curl
--data
"name=MIT&approval_status=
blacklist
ed"
--header
"PRIVATE-TOKEN: <your_access_token>"
"https://gitlab.example.com/api/v4/projects/1/managed_licenses"
curl
--data
"name=MIT&approval_status=
deni
ed"
--header
"PRIVATE-TOKEN: <your_access_token>"
"https://gitlab.example.com/api/v4/projects/1/managed_licenses"
```
```
Example response:
Example response:
...
@@ -125,10 +128,10 @@ PATCH /projects/:id/managed_licenses/:managed_license_id
...
@@ -125,10 +128,10 @@ PATCH /projects/:id/managed_licenses/:managed_license_id
| --------------- | ------- | --------------------------------- | ------------------------------- |
| --------------- | ------- | --------------------------------- | ------------------------------- |
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
index.md#namespaced-path-encoding
)
owned by the authenticated user |
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
index.md#namespaced-path-encoding
)
owned by the authenticated user |
|
`managed_license_id`
| integer/string | yes | The ID or URL-encoded name of the license belonging to the project |
|
`managed_license_id`
| integer/string | yes | The ID or URL-encoded name of the license belonging to the project |
|
`approval_status`
| string | yes | The approval status
. "approved" or "blacklisted"
|
|
`approval_status`
| string | yes | The approval status
of the license. "allowed" or "denied". "blacklisted" and "approved" are deprecated.
|
```
shell
```
shell
curl
--request
PATCH
--data
"approval_status=
blacklist
ed"
\
curl
--request
PATCH
--data
"approval_status=
deni
ed"
\
--header
"PRIVATE-TOKEN: <your_access_token>"
"https://gitlab.example.com/api/v4/projects/1/managed_licenses/6"
--header
"PRIVATE-TOKEN: <your_access_token>"
"https://gitlab.example.com/api/v4/projects/1/managed_licenses/6"
```
```
...
...
ee/lib/api/managed_licenses.rb
View file @
4057f938
...
@@ -61,8 +61,8 @@ module API
...
@@ -61,8 +61,8 @@ module API
requires
:name
,
type:
String
,
desc:
'The name of the license'
requires
:name
,
type:
String
,
desc:
'The name of the license'
requires
:approval_status
,
requires
:approval_status
,
type:
String
,
type:
String
,
values:
%w(approved blacklisted)
,
values:
%w(a
llowed denied a
pproved blacklisted)
,
desc:
'The approval status of the license. "
blacklisted" or "approved"
.'
desc:
'The approval status of the license. "
allowed" or "denied". "blacklisted" and "approved" are deprecated
.'
end
end
post
':id/managed_licenses'
do
post
':id/managed_licenses'
do
authorize_can_admin!
authorize_can_admin!
...
@@ -88,8 +88,8 @@ module API
...
@@ -88,8 +88,8 @@ module API
optional
:name
,
type:
String
,
desc:
'The name of the license'
optional
:name
,
type:
String
,
desc:
'The name of the license'
optional
:approval_status
,
optional
:approval_status
,
type:
String
,
type:
String
,
values:
%w(approved blacklisted)
,
values:
%w(a
llowed denied a
pproved blacklisted)
,
desc:
'The approval status of the license. "
blacklisted" or "approved"
.'
desc:
'The approval status of the license. "
allowed" or "denied". "blacklisted" and "approved" are deprecated
.'
end
end
patch
':id/managed_licenses/:managed_license_id'
,
requirements:
{
managed_license_id:
/.*/
}
do
patch
':id/managed_licenses/:managed_license_id'
,
requirements:
{
managed_license_id:
/.*/
}
do
authorize_can_admin!
authorize_can_admin!
...
...
ee/spec/requests/api/managed_licenses_spec.rb
View file @
4057f938
...
@@ -141,7 +141,7 @@ RSpec.describe API::ManagedLicenses do
...
@@ -141,7 +141,7 @@ RSpec.describe API::ManagedLicenses do
post
api
(
"/projects/
#{
project
.
id
}
/managed_licenses"
,
maintainer_user
),
post
api
(
"/projects/
#{
project
.
id
}
/managed_licenses"
,
maintainer_user
),
params:
{
params:
{
name:
'NEW_LICENSE_NAME'
,
name:
'NEW_LICENSE_NAME'
,
approval_status:
'a
pprov
ed'
approval_status:
'a
llow
ed'
}
}
end
.
to
change
{
project
.
software_license_policies
.
count
}.
by
(
1
)
end
.
to
change
{
project
.
software_license_policies
.
count
}.
by
(
1
)
...
@@ -163,6 +163,22 @@ RSpec.describe API::ManagedLicenses do
...
@@ -163,6 +163,22 @@ RSpec.describe API::ManagedLicenses do
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
it
'creates managed license from deprecated approval status value'
do
expect
do
post
api
(
"/projects/
#{
project
.
id
}
/managed_licenses"
,
maintainer_user
),
params:
{
name:
'NEW_LICENSE_NAME'
,
approval_status:
'approved'
}
end
.
to
change
{
project
.
software_license_policies
.
count
}.
by
(
1
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
response
).
to
match_response_schema
(
'software_license_policy'
,
dir:
'ee'
)
expect
(
json_response
).
to
have_key
(
'id'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'NEW_LICENSE_NAME'
)
expect
(
json_response
[
'approval_status'
]).
to
eq
(
'approved'
)
end
end
end
context
'authorized user with read permissions'
do
context
'authorized user with read permissions'
do
...
@@ -210,7 +226,7 @@ RSpec.describe API::ManagedLicenses do
...
@@ -210,7 +226,7 @@ RSpec.describe API::ManagedLicenses do
initial_name
=
initial_license
.
name
initial_name
=
initial_license
.
name
initial_classification
=
initial_license
.
classification
initial_classification
=
initial_license
.
classification
patch
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
,
maintainer_user
),
patch
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
,
maintainer_user
),
params:
{
approval_status:
'
blacklist
ed'
}
params:
{
approval_status:
'
deni
ed'
}
updated_software_license_policy
=
project
.
software_license_policies
.
reload
.
first
updated_software_license_policy
=
project
.
software_license_policies
.
reload
.
first
...
@@ -231,6 +247,26 @@ RSpec.describe API::ManagedLicenses do
...
@@ -231,6 +247,26 @@ RSpec.describe API::ManagedLicenses do
expect
(
initial_classification
).
not_to
eq
(
updated_software_license_policy
.
classification
)
expect
(
initial_classification
).
not_to
eq
(
updated_software_license_policy
.
classification
)
end
end
it
'updates managed license data with deprecated approval status'
do
initial_license
=
project
.
software_license_policies
.
first
initial_id
=
initial_license
.
id
patch
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
software_license_policy
.
id
}
"
,
maintainer_user
),
params:
{
approval_status:
'blacklisted'
}
updated_software_license_policy
=
project
.
software_license_policies
.
reload
.
first
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'software_license_policy'
,
dir:
'ee'
)
# Check that response is equal to the updated object
expect
(
json_response
[
'id'
]).
to
eq
(
initial_id
)
expect
(
json_response
[
'name'
]).
to
eq
(
updated_software_license_policy
.
name
)
expect
(
json_response
[
'approval_status'
]).
to
eq
(
'blacklisted'
)
# Check that the approval status was updated
expect
(
updated_software_license_policy
).
to
be_denied
end
it
'responds with 404 Not Found if requesting non-existing managed license'
do
it
'responds with 404 Not Found if requesting non-existing managed license'
do
patch
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
non_existing_record_id
}
"
,
maintainer_user
)
patch
api
(
"/projects/
#{
project
.
id
}
/managed_licenses/
#{
non_existing_record_id
}
"
,
maintainer_user
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment