Commit 168c05ee authored by Philip Cunningham's avatar Philip Cunningham

Expose normalizedTargetUrl on DastSiteProfile

Exposes new field on GraphQL type for frontend.
parent fdc1d6a8
......@@ -5015,6 +5015,11 @@ type DastSiteProfile {
"""
id: DastSiteProfileID!
"""
Normalized URL of the target to be scanned
"""
normalizedTargetUrl: String
"""
The name of the site profile
"""
......
......@@ -13726,6 +13726,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "normalizedTargetUrl",
"description": "Normalized URL of the target to be scanned",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "profileName",
"description": "The name of the site profile",
......@@ -827,6 +827,7 @@ Represents a DAST Site Profile.
| ----- | ---- | ----------- |
| `editPath` | String | Relative web path to the edit page of a site profile |
| `id` | DastSiteProfileID! | ID of the site profile |
| `normalizedTargetUrl` | String | Normalized URL of the target to be scanned |
| `profileName` | String | The name of the site profile |
| `targetUrl` | String | The URL of the target to be scanned |
| `userPermissions` | DastSiteProfilePermissions! | Permissions for the current user on the resource |
......
......@@ -26,6 +26,9 @@ module Types
description: 'The current validation status of the site profile',
method: :status
field :normalized_target_url, GraphQL::STRING_TYPE, null: true,
description: 'Normalized URL of the target to be scanned'
def target_url
object.dast_site.url
end
......@@ -33,5 +36,9 @@ module Types
def edit_path
Rails.application.routes.url_helpers.edit_project_security_configuration_dast_profiles_dast_site_profile_path(object.project, object)
end
def normalized_target_url
DastSiteValidation.get_normalized_url_base(object.dast_site.url)
end
end
end
---
title: Expose normalizedTargetUrl on DastSiteProfile GraphQL type
merge_request: 48727
author:
type: added
......@@ -6,7 +6,7 @@ RSpec.describe GitlabSchema.types['DastSiteProfile'] do
let_it_be(:dast_site_profile) { create(:dast_site_profile) }
let_it_be(:project) { dast_site_profile.project }
let_it_be(:user) { create(:user) }
let_it_be(:fields) { %i[id profileName targetUrl editPath validationStatus userPermissions] }
let_it_be(:fields) { %i[id profileName targetUrl editPath validationStatus userPermissions normalizedTargetUrl] }
subject do
GitlabSchema.execute(
......@@ -46,6 +46,7 @@ RSpec.describe GitlabSchema.types['DastSiteProfile'] do
targetUrl
editPath
validationStatus
normalizedTargetUrl
}
}
}
......@@ -89,6 +90,14 @@ RSpec.describe GitlabSchema.types['DastSiteProfile'] do
end
end
describe 'normalized_target_url field' do
it 'is the normalized url of the associated dast_site' do
normalized_url = DastSiteValidation.get_normalized_url_base(dast_site_profile.dast_site.url)
expect(first_dast_site_profile['normalizedTargetUrl']).to eq(normalized_url)
end
end
context 'when there are no dast_site_profiles' do
let(:project) { create(:project) }
......
......@@ -18,6 +18,7 @@ RSpec.describe 'Query.project(fullPath).dastSiteProfile' do
profileName
targetUrl
validationStatus
normalizedTargetUrl
}
}
}
......
......@@ -23,6 +23,7 @@ RSpec.describe 'Query.project(fullPath).dastSiteProfiles' do
targetUrl
editPath
validationStatus
normalizedTargetUrl
}
}
}
......
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