Commit 77cec6bf authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'djadmin-scanner-profile-graphql-updates' into 'master'

Update DAST Scanner Profile mutations to return complete profile

See merge request gitlab-org/gitlab!83383
parents 499356ad 3c7b7d43
...@@ -1808,8 +1808,9 @@ Input type: `DastScannerProfileCreateInput` ...@@ -1808,8 +1808,9 @@ Input type: `DastScannerProfileCreateInput`
| Name | Type | Description | | Name | Type | Description |
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| <a id="mutationdastscannerprofilecreateclientmutationid"></a>`clientMutationId` | [`String`](#string) | A unique identifier for the client performing the mutation. | | <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="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` ### `Mutation.dastScannerProfileDelete`
...@@ -1853,8 +1854,9 @@ Input type: `DastScannerProfileUpdateInput` ...@@ -1853,8 +1854,9 @@ Input type: `DastScannerProfileUpdateInput`
| Name | Type | Description | | Name | Type | Description |
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| <a id="mutationdastscannerprofileupdateclientmutationid"></a>`clientMutationId` | [`String`](#string) | A unique identifier for the client performing the mutation. | | <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="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` ### `Mutation.dastSiteProfileCreate`
...@@ -9,7 +9,12 @@ module Mutations ...@@ -9,7 +9,12 @@ module Mutations
field :id, ::Types::GlobalIDType[::DastScannerProfile], field :id, ::Types::GlobalIDType[::DastScannerProfile],
null: true, 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, argument :full_path, GraphQL::Types::ID,
required: true, required: true,
...@@ -61,7 +66,7 @@ module Mutations ...@@ -61,7 +66,7 @@ module Mutations
) )
if result.success? 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 else
{ errors: result.errors } { errors: result.errors }
end end
......
...@@ -11,7 +11,12 @@ module Mutations ...@@ -11,7 +11,12 @@ module Mutations
field :id, ScannerProfileID, field :id, ScannerProfileID,
null: true, 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, argument :full_path, GraphQL::Types::ID,
required: false, required: false,
...@@ -58,7 +63,7 @@ module Mutations ...@@ -58,7 +63,7 @@ module Mutations
result = service.execute(**service_args, id: dast_scanner_profile.id) result = service.execute(**service_args, id: dast_scanner_profile.id)
if result.success? if result.success?
{ id: result.payload.to_global_id, errors: [] } { id: result.payload.to_global_id, dast_scanner_profile: result.payload, errors: [] }
else else
{ errors: result.errors } { errors: result.errors }
end end
......
...@@ -46,6 +46,10 @@ RSpec.describe Mutations::DastScannerProfiles::Create do ...@@ -46,6 +46,10 @@ RSpec.describe Mutations::DastScannerProfiles::Create do
expect(subject[:id]).to eq(dast_scanner_profile.to_global_id) expect(subject[:id]).to eq(dast_scanner_profile.to_global_id)
end 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 it 'calls the dast_scanner_profile creation service' do
service = double(described_class) service = double(described_class)
result = double('result', success?: false, errors: []) result = double('result', success?: false, errors: [])
......
...@@ -78,6 +78,10 @@ RSpec.describe Mutations::DastScannerProfiles::Update do ...@@ -78,6 +78,10 @@ RSpec.describe Mutations::DastScannerProfiles::Update do
end end
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 context 'when dast scanner profile does not exist' do
let(:scanner_profile_id) { Gitlab::GlobalId.build(nil, model_name: 'DastScannerProfile', id: 'does_not_exist') } 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 ...@@ -27,6 +27,11 @@ RSpec.describe 'Creating a DAST Scanner Profile' do
post_graphql_mutation(mutation, current_user: current_user) post_graphql_mutation(mutation, current_user: current_user)
expect(mutation_response['id']).to eq(global_id_of(dast_scanner_profile)) 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 end
it 'sets default values of omitted properties' do it 'sets default values of omitted properties' do
......
...@@ -39,6 +39,17 @@ RSpec.describe 'Update a DAST Scanner Profile' 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 cannot run an on-demand scan'
it_behaves_like 'an on-demand scan mutation when user can run an on-demand scan' do 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 it 'updates the dast_scanner_profile' do
subject 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