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 {
"""
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
......@@ -2993,7 +2998,12 @@ type DastScannerProfileCreatePayload {
"""
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 @@
"description": "Represents a DAST scanner profile.",
"fields": [
{
"name": "id",
"name": "globalId",
"description": "ID of the DAST scanner profile",
"args": [
......@@ -7876,13 +7876,31 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"name": "DastScannerProfileID",
"ofType": null
}
},
"isDeprecated": false,
"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",
"description": "Name of the DAST scanner profile",
......@@ -8115,18 +8133,32 @@
"deprecationReason": null
},
{
"name": "id",
"name": "globalId",
"description": "ID of the scanner profile.",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "ID",
"name": "DastScannerProfileID",
"ofType": null
},
"isDeprecated": false,
"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,
......@@ -506,7 +506,8 @@ Represents a DAST scanner profile.
| 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 |
| `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 |
......@@ -519,7 +520,8 @@ Autogenerated return type of DastScannerProfileCreate
| --- | ---- | ---------- |
| `clientMutationId` | String | A unique identifier for the client performing 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
......
......@@ -8,6 +8,11 @@ module Mutations
graphql_name 'DastScannerProfileCreate'
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,
description: 'ID of the scanner profile.'
......@@ -36,7 +41,7 @@ module Mutations
result = service.execute(name: profile_name, spider_timeout: spider_timeout, target_timeout: target_timeout)
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
{ errors: result.errors }
end
......
......@@ -8,7 +8,12 @@ module Types
authorize :create_on_demand_dast_scan
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,
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
let_it_be(:dast_scanner_profile) { create(:dast_scanner_profile) }
let_it_be(:project) { dast_scanner_profile.project }
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
GitlabSchema.execute(
......@@ -43,6 +43,7 @@ RSpec.describe GitlabSchema.types['DastScannerProfile'] do
dastScannerProfiles(first: 1) {
nodes {
id
globalId
profileName
targetTimeout
spiderTimeout
......
......@@ -22,7 +22,13 @@ RSpec.describe 'Creating a DAST Scanner Profile' do
it 'returns the dast_scanner_profile id' do
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
context 'when dast_scanner_profile exists' do
......@@ -33,7 +39,7 @@ RSpec.describe 'Creating a DAST Scanner Profile' do
it 'returns errors' do
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
......
......@@ -69,6 +69,12 @@ RSpec.describe 'Query.project(fullPath).dastScannerProfiles' do
it { is_expected.to eq(dast_scanner_profile.to_global_id.to_s) }
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
before do
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