Commit d63d3e1d authored by Luke Duncalfe's avatar Luke Duncalfe

Merge branch 'philipcunningham-make-dast-site-validation-state-nullable' into 'master'

Return NONE when DastSiteValidation does not exist

See merge request gitlab-org/gitlab!48751
parents f382d3e2 c39c35f9
...@@ -5342,6 +5342,11 @@ enum DastSiteProfileValidationStatusEnum { ...@@ -5342,6 +5342,11 @@ enum DastSiteProfileValidationStatusEnum {
""" """
INPROGRESS_VALIDATION INPROGRESS_VALIDATION
"""
No site validation exists
"""
NONE
""" """
Site validation process finished successfully Site validation process finished successfully
""" """
......
...@@ -14715,6 +14715,12 @@ ...@@ -14715,6 +14715,12 @@
"inputFields": null, "inputFields": null,
"interfaces": null, "interfaces": null,
"enumValues": [ "enumValues": [
{
"name": "NONE",
"description": "No site validation exists",
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "PENDING_VALIDATION", "name": "PENDING_VALIDATION",
"description": "Site validation process has not started", "description": "Site validation process has not started",
...@@ -4056,6 +4056,7 @@ Status of a container repository. ...@@ -4056,6 +4056,7 @@ Status of a container repository.
| ----- | ----------- | | ----- | ----------- |
| `FAILED_VALIDATION` | Site validation process finished but failed | | `FAILED_VALIDATION` | Site validation process finished but failed |
| `INPROGRESS_VALIDATION` | Site validation process is in progress | | `INPROGRESS_VALIDATION` | Site validation process is in progress |
| `NONE` | No site validation exists |
| `PASSED_VALIDATION` | Site validation process finished successfully | | `PASSED_VALIDATION` | Site validation process finished successfully |
| `PENDING_VALIDATION` | Site validation process has not started | | `PENDING_VALIDATION` | Site validation process has not started |
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
module Types module Types
class DastSiteProfileValidationStatusEnum < BaseEnum class DastSiteProfileValidationStatusEnum < BaseEnum
value 'NONE', value: DastSiteValidation::NONE_STATE, description: 'No site validation exists'
value 'PENDING_VALIDATION', value: 'pending', description: 'Site validation process has not started' value 'PENDING_VALIDATION', value: 'pending', description: 'Site validation process has not started'
value 'INPROGRESS_VALIDATION', value: 'inprogress', description: 'Site validation process is in progress' value 'INPROGRESS_VALIDATION', value: 'inprogress', description: 'Site validation process is in progress'
value 'PASSED_VALIDATION', value: 'passed', description: 'Site validation process finished successfully' value 'PASSED_VALIDATION', value: 'passed', description: 'Site validation process finished successfully'
......
...@@ -15,7 +15,7 @@ class DastSiteProfile < ApplicationRecord ...@@ -15,7 +15,7 @@ class DastSiteProfile < ApplicationRecord
delegate :dast_site_validation, to: :dast_site, allow_nil: true delegate :dast_site_validation, to: :dast_site, allow_nil: true
def status def status
return DastSiteValidation::INITIAL_STATE unless dast_site_validation return DastSiteValidation::NONE_STATE unless dast_site_validation
dast_site_validation.state dast_site_validation.state
end end
......
...@@ -27,6 +27,7 @@ class DastSiteValidation < ApplicationRecord ...@@ -27,6 +27,7 @@ class DastSiteValidation < ApplicationRecord
"#{url_base}/#{url_path}" "#{url_base}/#{url_path}"
end end
NONE_STATE = 'none'
INITIAL_STATE = 'pending' INITIAL_STATE = 'pending'
state_machine :state, initial: INITIAL_STATE.to_sym do state_machine :state, initial: INITIAL_STATE.to_sym do
......
---
title: Return NONE for GraphQL DastSiteValidation type status when there is no DAST site validation
merge_request: 48751
author:
type: changed
...@@ -74,12 +74,12 @@ RSpec.describe DastSiteProfile, type: :model do ...@@ -74,12 +74,12 @@ RSpec.describe DastSiteProfile, type: :model do
describe '#status' do describe '#status' do
context 'when dast_site_validation association does not exist' do context 'when dast_site_validation association does not exist' do
it 'is pending' do it 'is none' do
subject.dast_site.update!(dast_site_validation_id: nil) subject.dast_site.update!(dast_site_validation_id: nil)
aggregate_failures do aggregate_failures do
expect(subject.dast_site_validation).to be_nil expect(subject.dast_site_validation).to be_nil
expect(subject.status).to eq('pending') expect(subject.status).to eq('none')
end end
end end
end end
......
...@@ -93,10 +93,10 @@ RSpec.describe 'Query.project(fullPath).dastSiteProfile' do ...@@ -93,10 +93,10 @@ RSpec.describe 'Query.project(fullPath).dastSiteProfile' do
end end
context 'when there is no associated dast_site_validation' do context 'when there is no associated dast_site_validation' do
it 'returns a pending validation status' do it 'returns a none validation status' do
dast_site_profile.dast_site_validation.destroy! dast_site_profile.dast_site_validation.destroy!
expect(dast_site_profile_response['validationStatus']).to eq('PENDING_VALIDATION') expect(dast_site_profile_response['validationStatus']).to eq('NONE')
end end
end end
end end
......
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