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
91b056ee
Commit
91b056ee
authored
Dec 08, 2021
by
Mark Chao
Committed by
Stan Hu
Dec 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add subscription future entry type
This is similar to LicenseHistoryEntry type
parent
07df96fd
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
303 additions
and
0 deletions
+303
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+50
-0
ee/app/graphql/ee/types/query_type.rb
ee/app/graphql/ee/types/query_type.rb
+5
-0
ee/app/graphql/resolvers/admin/cloud_licenses/subscription_future_entries_resolver.rb
...in/cloud_licenses/subscription_future_entries_resolver.rb
+27
-0
ee/app/graphql/types/admin/cloud_licenses/subscription_future_entry_type.rb
...es/admin/cloud_licenses/subscription_future_entry_type.rb
+37
-0
ee/spec/graphql/resolvers/admin/cloud_licenses/subscription_future_entries_resolver_spec.rb
...oud_licenses/subscription_future_entries_resolver_spec.rb
+80
-0
ee/spec/graphql/types/admin/cloud_licenses/subscription_future_entry_type_spec.rb
...min/cloud_licenses/subscription_future_entry_type_spec.rb
+103
-0
ee/spec/graphql/types/query_type_spec.rb
ee/spec/graphql/types/query_type_spec.rb
+1
-0
No files found.
doc/api/graphql/reference/index.md
View file @
91b056ee
...
@@ -398,6 +398,16 @@ four standard [pagination arguments](#connection-pagination-arguments):
...
@@ -398,6 +398,16 @@ four standard [pagination arguments](#connection-pagination-arguments):
| <a id="querysnippetstype"></a>`type` | [`TypeEnum`](#typeenum) | Type of snippet. |
| <a id="querysnippetstype"></a>`type` | [`TypeEnum`](#typeenum) | Type of snippet. |
| <a id="querysnippetsvisibility"></a>`visibility` | [`VisibilityScopesEnum`](#visibilityscopesenum) | Visibility of the snippet. |
| <a id="querysnippetsvisibility"></a>`visibility` | [`VisibilityScopesEnum`](#visibilityscopesenum) | Visibility of the snippet. |
### `Query.subscriptionFutureEntries`
Fields related to entries in future subscriptions.
Returns [`SubscriptionFutureEntryConnection`](#subscriptionfutureentryconnection).
This field returns a [connection](#connections). It accepts the
four standard [pagination arguments](#connection-pagination-arguments):
`before: String`, `after: String`, `first: Int`, `last: Int`.
### `Query.timelogs`
### `Query.timelogs`
Find timelogs visible to the current user.
Find timelogs visible to the current user.
...
@@ -7566,6 +7576,29 @@ The edge type for [`Submodule`](#submodule).
...
@@ -7566,6 +7576,29 @@ The edge type for [`Submodule`](#submodule).
| <a id="submoduleedgecursor"></a>`cursor` | [`String!`](#string) | A cursor for use in pagination. |
| <a id="submoduleedgecursor"></a>`cursor` | [`String!`](#string) | A cursor for use in pagination. |
| <a id="submoduleedgenode"></a>`node` | [`Submodule`](#submodule) | The item at the end of the edge. |
| <a id="submoduleedgenode"></a>`node` | [`Submodule`](#submodule) | The item at the end of the edge. |
#### `SubscriptionFutureEntryConnection`
The connection type for [`SubscriptionFutureEntry`](#subscriptionfutureentry).
##### Fields
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="subscriptionfutureentryconnectionedges"></a>`edges` | [`[SubscriptionFutureEntryEdge]`](#subscriptionfutureentryedge) | A list of edges. |
| <a id="subscriptionfutureentryconnectionnodes"></a>`nodes` | [`[SubscriptionFutureEntry]`](#subscriptionfutureentry) | A list of nodes. |
| <a id="subscriptionfutureentryconnectionpageinfo"></a>`pageInfo` | [`PageInfo!`](#pageinfo) | Information to aid in pagination. |
#### `SubscriptionFutureEntryEdge`
The edge type for [`SubscriptionFutureEntry`](#subscriptionfutureentry).
##### Fields
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="subscriptionfutureentryedgecursor"></a>`cursor` | [`String!`](#string) | A cursor for use in pagination. |
| <a id="subscriptionfutureentryedgenode"></a>`node` | [`SubscriptionFutureEntry`](#subscriptionfutureentry) | The item at the end of the edge. |
#### `TerraformStateConnection`
#### `TerraformStateConnection`
The connection type for [`TerraformState`](#terraformstate).
The connection type for [`TerraformState`](#terraformstate).
...
@@ -14739,6 +14772,23 @@ Represents the Geo sync and verification state of a snippet repository.
...
@@ -14739,6 +14772,23 @@ Represents the Geo sync and verification state of a snippet repository.
| <a id="submoduletype"></a>`type` | [`EntryType!`](#entrytype) | Type of tree entry. |
| <a id="submoduletype"></a>`type` | [`EntryType!`](#entrytype) | Type of tree entry. |
| <a id="submoduleweburl"></a>`webUrl` | [`String`](#string) | Web URL for the sub-module. |
| <a id="submoduleweburl"></a>`webUrl` | [`String`](#string) | Web URL for the sub-module. |
### `SubscriptionFutureEntry`
Represents an entry from the future subscriptions.
#### Fields
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="subscriptionfutureentrycompany"></a>`company` | [`String`](#string) | Company of the licensee. |
| <a id="subscriptionfutureentryemail"></a>`email` | [`String`](#string) | Email of the licensee. |
| <a id="subscriptionfutureentryexpiresat"></a>`expiresAt` | [`Date`](#date) | Date when the license expires. |
| <a id="subscriptionfutureentryname"></a>`name` | [`String`](#string) | Name of the licensee. |
| <a id="subscriptionfutureentryplan"></a>`plan` | [`String!`](#string) | Name of the subscription plan. |
| <a id="subscriptionfutureentrystartsat"></a>`startsAt` | [`Date`](#date) | Date when the license started. |
| <a id="subscriptionfutureentrytype"></a>`type` | [`String!`](#string) | Type of license the subscription will yield. |
| <a id="subscriptionfutureentryusersinlicensecount"></a>`usersInLicenseCount` | [`Int`](#int) | Number of paid user seats. |
### `TaskCompletionStatus`
### `TaskCompletionStatus`
Completion status of tasks.
Completion status of tasks.
ee/app/graphql/ee/types/query_type.rb
View file @
91b056ee
...
@@ -63,6 +63,11 @@ module EE
...
@@ -63,6 +63,11 @@ module EE
resolver:
::
Resolvers
::
Admin
::
CloudLicenses
::
LicenseHistoryEntriesResolver
,
resolver:
::
Resolvers
::
Admin
::
CloudLicenses
::
LicenseHistoryEntriesResolver
,
description:
'Fields related to entries in the license history.'
description:
'Fields related to entries in the license history.'
field
:subscription_future_entries
,
::
Types
::
Admin
::
CloudLicenses
::
SubscriptionFutureEntryType
.
connection_type
,
null:
true
,
resolver:
::
Resolvers
::
Admin
::
CloudLicenses
::
SubscriptionFutureEntriesResolver
,
description:
'Fields related to entries in future subscriptions.'
field
:ci_minutes_usage
,
::
Types
::
Ci
::
Minutes
::
NamespaceMonthlyUsageType
.
connection_type
,
field
:ci_minutes_usage
,
::
Types
::
Ci
::
Minutes
::
NamespaceMonthlyUsageType
.
connection_type
,
null:
true
,
null:
true
,
description:
'Monthly CI minutes usage data for the current user.'
description:
'Monthly CI minutes usage data for the current user.'
...
...
ee/app/graphql/resolvers/admin/cloud_licenses/subscription_future_entries_resolver.rb
0 → 100644
View file @
91b056ee
# frozen_string_literal: true
module
Resolvers
module
Admin
module
CloudLicenses
class
SubscriptionFutureEntriesResolver
<
BaseResolver
include
Gitlab
::
Graphql
::
Authorize
::
AuthorizeResource
type
[
::
Types
::
Admin
::
CloudLicenses
::
SubscriptionFutureEntryType
],
null:
true
def
resolve
authorize!
::
Gitlab
::
CurrentSettings
.
future_subscriptions
.
each
do
|
subscription
|
subscription
[
'type'
]
=
subscription
[
'cloud_license_enabled'
]
?
License
::
CLOUD_LICENSE_TYPE
:
License
::
LICENSE_FILE_TYPE
end
end
private
def
authorize!
Ability
.
allowed?
(
context
[
:current_user
],
:read_licenses
)
||
raise_resource_not_available_error!
end
end
end
end
end
ee/app/graphql/types/admin/cloud_licenses/subscription_future_entry_type.rb
0 → 100644
View file @
91b056ee
# frozen_string_literal: true
module
Types
module
Admin
module
CloudLicenses
# rubocop: disable Graphql/AuthorizeTypes
class
SubscriptionFutureEntryType
<
BaseObject
field
:type
,
GraphQL
::
Types
::
String
,
null:
false
,
description:
'Type of license the subscription will yield.'
field
:plan
,
GraphQL
::
Types
::
String
,
null:
false
,
description:
'Name of the subscription plan.'
field
:name
,
GraphQL
::
Types
::
String
,
null:
true
,
description:
'Name of the licensee.'
field
:email
,
GraphQL
::
Types
::
String
,
null:
true
,
description:
'Email of the licensee.'
field
:company
,
GraphQL
::
Types
::
String
,
null:
true
,
description:
'Company of the licensee.'
field
:starts_at
,
::
Types
::
DateType
,
null:
true
,
description:
'Date when the license started.'
field
:expires_at
,
::
Types
::
DateType
,
null:
true
,
description:
'Date when the license expires.'
field
:users_in_license_count
,
GraphQL
::
Types
::
Int
,
null:
true
,
description:
'Number of paid user seats.'
graphql_name
'SubscriptionFutureEntry'
description
'Represents an entry from the future subscriptions'
end
end
end
end
ee/spec/graphql/resolvers/admin/cloud_licenses/subscription_future_entries_resolver_spec.rb
0 → 100644
View file @
91b056ee
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Resolvers
::
Admin
::
CloudLicenses
::
SubscriptionFutureEntriesResolver
do
include
GraphqlHelpers
describe
'#resolve'
do
subject
(
:result
)
{
resolve_entries
}
let_it_be
(
:admin
)
{
create
(
:admin
)
}
def
resolve_entries
(
current_user:
admin
)
resolve
(
described_class
,
ctx:
{
current_user:
current_user
})
end
context
'when current user is unauthorized'
do
it
'raises error'
do
unauthorized_user
=
create
(
:user
)
expect
do
resolve_entries
(
current_user:
unauthorized_user
)
end
.
to
raise_error
(
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
)
end
end
context
'when no subscriptions exist'
do
it
'returns an empty array'
,
:enable_admin_mode
do
allow
(
::
Gitlab
::
CurrentSettings
).
to
receive
(
:future_subscriptions
).
and_return
([])
expect
(
result
).
to
eq
([])
end
end
context
'when future subscriptions exist'
do
let
(
:cloud_license_enabled
)
{
true
}
let
(
:subscription
)
do
{
'cloud_license_enabled'
=>
cloud_license_enabled
,
'plan'
=>
'ultimate'
,
'name'
=>
'User Example'
,
'email'
=>
'user@example.com'
,
'company'
=>
'Example Inc.'
,
'starts_at'
=>
'2021-12-08'
,
'expires_at'
=>
'2022-12-08'
,
'users_in_license_count'
=>
25
}
end
before
do
allow
(
::
Gitlab
::
CurrentSettings
).
to
receive
(
:future_subscriptions
).
and_return
([
subscription
])
end
it
'returns the subscription future entries'
,
:enable_admin_mode
do
expect
(
result
).
to
match
(
[
hash_including
(
'type'
=>
'cloud'
,
'plan'
=>
'ultimate'
,
'name'
=>
'User Example'
,
'email'
=>
'user@example.com'
,
'company'
=>
'Example Inc.'
,
'starts_at'
=>
'2021-12-08'
,
'expires_at'
=>
'2022-12-08'
,
'users_in_license_count'
=>
25
)
]
)
end
context
'cloud_license_enabled is false'
do
let
(
:cloud_license_enabled
)
{
false
}
it
'returns type as license_file'
,
:enable_admin_mode
do
expect
(
result
.
first
).
to
include
(
'type'
=>
'license_file'
)
end
end
end
end
end
ee/spec/graphql/types/admin/cloud_licenses/subscription_future_entry_type_spec.rb
0 → 100644
View file @
91b056ee
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
GitlabSchema
.
types
[
'SubscriptionFutureEntry'
],
:enable_admin_mode
do
include
GraphqlHelpers
let_it_be
(
:admin
)
{
create
(
:admin
)
}
def
query
(
field_name
)
%(
{
subscriptionFutureEntries {
nodes {
#{field_name}
}
}
}
)
end
def
query_field
(
field_name
)
GitlabSchema
.
execute
(
query
(
field_name
),
context:
{
current_user:
admin
}).
as_json
end
it
{
expect
(
described_class
.
graphql_name
).
to
eq
(
'SubscriptionFutureEntry'
)
}
context
'with fields'
do
let
(
:fields
)
do
%w[plan name email company starts_at expires_at users_in_license_count]
end
it
{
expect
(
described_class
).
to
include_graphql_fields
(
*
fields
)
}
describe
'field values'
do
let_it_be
(
:starts_at
)
{
Date
.
current
-
3
.
months
}
let_it_be
(
:expires_at
)
{
Date
.
current
+
9
.
months
}
let_it_be
(
:subscription
)
do
{
'type'
=>
License
::
CLOUD_LICENSE_TYPE
,
'plan'
=>
'ultimate'
,
'name'
=>
'User Example'
,
'email'
=>
'user@example.com'
,
'company'
=>
'Example Inc.'
,
'starts_at'
=>
starts_at
,
'expires_at'
=>
expires_at
,
'users_in_license_count'
=>
25
}
end
subject
{
resolve_field
(
field_name
,
subscription
)
}
describe
'type'
do
let
(
:field_name
)
{
:type
}
it
{
is_expected
.
to
eq
(
License
::
CLOUD_LICENSE_TYPE
)
}
end
describe
'plan'
do
let
(
:field_name
)
{
:plan
}
it
{
is_expected
.
to
eq
(
'ultimate'
)
}
end
describe
'name'
do
let
(
:field_name
)
{
:name
}
it
{
is_expected
.
to
eq
(
'User Example'
)
}
end
describe
'email'
do
let
(
:field_name
)
{
:email
}
it
{
is_expected
.
to
eq
(
'user@example.com'
)
}
end
describe
'company'
do
let
(
:field_name
)
{
:company
}
it
{
is_expected
.
to
eq
(
'Example Inc.'
)
}
end
describe
'starts_at'
do
let
(
:field_name
)
{
:starts_at
}
it
{
is_expected
.
to
eq
(
starts_at
)
}
end
describe
'expires_at'
do
let
(
:field_name
)
{
:expires_at
}
it
{
is_expected
.
to
eq
(
expires_at
)
}
end
describe
'users_in_license_count'
do
let
(
:field_name
)
{
:users_in_license_count
}
it
{
is_expected
.
to
eq
(
25
)
}
end
end
end
end
ee/spec/graphql/types/query_type_spec.rb
View file @
91b056ee
...
@@ -11,6 +11,7 @@ RSpec.describe GitlabSchema.types['Query'] do
...
@@ -11,6 +11,7 @@ RSpec.describe GitlabSchema.types['Query'] do
:instance_security_dashboard
,
:instance_security_dashboard
,
:iteration
,
:iteration
,
:license_history_entries
,
:license_history_entries
,
:subscription_future_entries
,
:vulnerabilities
,
:vulnerabilities
,
:vulnerabilities_count_by_day
,
:vulnerabilities_count_by_day
,
:vulnerability
:vulnerability
...
...
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