Commit 3c7b7d43 authored by Dheeraj Joshi's avatar Dheeraj Joshi Committed by Bob Van Landuyt

Update DAST Scanner Profile Mutations to return payload

  * Updates both Create & Update mutations

Changelog: changed
EE: true
parent d74aea9c
......@@ -1808,8 +1808,9 @@ Input type: `DastScannerProfileCreateInput`
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="mutationdastscannerprofilecreateclientmutationid"></a>`clientMutationId` | [`String`](#string) | A unique identifier for the client performing the mutation. |
| <a id="mutationdastscannerprofilecreatedastscannerprofile"></a>`dastScannerProfile` | [`DastScannerProfile`](#dastscannerprofile) | Created scanner profile. |
| <a id="mutationdastscannerprofilecreateerrors"></a>`errors` | [`[String!]!`](#string) | Errors encountered during execution of the mutation. |
| <a id="mutationdastscannerprofilecreateid"></a>`id` | [`DastScannerProfileID`](#dastscannerprofileid) | ID of the scanner profile. |
| <a id="mutationdastscannerprofilecreateid"></a>`id` **{warning-solid}** | [`DastScannerProfileID`](#dastscannerprofileid) | **Deprecated:** use `dastScannerProfile` field. Deprecated in 14.10. |
### `Mutation.dastScannerProfileDelete`
......@@ -1853,8 +1854,9 @@ Input type: `DastScannerProfileUpdateInput`
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="mutationdastscannerprofileupdateclientmutationid"></a>`clientMutationId` | [`String`](#string) | A unique identifier for the client performing the mutation. |
| <a id="mutationdastscannerprofileupdatedastscannerprofile"></a>`dastScannerProfile` | [`DastScannerProfile`](#dastscannerprofile) | Updated scanner profile. |
| <a id="mutationdastscannerprofileupdateerrors"></a>`errors` | [`[String!]!`](#string) | Errors encountered during execution of the mutation. |
| <a id="mutationdastscannerprofileupdateid"></a>`id` | [`DastScannerProfileID`](#dastscannerprofileid) | ID of the scanner profile. |
| <a id="mutationdastscannerprofileupdateid"></a>`id` **{warning-solid}** | [`DastScannerProfileID`](#dastscannerprofileid) | **Deprecated:** use `dastScannerProfile` field. Deprecated in 14.10. |
### `Mutation.dastSiteProfileCreate`
......@@ -9,7 +9,12 @@ module Mutations
field :id, ::Types::GlobalIDType[::DastScannerProfile],
null: true,
description: 'ID of the scanner profile.'
description: 'ID of the scanner profile.',
deprecated: { reason: 'use `dastScannerProfile` field', milestone: '14.10' }
field :dast_scanner_profile, ::Types::DastScannerProfileType,
null: true,
description: 'Created scanner profile.'
argument :full_path, GraphQL::Types::ID,
required: true,
......@@ -61,7 +66,7 @@ module Mutations
)
if result.success?
{ id: result.payload.to_global_id, global_id: result.payload.to_global_id, errors: [] }
{ id: result.payload.to_global_id, dast_scanner_profile: result.payload, errors: [] }
else
{ errors: result.errors }
end
......
......@@ -11,7 +11,12 @@ module Mutations
field :id, ScannerProfileID,
null: true,
description: 'ID of the scanner profile.'
description: 'ID of the scanner profile.',
deprecated: { reason: 'use `dastScannerProfile` field', milestone: '14.10' }
field :dast_scanner_profile, ::Types::DastScannerProfileType,
null: true,
description: 'Updated scanner profile.'
argument :full_path, GraphQL::Types::ID,
required: false,
......@@ -58,7 +63,7 @@ module Mutations
result = service.execute(**service_args, id: dast_scanner_profile.id)
if result.success?
{ id: result.payload.to_global_id, errors: [] }
{ id: result.payload.to_global_id, dast_scanner_profile: result.payload, errors: [] }
else
{ errors: result.errors }
end
......
......@@ -46,6 +46,10 @@ RSpec.describe Mutations::DastScannerProfiles::Create do
expect(subject[:id]).to eq(dast_scanner_profile.to_global_id)
end
it 'returns the complete dast_scanner_profile' do
expect(subject[:dast_scanner_profile]).to eq(dast_scanner_profile)
end
it 'calls the dast_scanner_profile creation service' do
service = double(described_class)
result = double('result', success?: false, errors: [])
......
......@@ -78,6 +78,10 @@ RSpec.describe Mutations::DastScannerProfiles::Update do
end
end
it 'returns the complete dast_scanner_profile' do
expect(subject[:dast_scanner_profile]).to eq(dast_scanner_profile)
end
context 'when dast scanner profile does not exist' do
let(:scanner_profile_id) { Gitlab::GlobalId.build(nil, model_name: 'DastScannerProfile', id: 'does_not_exist') }
......
......@@ -27,6 +27,11 @@ RSpec.describe 'Creating a DAST Scanner Profile' do
post_graphql_mutation(mutation, current_user: current_user)
expect(mutation_response['id']).to eq(global_id_of(dast_scanner_profile))
expect(mutation_response).to have_key('dastScannerProfile')
profile = mutation_response['dastScannerProfile']
expect(profile['id']).to eq(global_id_of(dast_scanner_profile))
expect(profile['profileName']).to eq(dast_scanner_profile.name)
end
it 'sets default values of omitted properties' do
......
......@@ -39,6 +39,17 @@ RSpec.describe 'Update a DAST Scanner Profile' do
it_behaves_like 'an on-demand scan mutation when user cannot run an on-demand scan'
it_behaves_like 'an on-demand scan mutation when user can run an on-demand scan' do
it 'returns the dast_scanner_profile' do
subject
expect(mutation_response['id']).to eq(global_id_of(dast_scanner_profile))
expect(mutation_response).to have_key('dastScannerProfile')
profile = mutation_response['dastScannerProfile']
expect(profile['id']).to eq(global_id_of(dast_scanner_profile))
expect(profile['profileName']).to eq(new_profile_name)
end
it 'updates the dast_scanner_profile' do
subject
......
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