Commit 059a0149 authored by Pedro Pombeiro's avatar Pedro Pombeiro

Rename full_path argument to id

parent 54eca155
......@@ -8,9 +8,11 @@ module Mutations
authorize :update_runners_registration_token
argument :full_path, GraphQL::ID_TYPE,
required: false,
description: 'Full path of the project or group to reset the token for. Omit if resetting instance runner token.'
ScopeID = ::GraphQL::ID_TYPE
argument :id, ScopeID,
required: true,
description: 'ID of the project or group to reset the token for. Omit if resetting instance runner token.'
field :token,
GraphQL::STRING_TYPE,
......@@ -19,27 +21,27 @@ module Mutations
def resolve(**args)
{
token: reset_token(args[:full_path]),
token: reset_token(args[:id]),
errors: []
}
end
private
def find_object(full_path:)
return unless full_path
def find_object(id:)
return unless id
GitlabSchema.object_from_id(full_path, expected_type: [::Project, ::Group])
GitlabSchema.object_from_id(id, expected_type: [::Project, ::Group])
end
def reset_token(full_path)
if full_path.blank?
def reset_token(id)
if id.blank?
authorize!(:global)
ApplicationSetting.current.reset_runners_registration_token!
ApplicationSetting.current_without_cache.runners_registration_token
else
project_or_group = authorized_find!(full_path: full_path)
project_or_group = authorized_find!(id: id)
project_or_group.reset_runners_token!
project_or_group.runners_token
end
......
......@@ -3538,7 +3538,7 @@ Input type: `RunnersRegistrationTokenResetInput`
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="mutationrunnersregistrationtokenresetclientmutationid"></a>`clientMutationId` | [`String`](#string) | A unique identifier for the client performing the mutation. |
| <a id="mutationrunnersregistrationtokenresetfullpath"></a>`fullPath` | [`ID`](#id) | Full path of the project or group to reset the token for. Omit if resetting instance runner token. |
| <a id="mutationrunnersregistrationtokenresetid"></a>`id` | [`ID!`](#id) | ID of the project or group to reset the token for. Omit if resetting instance runner token. |
#### Fields
......
......@@ -50,7 +50,7 @@ RSpec.describe 'RunnersRegistrationTokenReset' do
end
context 'when bad arguments are provided' do
let(:input) { { full_path: 'some string' } }
let(:input) { { id: 'some string' } }
it 'returns errors' do
expect { subject }.not_to change { get_token }
......@@ -64,7 +64,7 @@ RSpec.describe 'RunnersRegistrationTokenReset' do
context 'applied to project' do
let_it_be(:project) { create_default(:project) }
let(:input) { { full_path: project.to_global_id.to_s } }
let(:input) { { id: project.to_global_id.to_s } }
include_context 'when unauthorized', 'project' do
let(:target) { project }
......@@ -82,7 +82,7 @@ RSpec.describe 'RunnersRegistrationTokenReset' do
context 'applied to group' do
let_it_be(:group) { create_default(:group) }
let(:input) { { full_path: group.to_global_id.to_s } }
let(:input) { { id: group.to_global_id.to_s } }
include_context 'when unauthorized', 'group' do
let(:target) { group }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment