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
edc6d00b
Commit
edc6d00b
authored
Nov 24, 2015
by
Patricio Cano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
License information can now be retrieved via the API
parent
437679ec
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
86 additions
and
1 deletion
+86
-1
CHANGELOG-EE
CHANGELOG-EE
+2
-1
doc/api/README.md
doc/api/README.md
+1
-0
doc/api/license.md
doc/api/license.md
+24
-0
lib/api/api.rb
lib/api/api.rb
+1
-0
lib/api/entities.rb
lib/api/entities.rb
+12
-0
lib/api/license_info.rb
lib/api/license_info.rb
+18
-0
spec/factories.rb
spec/factories.rb
+1
-0
spec/requests/api/license_spec.rb
spec/requests/api/license_spec.rb
+27
-0
No files found.
CHANGELOG-EE
View file @
edc6d00b
v 8.3.0 (unreleased)
- License information can now be retrieved via the API
v 8.2.0
- Invalidate stored jira password if the endpoint URL is changed
...
...
@@ -26,7 +27,7 @@ v 8.1.0
- Add documentation for "Share project with group" API call
- Added an issues template (Hannes Rosenögger)
- Add documentation for "Share project with group" API call
- Abiliy to disable 'Share with Group' feature (via UI and API)
- Abili
t
y to disable 'Share with Group' feature (via UI and API)
v 8.0.6
- No EE-specific changes
...
...
doc/api/README.md
View file @
edc6d00b
...
...
@@ -23,6 +23,7 @@
-
[
Namespaces
](
namespaces.md
)
-
[
Settings
](
settings.md
)
-
[
Keys
](
keys.md
)
-
[
License
](
license.md
)
## Clients
...
...
doc/api/license.md
0 → 100644
View file @
edc6d00b
# License
## Retrieve information about the current license
In order to retrieve the license information, you need to authenticate yourself
as an admin.
```
GET /license
```
```
json
{
"starts_at"
:
"2015-10-24"
,
"expires_at"
:
"2016-10-24"
,
"licensee"
:
{
"Name"
:
"John Doe"
,
"Company"
:
"Doe, Inc."
,
"Email"
:
"john@doe.com"
},
"user_limit"
:
100
,
"active_users"
:
60
}
```
\ No newline at end of file
lib/api/api.rb
View file @
edc6d00b
...
...
@@ -56,5 +56,6 @@ module API
mount
Settings
mount
Keys
mount
Tags
mount
LicenseInfo
end
end
lib/api/entities.rb
View file @
edc6d00b
...
...
@@ -373,5 +373,17 @@ module API
end
end
end
class
License
<
Grape
::
Entity
expose
:starts_at
,
:expires_at
,
:licensee
expose
:user_limit
do
|
license
,
options
|
license
.
restricted?
(
:active_user_count
)
?
license
.
restrictions
[
:active_user_count
]
:
0
end
expose
:active_users
do
|
license
,
options
|
::
User
.
active
.
count
end
end
end
end
lib/api/license_info.rb
0 → 100644
View file @
edc6d00b
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
spec/factories.rb
View file @
edc6d00b
...
...
@@ -225,6 +225,7 @@ FactoryGirl.define do
factory
:gitlab_license
,
class:
"Gitlab::License"
do
starts_at
{
Date
.
today
-
1
.
month
}
expires_at
{
Date
.
today
+
11
.
months
}
licensee
do
{
"Name"
=>
FFaker
::
Name
.
name
}
end
...
...
spec/requests/api/license_spec.rb
0 → 100644
View file @
edc6d00b
require
'spec_helper'
describe
API
::
API
,
api:
true
do
include
ApiHelpers
let
(
:gl_license
)
{
build
(
:gitlab_license
)
}
let
(
:license
)
{
build
(
:license
,
data:
gl_license
.
export
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:user
)
{
create
(
:user
)
}
describe
'GET /license'
do
it
'should retrieve the license information if admin is logged in'
do
get
api
(
'/license'
,
admin
)
expect
(
response
.
status
).
to
eq
200
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
'should deny access if not admin'
do
get
api
(
'/license'
,
user
)
expect
(
response
.
status
).
to
eq
403
end
end
end
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