Commit f6e83b81 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'philipcunningham-rename-dast-site-validation-revoke-service' into 'master'

Move DAST validation service to AppSec namespace

See merge request gitlab-org/gitlab!70904
parents 7431ff80 4f935a2e
......@@ -20,7 +20,7 @@ module Mutations
def resolve(full_path:, normalized_target_url:)
project = authorized_find!(full_path)
response = ::DastSiteValidations::RevokeService.new(
response = ::AppSec::Dast::SiteValidations::RevokeService.new(
container: project,
params: { url_base: normalized_target_url }
).execute
......
# frozen_string_literal: true
module AppSec
module Dast
module SiteValidations
class RevokeService < BaseContainerService
MissingParamError = Class.new(StandardError)
def execute
return ServiceResponse.error(message: 'Insufficient permissions') unless allowed?
finder = DastSiteValidationsFinder.new(
project_id: container.id,
url_base: url_base
)
result = finder.execute.delete_all
ServiceResponse.success(payload: { count: result })
rescue MissingParamError => err
ServiceResponse.error(message: err.message)
end
private
def allowed?
container.licensed_feature_available?(:security_on_demand_scans)
end
def url_base
params[:url_base] || raise(MissingParamError, 'URL parameter used to search for validations is missing')
end
end
end
end
end
# frozen_string_literal: true
module DastSiteValidations
class RevokeService < BaseContainerService
MissingParamError = Class.new(StandardError)
def execute
return ServiceResponse.error(message: 'Insufficient permissions') unless allowed?
finder = DastSiteValidationsFinder.new(
project_id: container.id,
url_base: url_base
)
result = finder.execute.delete_all
ServiceResponse.success(payload: { count: result })
rescue MissingParamError => err
ServiceResponse.error(message: err.message)
end
private
def allowed?
container.feature_available?(:security_on_demand_scans)
end
def url_base
params[:url_base] || raise(MissingParamError, 'URL parameter used to search for validations is missing')
end
end
end
......@@ -48,10 +48,10 @@ RSpec.describe Mutations::DastSiteValidations::Revoke do
end
end
it 'correctly calls DastSiteValidations::RevokeService' do
it 'correctly calls AppSec::Dast::SiteValidations::RevokeService' do
params = { container: project, params: { url_base: dast_site_validation1.url_base } }
expect(DastSiteValidations::RevokeService).to receive(:new).with(params).and_call_original
expect(AppSec::Dast::SiteValidations::RevokeService).to receive(:new).with(params).and_call_original
subject
end
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe DastSiteValidations::RevokeService do
RSpec.describe AppSec::Dast::SiteValidations::RevokeService do
let_it_be(:project) { create(:project) }
let_it_be(:dast_site_token) { create(:dast_site_token, project: project) }
let_it_be(:common_url_base) { DastSiteValidation.get_normalized_url_base(dast_site_token.url) }
......
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