Commit 1f42d324 authored by David O'Regan's avatar David O'Regan

Merge branch '293897-dast-input-types' into 'master'

Use input types in DAST mutations

See merge request gitlab-org/gitlab!50086
parents c930f24b b28b4f98
...@@ -175,9 +175,11 @@ export default { ...@@ -175,9 +175,11 @@ export default {
.mutate({ .mutate({
mutation: dastOnDemandScanCreateMutation, mutation: dastOnDemandScanCreateMutation,
variables: { variables: {
fullPath: this.projectPath, input: {
dastScannerProfileId: this.selectedScannerProfile.id, fullPath: this.projectPath,
dastSiteProfileId: this.selectedSiteProfile.id, dastScannerProfileId: this.selectedScannerProfile.id,
dastSiteProfileId: this.selectedSiteProfile.id,
},
}, },
}) })
.then(({ data: { dastOnDemandScanCreate: { pipelineUrl, errors } } }) => { .then(({ data: { dastOnDemandScanCreate: { pipelineUrl, errors } } }) => {
......
mutation dastOnDemandScanCreate( mutation dastOnDemandScanCreate($input: DastOnDemandScanCreateInput!) {
$fullPath: ID! dastOnDemandScanCreate(input: $input) {
$dastScannerProfileId: DastScannerProfileID
$dastSiteProfileId: DastSiteProfileID!
) {
dastOnDemandScanCreate(
input: {
fullPath: $fullPath
dastScannerProfileId: $dastScannerProfileId
dastSiteProfileId: $dastSiteProfileId
}
) {
pipelineUrl pipelineUrl
errors errors
} }
......
...@@ -172,8 +172,10 @@ export default { ...@@ -172,8 +172,10 @@ export default {
.mutate({ .mutate({
mutation: deletion.mutation, mutation: deletion.mutation,
variables: { variables: {
projectFullPath, input: {
profileId, fullPath: projectFullPath,
profileId,
},
}, },
update(store, { data = {} }) { update(store, { data = {} }) {
const errors = data[`${profileType}Delete`]?.errors ?? []; const errors = data[`${profileType}Delete`]?.errors ?? [];
......
mutation dastScannerProfileDelete($projectFullPath: ID!, $profileId: DastScannerProfileID!) { mutation dastScannerProfileDelete($input: DastScannerProfileDeleteInput!) {
scannerProfilesDelete: dastScannerProfileDelete( scannerProfilesDelete: dastScannerProfileDelete(input: $input) {
input: { fullPath: $projectFullPath, id: $profileId }
) {
errors errors
} }
} }
mutation dastSiteProfileDelete($projectFullPath: ID!, $profileId: DastSiteProfileID!) { mutation dastSiteProfileDelete($input: DastSiteProfileDeleteInput!) {
siteProfilesDelete: dastSiteProfileDelete(input: { fullPath: $projectFullPath, id: $profileId }) { siteProfilesDelete: dastSiteProfileDelete(input: $input) {
errors errors
} }
} }
...@@ -171,9 +171,11 @@ export default { ...@@ -171,9 +171,11 @@ export default {
this.hideErrors(); this.hideErrors();
const variables = { const variables = {
projectFullPath: this.projectFullPath, input: {
...(this.isEdit ? { id: this.profile.id } : {}), fullPath: this.projectFullPath,
...serializeFormObject(this.form), ...(this.isEdit ? { id: this.profile.id } : {}),
...serializeFormObject(this.form),
},
}; };
this.$apollo this.$apollo
......
mutation dastScannerProfileCreate( mutation dastScannerProfileCreate($input: DastScannerProfileCreateInput!) {
$projectFullPath: ID! dastScannerProfileCreate(input: $input) {
$profileName: String!
$spiderTimeout: Int!
$targetTimeout: Int!
$scanType: DastScanTypeEnum!
$useAjaxSpider: Boolean!
$showDebugMessages: Boolean!
) {
dastScannerProfileCreate(
input: {
fullPath: $projectFullPath
profileName: $profileName
spiderTimeout: $spiderTimeout
targetTimeout: $targetTimeout
scanType: $scanType
useAjaxSpider: $useAjaxSpider
showDebugMessages: $showDebugMessages
}
) {
errors errors
} }
} }
mutation dastScannerProfileUpdate( mutation dastScannerProfileUpdate($input: DastScannerProfileUpdateInput!) {
$id: DastScannerProfileID! dastScannerProfileUpdate(input: $input) {
$projectFullPath: ID!
$profileName: String!
$spiderTimeout: Int!
$targetTimeout: Int!
$scanType: DastScanTypeEnum!
$useAjaxSpider: Boolean!
$showDebugMessages: Boolean!
) {
dastScannerProfileUpdate(
input: {
id: $id
fullPath: $projectFullPath
profileName: $profileName
spiderTimeout: $spiderTimeout
targetTimeout: $targetTimeout
scanType: $scanType
useAjaxSpider: $useAjaxSpider
showDebugMessages: $showDebugMessages
}
) {
id id
errors errors
} }
......
...@@ -105,9 +105,11 @@ export default { ...@@ -105,9 +105,11 @@ export default {
const { errorMessage } = this.i18n; const { errorMessage } = this.i18n;
const variables = { const variables = {
fullPath: this.fullPath, input: {
...(this.isEdit ? { id: this.siteProfile.id } : {}), fullPath: this.fullPath,
...serializeFormObject(this.form.fields), ...(this.isEdit ? { id: this.siteProfile.id } : {}),
...serializeFormObject(this.form.fields),
},
}; };
this.$apollo this.$apollo
......
mutation dastSiteProfileCreate($fullPath: ID!, $profileName: String!, $targetUrl: String) { mutation dastSiteProfileCreate($input: DastSiteProfileCreateInput!) {
dastSiteProfileCreate( dastSiteProfileCreate(input: $input) {
input: { fullPath: $fullPath, profileName: $profileName, targetUrl: $targetUrl }
) {
id id
errors errors
} }
......
mutation dastSiteProfileUpdate( mutation dastSiteProfileUpdate($input: DastSiteProfileUpdateInput!) {
$id: DastSiteProfileID! dastSiteProfileUpdate(input: $input) {
$fullPath: ID!
$profileName: String!
$targetUrl: String
) {
dastSiteProfileUpdate(
input: { id: $id, fullPath: $fullPath, profileName: $profileName, targetUrl: $targetUrl }
) {
id id
errors errors
} }
......
...@@ -200,9 +200,11 @@ describe('OnDemandScansForm', () => { ...@@ -200,9 +200,11 @@ describe('OnDemandScansForm', () => {
expect(subject.vm.$apollo.mutate).toHaveBeenCalledWith({ expect(subject.vm.$apollo.mutate).toHaveBeenCalledWith({
mutation: dastOnDemandScanCreate, mutation: dastOnDemandScanCreate,
variables: { variables: {
dastScannerProfileId: passiveScannerProfile.id, input: {
dastSiteProfileId: nonValidatedSiteProfile.id, dastScannerProfileId: passiveScannerProfile.id,
fullPath: projectPath, dastSiteProfileId: nonValidatedSiteProfile.id,
fullPath: projectPath,
},
}, },
}); });
}); });
......
...@@ -189,14 +189,16 @@ describe('DAST Scanner Profile', () => { ...@@ -189,14 +189,16 @@ describe('DAST Scanner Profile', () => {
expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledWith({ expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledWith({
mutation, mutation,
variables: { variables: {
profileName, input: {
spiderTimeout, profileName,
targetTimeout, spiderTimeout,
projectFullPath, targetTimeout,
scanType, fullPath: projectFullPath,
useAjaxSpider, scanType,
showDebugMessages, useAjaxSpider,
...mutationVars, showDebugMessages,
...mutationVars,
},
}, },
}); });
}); });
......
...@@ -173,10 +173,12 @@ describe('DastSiteProfileForm', () => { ...@@ -173,10 +173,12 @@ describe('DastSiteProfileForm', () => {
it('triggers GraphQL mutation', () => { it('triggers GraphQL mutation', () => {
expect(requestHandlers[mutationKind]).toHaveBeenCalledWith({ expect(requestHandlers[mutationKind]).toHaveBeenCalledWith({
profileName, input: {
targetUrl, profileName,
fullPath, targetUrl,
...mutationVars, fullPath,
...mutationVars,
},
}); });
}); });
......
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