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
d1dd757f
Commit
d1dd757f
authored
Jan 14, 2021
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GraphQL mutation for activation
For cloud license feature
parent
553fff95
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
275 additions
and
0 deletions
+275
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+31
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+115
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+9
-0
ee/app/graphql/ee/types/mutation_type.rb
ee/app/graphql/ee/types/mutation_type.rb
+1
-0
ee/app/graphql/mutations/gitlab_subscriptions/activate.rb
ee/app/graphql/mutations/gitlab_subscriptions/activate.rb
+23
-0
ee/spec/graphql/mutations/gitlab_subscriptions/activate_spec.rb
...c/graphql/mutations/gitlab_subscriptions/activate_spec.rb
+51
-0
ee/spec/requests/api/graphql/mutations/gitlab_subscriptions/activate_spec.rb
...i/graphql/mutations/gitlab_subscriptions/activate_spec.rb
+45
-0
No files found.
doc/api/graphql/reference/gitlab_schema.graphql
View file @
d1dd757f
...
...
@@ -9841,6 +9841,36 @@ Identifier of Gitlab::ErrorTracking::DetailedError
"""
scalar
GitlabErrorTrackingDetailedErrorID
"""
Autogenerated input type of GitlabSubscriptionActivate
"""
input
GitlabSubscriptionActivateInput
{
"""
Activation
code
received
after
purchasing
a
GitLab
subscription
.
"""
activationCode
:
String
!
"""
A
unique
identifier
for
the
client
performing
the
mutation
.
"""
clientMutationId
:
String
}
"""
Autogenerated return type of GitlabSubscriptionActivate
"""
type
GitlabSubscriptionActivatePayload
{
"""
A
unique
identifier
for
the
client
performing
the
mutation
.
"""
clientMutationId
:
String
"""
Errors
encountered
during
execution
of
the
mutation
.
"""
errors
:
[
String
!]!
}
type
GrafanaIntegration
{
"""
Timestamp
of
the
issue
'
s
creation
...
...
@@ -15531,6 +15561,7 @@ type Mutation {
epicSetSubscription
(
input
:
EpicSetSubscriptionInput
!):
EpicSetSubscriptionPayload
epicTreeReorder
(
input
:
EpicTreeReorderInput
!):
EpicTreeReorderPayload
exportRequirements
(
input
:
ExportRequirementsInput
!):
ExportRequirementsPayload
gitlabSubscriptionActivate
(
input
:
GitlabSubscriptionActivateInput
!):
GitlabSubscriptionActivatePayload
httpIntegrationCreate
(
input
:
HttpIntegrationCreateInput
!):
HttpIntegrationCreatePayload
httpIntegrationDestroy
(
input
:
HttpIntegrationDestroyInput
!):
HttpIntegrationDestroyPayload
httpIntegrationResetToken
(
input
:
HttpIntegrationResetTokenInput
!):
HttpIntegrationResetTokenPayload
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
d1dd757f
...
...
@@ -27324,6 +27324,94 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "GitlabSubscriptionActivateInput",
"description": "Autogenerated input type of GitlabSubscriptionActivate",
"fields": null,
"inputFields": [
{
"name": "activationCode",
"description": "Activation code received after purchasing a GitLab subscription.",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "clientMutationId",
"description": "A unique identifier for the client performing the mutation.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "GitlabSubscriptionActivatePayload",
"description": "Autogenerated return type of GitlabSubscriptionActivate",
"fields": [
{
"name": "clientMutationId",
"description": "A unique identifier for the client performing the mutation.",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "errors",
"description": "Errors encountered during execution of the mutation.",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "GrafanaIntegration",
...
...
@@ -44309,6 +44397,33 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "gitlabSubscriptionActivate",
"description": null,
"args": [
{
"name": "input",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "INPUT_OBJECT",
"name": "GitlabSubscriptionActivateInput",
"ofType": null
}
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
"name": "GitlabSubscriptionActivatePayload",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "httpIntegrationCreate",
"description": null,
doc/api/graphql/reference/index.md
View file @
d1dd757f
...
...
@@ -1601,6 +1601,15 @@ Represents an external issue.
|
`url`
| String | The user-facing URL for this Geo node |
|
`verificationMaxCapacity`
| Int | The maximum concurrency of repository verification for this secondary node |
### GitlabSubscriptionActivatePayload
Autogenerated return type of GitlabSubscriptionActivate.
| Field | Type | Description |
| ----- | ---- | ----------- |
|
`clientMutationId`
| String | A unique identifier for the client performing the mutation. |
|
`errors`
| String! => Array | Errors encountered during execution of the mutation. |
### GrafanaIntegration
| Field | Type | Description |
...
...
ee/app/graphql/ee/types/mutation_type.rb
View file @
d1dd757f
...
...
@@ -22,6 +22,7 @@ module EE
mount_mutation
::
Mutations
::
Epics
::
Create
mount_mutation
::
Mutations
::
Epics
::
SetSubscription
mount_mutation
::
Mutations
::
Epics
::
AddIssue
mount_mutation
::
Mutations
::
GitlabSubscriptions
::
Activate
mount_mutation
::
Mutations
::
Iterations
::
Create
mount_mutation
::
Mutations
::
Iterations
::
Update
mount_mutation
::
Mutations
::
RequirementsManagement
::
CreateRequirement
...
...
ee/app/graphql/mutations/gitlab_subscriptions/activate.rb
0 → 100644
View file @
d1dd757f
# frozen_string_literal: true
module
Mutations
module
GitlabSubscriptions
class
Activate
<
BaseMutation
graphql_name
'GitlabSubscriptionActivate'
authorize
:manage_subscription
argument
:activation_code
,
GraphQL
::
STRING_TYPE
,
required:
true
,
description:
'Activation code received after purchasing a GitLab subscription.'
def
resolve
(
activation_code
:)
authorize!
:global
result
=
::
GitlabSubscriptions
::
ActivateService
.
new
.
execute
(
activation_code
)
{
errors:
Array
(
result
[
:errors
])
}
end
end
end
end
ee/spec/graphql/mutations/gitlab_subscriptions/activate_spec.rb
0 → 100644
View file @
d1dd757f
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Mutations
::
GitlabSubscriptions
::
Activate
do
include
AdminModeHelper
subject
(
:mutation
)
{
described_class
.
new
(
object:
nil
,
context:
{
current_user:
user
},
field:
nil
)
}
let_it_be
(
:user
)
{
create
(
:admin
)
}
let
(
:activation_code
)
{
'activation_code'
}
let
(
:result
)
{
{
success:
true
}
}
describe
'#resolve'
do
before
do
enable_admin_mode!
(
user
)
allow_next_instance_of
(
::
GitlabSubscriptions
::
ActivateService
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
).
with
(
activation_code
).
and_return
(
result
)
end
end
context
'when successful'
do
it
'adds the issue to the epic'
do
result
=
mutation
.
resolve
(
activation_code:
activation_code
)
expect
(
result
).
to
eq
({
errors:
[]
})
end
end
context
'when failure'
do
let
(
:result
)
{
{
success:
false
,
errors:
[
'foo'
]
}
}
it
'returns errors'
do
result
=
mutation
.
resolve
(
activation_code:
activation_code
)
expect
(
result
).
to
eq
({
errors:
[
'foo'
]
})
end
end
context
'when non-admin'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
it
'raises errors'
do
expect
do
mutation
.
resolve
(
activation_code:
activation_code
)
end
.
to
raise_error
(
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
)
end
end
end
end
ee/spec/requests/api/graphql/mutations/gitlab_subscriptions/activate_spec.rb
0 → 100644
View file @
d1dd757f
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'Activate a subscription'
do
include
GraphqlHelpers
let_it_be
(
:current_user
)
{
create
(
:admin
)
}
let!
(
:application_setting
)
do
stub_env
(
'IN_MEMORY_APPLICATION_SETTINGS'
,
'false'
)
create
(
:application_setting
,
cloud_license_enabled:
true
)
end
let
(
:authentication_token
)
{
'authentication_token'
}
let
(
:mutation
)
do
graphql_mutation
(
:gitlab_subscription_activate
,
{
activation_code:
'abc'
})
end
let
(
:remote_response
)
do
{
success:
true
,
data:
{
"data"
=>
{
"cloudActivationActivate"
=>
{
"authenticationToken"
=>
authentication_token
,
"errors"
=>
[]
}
}
}
}
end
before
do
allow
(
Gitlab
::
SubscriptionPortal
::
Client
).
to
receive
(
:http_post
).
and_return
(
remote_response
)
end
it
'persists authentication token'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
:success
)
expect
(
graphql_mutation_response
(
:gitlab_subscription_activate
)[
'errors'
]).
to
be_empty
expect
(
application_setting
.
reload
.
cloud_license_auth_token
).
to
eq
(
authentication_token
)
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