Commit 15f8fdad authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch 'switch-query-id-in-scanner-profiles-238963' into 'master'

Add global_id field to DastScannerProfiles

See merge request gitlab-org/gitlab!40225
parents c0faec2f 2d23ada5
...@@ -2908,7 +2908,12 @@ type DastScannerProfile { ...@@ -2908,7 +2908,12 @@ type DastScannerProfile {
""" """
ID of the DAST scanner profile ID of the DAST scanner profile
""" """
id: ID! globalId: DastScannerProfileID!
"""
ID of the DAST scanner profile. Deprecated in 13.4: Use `global_id`
"""
id: ID! @deprecated(reason: "Use `global_id`. Deprecated in 13.4")
""" """
Name of the DAST scanner profile Name of the DAST scanner profile
...@@ -2993,7 +2998,12 @@ type DastScannerProfileCreatePayload { ...@@ -2993,7 +2998,12 @@ type DastScannerProfileCreatePayload {
""" """
ID of the scanner profile. ID of the scanner profile.
""" """
id: ID globalId: DastScannerProfileID
"""
ID of the scanner profile.. Deprecated in 13.4: Use `global_id`
"""
id: ID @deprecated(reason: "Use `global_id`. Deprecated in 13.4")
} }
""" """
......
...@@ -7866,7 +7866,7 @@ ...@@ -7866,7 +7866,7 @@
"description": "Represents a DAST scanner profile.", "description": "Represents a DAST scanner profile.",
"fields": [ "fields": [
{ {
"name": "id", "name": "globalId",
"description": "ID of the DAST scanner profile", "description": "ID of the DAST scanner profile",
"args": [ "args": [
...@@ -7876,13 +7876,31 @@ ...@@ -7876,13 +7876,31 @@
"name": null, "name": null,
"ofType": { "ofType": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "ID", "name": "DastScannerProfileID",
"ofType": null "ofType": null
} }
}, },
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "id",
"description": "ID of the DAST scanner profile. Deprecated in 13.4: Use `global_id`",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"isDeprecated": true,
"deprecationReason": "Use `global_id`. Deprecated in 13.4"
},
{ {
"name": "profileName", "name": "profileName",
"description": "Name of the DAST scanner profile", "description": "Name of the DAST scanner profile",
...@@ -8115,18 +8133,32 @@ ...@@ -8115,18 +8133,32 @@
"deprecationReason": null "deprecationReason": null
}, },
{ {
"name": "id", "name": "globalId",
"description": "ID of the scanner profile.", "description": "ID of the scanner profile.",
"args": [ "args": [
], ],
"type": { "type": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "ID", "name": "DastScannerProfileID",
"ofType": null "ofType": null
}, },
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
},
{
"name": "id",
"description": "ID of the scanner profile.. Deprecated in 13.4: Use `global_id`",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
},
"isDeprecated": true,
"deprecationReason": "Use `global_id`. Deprecated in 13.4"
} }
], ],
"inputFields": null, "inputFields": null,
...@@ -506,7 +506,8 @@ Represents a DAST scanner profile. ...@@ -506,7 +506,8 @@ Represents a DAST scanner profile.
| Name | Type | Description | | Name | Type | Description |
| --- | ---- | ---------- | | --- | ---- | ---------- |
| `id` | ID! | ID of the DAST scanner profile | | `globalId` | DastScannerProfileID! | ID of the DAST scanner profile |
| `id` **{warning-solid}** | ID! | **Deprecated:** Use `global_id`. Deprecated in 13.4 |
| `profileName` | String | Name of the DAST scanner profile | | `profileName` | String | Name of the DAST scanner profile |
| `spiderTimeout` | Int | The maximum number of seconds allowed for the spider to traverse the site | | `spiderTimeout` | Int | The maximum number of seconds allowed for the spider to traverse the site |
| `targetTimeout` | Int | The maximum number of seconds allowed for the site under test to respond to a request | | `targetTimeout` | Int | The maximum number of seconds allowed for the site under test to respond to a request |
...@@ -519,7 +520,8 @@ Autogenerated return type of DastScannerProfileCreate ...@@ -519,7 +520,8 @@ Autogenerated return type of DastScannerProfileCreate
| --- | ---- | ---------- | | --- | ---- | ---------- |
| `clientMutationId` | String | A unique identifier for the client performing the mutation. | | `clientMutationId` | String | A unique identifier for the client performing the mutation. |
| `errors` | String! => Array | Errors encountered during execution of the mutation. | | `errors` | String! => Array | Errors encountered during execution of the mutation. |
| `id` | ID | ID of the scanner profile. | | `globalId` | DastScannerProfileID | ID of the scanner profile. |
| `id` **{warning-solid}** | ID | **Deprecated:** Use `global_id`. Deprecated in 13.4 |
## DastScannerProfileUpdatePayload ## DastScannerProfileUpdatePayload
......
...@@ -8,6 +8,11 @@ module Mutations ...@@ -8,6 +8,11 @@ module Mutations
graphql_name 'DastScannerProfileCreate' graphql_name 'DastScannerProfileCreate'
field :id, GraphQL::ID_TYPE, field :id, GraphQL::ID_TYPE,
null: true,
description: 'ID of the scanner profile.',
deprecated: { reason: 'Use `global_id`', milestone: '13.4' }
field :global_id, ::Types::GlobalIDType[::DastScannerProfile],
null: true, null: true,
description: 'ID of the scanner profile.' description: 'ID of the scanner profile.'
...@@ -36,7 +41,7 @@ module Mutations ...@@ -36,7 +41,7 @@ module Mutations
result = service.execute(name: profile_name, spider_timeout: spider_timeout, target_timeout: target_timeout) result = service.execute(name: profile_name, spider_timeout: spider_timeout, target_timeout: target_timeout)
if result.success? if result.success?
{ id: result.payload.to_global_id, errors: [] } { id: result.payload.to_global_id, global_id: result.payload.to_global_id, errors: [] }
else else
{ errors: result.errors } { errors: result.errors }
end end
......
...@@ -8,7 +8,12 @@ module Types ...@@ -8,7 +8,12 @@ module Types
authorize :create_on_demand_dast_scan authorize :create_on_demand_dast_scan
field :id, GraphQL::ID_TYPE, null: false, field :id, GraphQL::ID_TYPE, null: false,
description: 'ID of the DAST scanner profile' description: 'ID of the DAST scanner profile',
deprecated: { reason: 'Use `global_id`', milestone: '13.4' }
field :global_id, ::Types::GlobalIDType[::DastScannerProfile], null: false,
description: 'ID of the DAST scanner profile',
method: :id
field :profile_name, GraphQL::STRING_TYPE, null: true, field :profile_name, GraphQL::STRING_TYPE, null: true,
description: 'Name of the DAST scanner profile', description: 'Name of the DAST scanner profile',
......
---
title: Add global_id field to DastScannerProfiles::Create
merge_request: 40225
author:
type: added
...@@ -6,7 +6,7 @@ RSpec.describe GitlabSchema.types['DastScannerProfile'] do ...@@ -6,7 +6,7 @@ RSpec.describe GitlabSchema.types['DastScannerProfile'] do
let_it_be(:dast_scanner_profile) { create(:dast_scanner_profile) } let_it_be(:dast_scanner_profile) { create(:dast_scanner_profile) }
let_it_be(:project) { dast_scanner_profile.project } let_it_be(:project) { dast_scanner_profile.project }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:fields) { %i[id profileName spiderTimeout targetTimeout] } let_it_be(:fields) { %i[id globalId profileName spiderTimeout targetTimeout] }
let(:response) do let(:response) do
GitlabSchema.execute( GitlabSchema.execute(
...@@ -43,6 +43,7 @@ RSpec.describe GitlabSchema.types['DastScannerProfile'] do ...@@ -43,6 +43,7 @@ RSpec.describe GitlabSchema.types['DastScannerProfile'] do
dastScannerProfiles(first: 1) { dastScannerProfiles(first: 1) {
nodes { nodes {
id id
globalId
profileName profileName
targetTimeout targetTimeout
spiderTimeout spiderTimeout
......
...@@ -22,7 +22,13 @@ RSpec.describe 'Creating a DAST Scanner Profile' do ...@@ -22,7 +22,13 @@ RSpec.describe 'Creating a DAST Scanner Profile' do
it 'returns the dast_scanner_profile id' do it 'returns the dast_scanner_profile id' do
post_graphql_mutation(mutation, current_user: current_user) post_graphql_mutation(mutation, current_user: current_user)
expect(mutation_response["id"]).to eq(dast_scanner_profile.to_global_id.to_s) expect(mutation_response['id']).to eq(dast_scanner_profile.to_global_id.to_s)
end
it 'returns the dast_scanner_profile global_id' do
post_graphql_mutation(mutation, current_user: current_user)
expect(mutation_response['globalId']).to eq(dast_scanner_profile.to_global_id.to_s)
end end
context 'when dast_scanner_profile exists' do context 'when dast_scanner_profile exists' do
...@@ -33,7 +39,7 @@ RSpec.describe 'Creating a DAST Scanner Profile' do ...@@ -33,7 +39,7 @@ RSpec.describe 'Creating a DAST Scanner Profile' do
it 'returns errors' do it 'returns errors' do
post_graphql_mutation(mutation, current_user: current_user) post_graphql_mutation(mutation, current_user: current_user)
expect(mutation_response["errors"]).to include('Name has already been taken') expect(mutation_response['errors']).to include('Name has already been taken')
end end
end end
end end
......
...@@ -69,6 +69,12 @@ RSpec.describe 'Query.project(fullPath).dastScannerProfiles' do ...@@ -69,6 +69,12 @@ RSpec.describe 'Query.project(fullPath).dastScannerProfiles' do
it { is_expected.to eq(dast_scanner_profile.to_global_id.to_s) } it { is_expected.to eq(dast_scanner_profile.to_global_id.to_s) }
end end
describe 'first dast scanner profile globalId' do
subject { response_data.dig('project', 'dastScannerProfiles', 'nodes').first['globalId'] }
it { is_expected.to eq(dast_scanner_profile.to_global_id.to_s) }
end
context 'when on demand scan feature flag is disabled' do context 'when on demand scan feature flag is disabled' do
before do before do
stub_feature_flags(security_on_demand_scans_feature_flag: false) stub_feature_flags(security_on_demand_scans_feature_flag: false)
......
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