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
c9492eb5
Commit
c9492eb5
authored
May 14, 2016
by
Drew Blessing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow adding a new license via the API
parent
6331bc87
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
66 additions
and
22 deletions
+66
-22
CHANGELOG-EE
CHANGELOG-EE
+1
-0
lib/api/api.rb
lib/api/api.rb
+2
-2
lib/api/license.rb
lib/api/license.rb
+36
-0
lib/api/license_info.rb
lib/api/license_info.rb
+0
-18
lib/api/license_templates.rb
lib/api/license_templates.rb
+1
-1
spec/requests/api/license_spec.rb
spec/requests/api/license_spec.rb
+25
-0
spec/requests/api/license_templates_spec.rb
spec/requests/api/license_templates_spec.rb
+1
-1
No files found.
CHANGELOG-EE
View file @
c9492eb5
...
...
@@ -4,6 +4,7 @@ v 8.8.0 (unreleased)
- [Elastic] Database indexer prints its status
- [Elastic][Fix] Database indexer skips projects with invalid HEAD reference
- Fix skipping pages when restoring backups
- Add EE license via API !400
- [Elastic] More efficient snippets search
- [Elastic] Add rake task for removing all indexes
- [Elastic] Add rake task for clearing indexing status
...
...
lib/api/api.rb
View file @
c9492eb5
...
...
@@ -56,12 +56,12 @@ module API
mount
::
API
::
Settings
mount
::
API
::
Keys
mount
::
API
::
Tags
mount
::
API
::
License
Info
mount
::
API
::
License
mount
::
API
::
Triggers
mount
::
API
::
Builds
mount
::
API
::
Variables
mount
::
API
::
Runners
mount
::
API
::
Licenses
mount
::
API
::
License
Template
s
mount
::
API
::
Subscriptions
end
end
lib/api/license.rb
0 → 100644
View file @
c9492eb5
module
API
class
License
<
Grape
::
API
before
{
authenticated_as_admin!
}
resource
:license
do
# Get information on the currently active license
#
# Example request:
# GET /license
get
do
license
=
::
License
.
current
present
license
,
with:
Entities
::
License
end
# Add a new license
#
# Parameters:
# license (required) - The license text
#
# Example request:
# POST /license
post
do
required_attributes!
[
:license
]
license
=
::
License
.
new
(
data:
params
[
:license
])
if
license
.
save
present
license
,
with:
Entities
::
License
else
render_api_error!
(
license
.
errors
.
full_messages
.
first
,
400
)
end
end
end
end
end
lib/api/license_info.rb
deleted
100644 → 0
View file @
6331bc87
module
API
class
LicenseInfo
<
Grape
::
API
before
{
authenticated_as_admin!
}
resource
:license
do
# Get information on the currently active license
#
# Example request:
# GET /license
get
do
@license
=
License
.
current
present
@license
,
with:
Entities
::
License
end
end
end
end
lib/api/licenses.rb
→
lib/api/license
_template
s.rb
View file @
c9492eb5
module
API
# Licenses API
class
Licenses
<
Grape
::
API
class
License
Template
s
<
Grape
::
API
PROJECT_TEMPLATE_REGEX
=
/[\<\{\[]
(project|description|
...
...
spec/requests/api/license_spec.rb
View file @
c9492eb5
...
...
@@ -24,4 +24,29 @@ describe API::API, api: true do
expect
(
response
.
status
).
to
eq
403
end
end
describe
'POST /license'
do
it
'adds a new license if admin is logged in'
do
post
api
(
'/license'
,
admin
),
license:
gl_license
.
export
expect
(
response
.
status
).
to
eq
201
expect
(
json_response
[
'user_limit'
]).
to
eq
0
expect
(
Date
.
parse
(
json_response
[
'starts_at'
])).
to
eq
Date
.
today
-
1
.
month
expect
(
Date
.
parse
(
json_response
[
'expires_at'
])).
to
eq
Date
.
today
+
11
.
months
expect
(
json_response
[
'active_users'
]).
to
eq
1
expect
(
json_response
[
'licensee'
]).
to_not
be_empty
end
it
'denies access if not admin'
do
post
api
(
'/license'
,
user
),
license:
license
expect
(
response
.
status
).
to
eq
403
end
it
'returns 400 if the license cannot be saved'
do
post
api
(
'/license'
,
admin
),
license:
'foo'
expect
(
response
.
status
).
to
eq
(
400
)
end
end
end
spec/requests/api/licenses_spec.rb
→
spec/requests/api/license
_template
s_spec.rb
View file @
c9492eb5
require
'spec_helper'
describe
API
::
Licenses
,
api:
true
do
describe
API
::
API
,
api:
true
do
include
ApiHelpers
describe
'Entity'
do
...
...
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