Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7ef723e5
Commit
7ef723e5
authored
Dec 07, 2020
by
Paul Slaughter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch '246892-auto-select-dast-profile' into 'master'"
This reverts merge request !48940
parent
0255e321
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
66 additions
and
195 deletions
+66
-195
ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_form.vue
...ripts/on_demand_scans/components/on_demand_scans_form.vue
+15
-40
ee/app/assets/javascripts/on_demand_scans/components/profile_selector/profile_selector.vue
...nd_scans/components/profile_selector/profile_selector.vue
+8
-10
ee/app/assets/javascripts/on_demand_scans/components/profile_selector/scanner_profile_selector.vue
.../components/profile_selector/scanner_profile_selector.vue
+2
-2
ee/app/assets/javascripts/on_demand_scans/components/profile_selector/site_profile_selector.vue
...ans/components/profile_selector/site_profile_selector.vue
+2
-2
ee/changelogs/unreleased/246892-auto-select-dast-profile.yml
ee/changelogs/unreleased/246892-auto-select-dast-profile.yml
+0
-5
ee/spec/frontend/on_demand_scans/components/on_demand_scans_form_spec.js
...d/on_demand_scans/components/on_demand_scans_form_spec.js
+20
-77
ee/spec/frontend/on_demand_scans/components/profile_selector/__snapshots__/scanner_profile_selector_spec.js.snap
...ector/__snapshots__/scanner_profile_selector_spec.js.snap
+1
-1
ee/spec/frontend/on_demand_scans/components/profile_selector/__snapshots__/site_profile_selector_spec.js.snap
...selector/__snapshots__/site_profile_selector_spec.js.snap
+1
-1
ee/spec/frontend/on_demand_scans/components/profile_selector/profile_selector_spec.js
...cans/components/profile_selector/profile_selector_spec.js
+7
-5
ee/spec/frontend/on_demand_scans/components/profile_selector/scanner_profile_selector_spec.js
...ponents/profile_selector/scanner_profile_selector_spec.js
+4
-4
ee/spec/frontend/on_demand_scans/components/profile_selector/site_profile_selector_spec.js
...components/profile_selector/site_profile_selector_spec.js
+4
-4
ee/spec/frontend/on_demand_scans/mock_data.js
ee/spec/frontend/on_demand_scans/mock_data.js
+0
-4
ee/spec/frontend/on_demand_scans/mocks/apollo_mocks.js
ee/spec/frontend/on_demand_scans/mocks/apollo_mocks.js
+0
-38
ee/spec/frontend/security_configuration/dast_scanner_profiles_form/components/dast_scanner_profiles_form_spec.js
...ofiles_form/components/dast_scanner_profiles_form_spec.js
+1
-1
ee/spec/frontend/security_configuration/dast_site_profiles_form/components/dast_site_profile_form_spec.js
...e_profiles_form/components/dast_site_profile_form_spec.js
+1
-1
No files found.
ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_form.vue
View file @
7ef723e5
...
@@ -30,7 +30,7 @@ import ProfileSelectorSummaryCell from './profile_selector/summary_cell.vue';
...
@@ -30,7 +30,7 @@ import ProfileSelectorSummaryCell from './profile_selector/summary_cell.vue';
import
ScannerProfileSelector
from
'
./profile_selector/scanner_profile_selector.vue
'
;
import
ScannerProfileSelector
from
'
./profile_selector/scanner_profile_selector.vue
'
;
import
SiteProfileSelector
from
'
./profile_selector/site_profile_selector.vue
'
;
import
SiteProfileSelector
from
'
./profile_selector/site_profile_selector.vue
'
;
const
createProfilesApolloOptions
=
(
name
,
field
,
{
fetchQuery
,
fetchError
})
=>
({
const
createProfilesApolloOptions
=
(
name
,
{
fetchQuery
,
fetchError
})
=>
({
query
:
fetchQuery
,
query
:
fetchQuery
,
variables
()
{
variables
()
{
return
{
return
{
...
@@ -39,9 +39,6 @@ const createProfilesApolloOptions = (name, field, { fetchQuery, fetchError }) =>
...
@@ -39,9 +39,6 @@ const createProfilesApolloOptions = (name, field, { fetchQuery, fetchError }) =>
},
},
update
(
data
)
{
update
(
data
)
{
const
edges
=
data
?.
project
?.[
name
]?.
edges
??
[];
const
edges
=
data
?.
project
?.[
name
]?.
edges
??
[];
if
(
edges
.
length
===
1
)
{
this
[
field
]
=
edges
[
0
].
node
.
id
;
}
return
edges
.
map
(({
node
})
=>
node
);
return
edges
.
map
(({
node
})
=>
node
);
},
},
error
(
e
)
{
error
(
e
)
{
...
@@ -69,16 +66,8 @@ export default {
...
@@ -69,16 +66,8 @@ export default {
},
},
mixins
:
[
glFeatureFlagsMixin
()],
mixins
:
[
glFeatureFlagsMixin
()],
apollo
:
{
apollo
:
{
scannerProfiles
:
createProfilesApolloOptions
(
scannerProfiles
:
createProfilesApolloOptions
(
'
scannerProfiles
'
,
SCANNER_PROFILES_QUERY
),
'
scannerProfiles
'
,
siteProfiles
:
createProfilesApolloOptions
(
'
siteProfiles
'
,
SITE_PROFILES_QUERY
),
'
selectedScannerProfileId
'
,
SCANNER_PROFILES_QUERY
,
),
siteProfiles
:
createProfilesApolloOptions
(
'
siteProfiles
'
,
'
selectedSiteProfileId
'
,
SITE_PROFILES_QUERY
,
),
},
},
props
:
{
props
:
{
helpPagePath
:
{
helpPagePath
:
{
...
@@ -115,8 +104,8 @@ export default {
...
@@ -115,8 +104,8 @@ export default {
return
{
return
{
scannerProfiles
:
[],
scannerProfiles
:
[],
siteProfiles
:
[],
siteProfiles
:
[],
selectedScannerProfile
Id
:
null
,
selectedScannerProfile
:
null
,
selectedSiteProfile
Id
:
null
,
selectedSiteProfile
:
null
,
loading
:
false
,
loading
:
false
,
errorType
:
null
,
errorType
:
null
,
errors
:
[],
errors
:
[],
...
@@ -124,16 +113,6 @@ export default {
...
@@ -124,16 +113,6 @@ export default {
};
};
},
},
computed
:
{
computed
:
{
selectedScannerProfile
()
{
return
this
.
selectedScannerProfileId
?
this
.
scannerProfiles
.
find
(({
id
})
=>
id
===
this
.
selectedScannerProfileId
)
:
null
;
},
selectedSiteProfile
()
{
return
this
.
selectedSiteProfileId
?
this
.
siteProfiles
.
find
(({
id
})
=>
id
===
this
.
selectedSiteProfileId
)
:
null
;
},
errorMessage
()
{
errorMessage
()
{
return
ERROR_MESSAGES
[
this
.
errorType
]
||
null
;
return
ERROR_MESSAGES
[
this
.
errorType
]
||
null
;
},
},
...
@@ -259,37 +238,37 @@ export default {
...
@@ -259,37 +238,37 @@ export default {
</template>
</template>
<
template
v-else-if=
"!failedToLoadProfiles"
>
<
template
v-else-if=
"!failedToLoadProfiles"
>
<scanner-profile-selector
<scanner-profile-selector
v-model=
"selectedScannerProfile
Id
"
v-model=
"selectedScannerProfile"
class=
"gl-mb-5"
class=
"gl-mb-5"
:profiles=
"scannerProfiles"
:profiles=
"scannerProfiles"
>
>
<template
v-if=
"selectedScannerProfile"
#summary
>
<template
#summary
="
{ profile }"
>
<div
class=
"row"
>
<div
class=
"row"
>
<profile-selector-summary-cell
<profile-selector-summary-cell
:class=
"
{ 'gl-text-red-500': hasProfilesConflict }"
:class=
"
{ 'gl-text-red-500': hasProfilesConflict }"
:label="s__('DastProfiles|Scan mode')"
:label="s__('DastProfiles|Scan mode')"
:value="$options.SCAN_TYPE_LABEL[
selectedScannerP
rofile.scanType]"
:value="$options.SCAN_TYPE_LABEL[
p
rofile.scanType]"
/>
/>
</div>
</div>
<div
class=
"row"
>
<div
class=
"row"
>
<profile-selector-summary-cell
<profile-selector-summary-cell
:label=
"s__('DastProfiles|Spider timeout')"
:label=
"s__('DastProfiles|Spider timeout')"
:value=
"n__('%d minute', '%d minutes',
selectedScannerP
rofile.spiderTimeout)"
:value=
"n__('%d minute', '%d minutes',
p
rofile.spiderTimeout)"
/>
/>
<profile-selector-summary-cell
<profile-selector-summary-cell
:label=
"s__('DastProfiles|Target timeout')"
:label=
"s__('DastProfiles|Target timeout')"
:value=
"n__('%d second', '%d seconds',
selectedScannerP
rofile.targetTimeout)"
:value=
"n__('%d second', '%d seconds',
p
rofile.targetTimeout)"
/>
/>
</div>
</div>
<div
class=
"row"
>
<div
class=
"row"
>
<profile-selector-summary-cell
<profile-selector-summary-cell
:label=
"s__('DastProfiles|AJAX spider')"
:label=
"s__('DastProfiles|AJAX spider')"
:value=
"
selectedScannerP
rofile.useAjaxSpider ? __('On') : __('Off')"
:value=
"
p
rofile.useAjaxSpider ? __('On') : __('Off')"
/>
/>
<profile-selector-summary-cell
<profile-selector-summary-cell
:label=
"s__('DastProfiles|Debug messages')"
:label=
"s__('DastProfiles|Debug messages')"
:value=
"
:value=
"
selectedScannerP
rofile.showDebugMessages
p
rofile.showDebugMessages
? s__('DastProfiles|Show debug messages')
? s__('DastProfiles|Show debug messages')
: s__('DastProfiles|Hide debug messages')
: s__('DastProfiles|Hide debug messages')
"
"
...
@@ -297,17 +276,13 @@ export default {
...
@@ -297,17 +276,13 @@ export default {
</div>
</div>
</
template
>
</
template
>
</scanner-profile-selector>
</scanner-profile-selector>
<site-profile-selector
<site-profile-selector
v-model=
"selectedSiteProfile"
class=
"gl-mb-5"
:profiles=
"siteProfiles"
>
v-model=
"selectedSiteProfileId"
<
template
#summary=
"{ profile }"
>
class=
"gl-mb-5"
:profiles=
"siteProfiles"
>
<
template
v-if=
"selectedSiteProfile"
#summary
>
<div
class=
"row"
>
<div
class=
"row"
>
<profile-selector-summary-cell
<profile-selector-summary-cell
:class=
"
{ 'gl-text-red-500': hasProfilesConflict }"
:class=
"
{ 'gl-text-red-500': hasProfilesConflict }"
:label="s__('DastProfiles|Target URL')"
:label="s__('DastProfiles|Target URL')"
:value="
selectedSiteP
rofile.targetUrl"
:value="
p
rofile.targetUrl"
/>
/>
</div>
</div>
</
template
>
</
template
>
...
...
ee/app/assets/javascripts/on_demand_scans/components/profile_selector/profile_selector.vue
View file @
7ef723e5
...
@@ -25,14 +25,14 @@ export default {
...
@@ -25,14 +25,14 @@ export default {
default
:
()
=>
[],
default
:
()
=>
[],
},
},
value
:
{
value
:
{
type
:
String
,
type
:
Object
,
required
:
false
,
required
:
false
,
default
:
null
,
default
:
null
,
},
},
},
},
computed
:
{
methods
:
{
selectedProfile
(
)
{
isChecked
({
id
}
)
{
return
this
.
value
?
this
.
profiles
.
find
(({
id
})
=>
this
.
value
===
id
)
:
null
;
return
this
.
value
?.
id
===
id
;
},
},
},
},
};
};
...
@@ -67,9 +67,7 @@ export default {
...
@@ -67,9 +67,7 @@ export default {
</
template
>
</
template
>
<gl-dropdown
<gl-dropdown
:text=
"
:text=
"
selectedProfile
value ? value.dropdownLabel : s__('OnDemandScans|Select one of the existing profiles')
? selectedProfile.dropdownLabel
: s__('OnDemandScans|Select one of the existing profiles')
"
"
class=
"mw-460"
class=
"mw-460"
data-testid=
"profiles-dropdown"
data-testid=
"profiles-dropdown"
...
@@ -77,9 +75,9 @@ export default {
...
@@ -77,9 +75,9 @@ export default {
<gl-dropdown-item
<gl-dropdown-item
v-for=
"profile in profiles"
v-for=
"profile in profiles"
:key=
"profile.id"
:key=
"profile.id"
:is-checked=
"
value === profile.id
"
:is-checked=
"
isChecked(profile)
"
is-check-item
is-check-item
@
click=
"$emit('input', profile
.id
)"
@
click=
"$emit('input', profile)"
>
>
{{ profile.profileName }}
{{ profile.profileName }}
</gl-dropdown-item>
</gl-dropdown-item>
...
@@ -89,7 +87,7 @@ export default {
...
@@ -89,7 +87,7 @@ export default {
data-testid=
"selected-profile-summary"
data-testid=
"selected-profile-summary"
class=
"gl-mt-6 gl-pt-6 gl-border-t-solid gl-border-gray-100 gl-border-t-1"
class=
"gl-mt-6 gl-pt-6 gl-border-t-solid gl-border-gray-100 gl-border-t-1"
>
>
<slot
name=
"summary"
></slot>
<slot
name=
"summary"
:profile=
"value"
></slot>
</div>
</div>
</gl-form-group>
</gl-form-group>
<
template
v-else
>
<
template
v-else
>
...
...
ee/app/assets/javascripts/on_demand_scans/components/profile_selector/scanner_profile_selector.vue
View file @
7ef723e5
...
@@ -57,8 +57,8 @@ export default {
...
@@ -57,8 +57,8 @@ export default {
)
)
}}
</
template
>
}}
</
template
>
<
template
#new-profile
>
{{
s__
(
'
OnDemandScans|Create a new scanner profile
'
)
}}
</
template
>
<
template
#new-profile
>
{{
s__
(
'
OnDemandScans|Create a new scanner profile
'
)
}}
</
template
>
<
template
#summary
>
<
template
#summary
=
"{ profile }"
>
<slot
name=
"summary"
></slot>
<slot
name=
"summary"
:profile=
"profile"
></slot>
</
template
>
</
template
>
</profile-selector>
</profile-selector>
</template>
</template>
ee/app/assets/javascripts/on_demand_scans/components/profile_selector/site_profile_selector.vue
View file @
7ef723e5
...
@@ -60,8 +60,8 @@ export default {
...
@@ -60,8 +60,8 @@ export default {
)
)
}}
</
template
>
}}
</
template
>
<
template
#new-profile
>
{{
s__
(
'
OnDemandScans|Create a new site profile
'
)
}}
</
template
>
<
template
#new-profile
>
{{
s__
(
'
OnDemandScans|Create a new site profile
'
)
}}
</
template
>
<
template
#summary
>
<
template
#summary
=
"{ profile }"
>
<slot
name=
"summary"
></slot>
<slot
name=
"summary"
:profile=
"profile"
></slot>
</
template
>
</
template
>
</profile-selector>
</profile-selector>
</template>
</template>
ee/changelogs/unreleased/246892-auto-select-dast-profile.yml
deleted
100644 → 0
View file @
0255e321
---
title
:
'
On-demand
scans:
automatically
select
DAST
profile
when
only
one
is
available'
merge_request
:
48940
author
:
type
:
changed
ee/spec/frontend/on_demand_scans/components/on_demand_scans_form_spec.js
View file @
7ef723e5
import
{
GlForm
,
GlSkeletonLoader
}
from
'
@gitlab/ui
'
;
import
{
GlForm
,
GlSkeletonLoader
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
,
mount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
,
mount
}
from
'
@vue/test-utils
'
;
import
{
merge
}
from
'
lodash
'
;
import
{
merge
}
from
'
lodash
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
createApolloProvider
from
'
helpers/mock_apollo_helper
'
;
import
OnDemandScansForm
from
'
ee/on_demand_scans/components/on_demand_scans_form.vue
'
;
import
OnDemandScansForm
from
'
ee/on_demand_scans/components/on_demand_scans_form.vue
'
;
import
ScannerProfileSelector
from
'
ee/on_demand_scans/components/profile_selector/scanner_profile_selector.vue
'
;
import
ScannerProfileSelector
from
'
ee/on_demand_scans/components/profile_selector/scanner_profile_selector.vue
'
;
import
SiteProfileSelector
from
'
ee/on_demand_scans/components/profile_selector/site_profile_selector.vue
'
;
import
SiteProfileSelector
from
'
ee/on_demand_scans/components/profile_selector/site_profile_selector.vue
'
;
import
dastOnDemandScanCreate
from
'
ee/on_demand_scans/graphql/dast_on_demand_scan_create.mutation.graphql
'
;
import
dastOnDemandScanCreate
from
'
ee/on_demand_scans/graphql/dast_on_demand_scan_create.mutation.graphql
'
;
import
dastScannerProfilesQuery
from
'
ee/security_configuration/dast_profiles/graphql/dast_scanner_profiles.query.graphql
'
;
import
dastSiteProfilesQuery
from
'
ee/security_configuration/dast_profiles/graphql/dast_site_profiles.query.graphql
'
;
import
*
as
responses
from
'
../mocks/apollo_mocks
'
;
import
{
scannerProfiles
,
siteProfiles
}
from
'
../mocks/mock_data
'
;
import
{
redirectTo
}
from
'
~/lib/utils/url_utility
'
;
import
{
redirectTo
}
from
'
~/lib/utils/url_utility
'
;
import
{
scannerProfiles
,
siteProfiles
}
from
'
../mock_data
'
;
const
helpPagePath
=
'
/application_security/dast/index#on-demand-scans
'
;
const
helpPagePath
=
'
/application_security/dast/index#on-demand-scans
'
;
const
projectPath
=
'
group/project
'
;
const
projectPath
=
'
group/project
'
;
...
@@ -27,6 +22,17 @@ const defaultProps = {
...
@@ -27,6 +22,17 @@ const defaultProps = {
defaultBranch
,
defaultBranch
,
};
};
const
defaultMocks
=
{
$apollo
:
{
mutate
:
jest
.
fn
(),
queries
:
{
scannerProfiles
:
{},
siteProfiles
:
{},
},
addSmartQuery
:
jest
.
fn
(),
},
};
const
pipelineUrl
=
`/
${
projectPath
}
/pipelines/123`
;
const
pipelineUrl
=
`/
${
projectPath
}
/pipelines/123`
;
const
[
passiveScannerProfile
,
activeScannerProfile
]
=
scannerProfiles
;
const
[
passiveScannerProfile
,
activeScannerProfile
]
=
scannerProfiles
;
const
[
nonValidatedSiteProfile
,
validatedSiteProfile
]
=
siteProfiles
;
const
[
nonValidatedSiteProfile
,
validatedSiteProfile
]
=
siteProfiles
;
...
@@ -37,9 +43,7 @@ jest.mock('~/lib/utils/url_utility', () => ({
...
@@ -37,9 +43,7 @@ jest.mock('~/lib/utils/url_utility', () => ({
}));
}));
describe
(
'
OnDemandScansForm
'
,
()
=>
{
describe
(
'
OnDemandScansForm
'
,
()
=>
{
let
localVue
;
let
subject
;
let
subject
;
let
requestHandlers
;
const
findForm
=
()
=>
subject
.
find
(
GlForm
);
const
findForm
=
()
=>
subject
.
find
(
GlForm
);
const
findByTestId
=
testId
=>
subject
.
find
(
`[data-testid="
${
testId
}
"]`
);
const
findByTestId
=
testId
=>
subject
.
find
(
`[data-testid="
${
testId
}
"]`
);
...
@@ -48,44 +52,13 @@ describe('OnDemandScansForm', () => {
...
@@ -48,44 +52,13 @@ describe('OnDemandScansForm', () => {
const
findSubmitButton
=
()
=>
findByTestId
(
'
on-demand-scan-submit-button
'
);
const
findSubmitButton
=
()
=>
findByTestId
(
'
on-demand-scan-submit-button
'
);
const
setValidFormData
=
()
=>
{
const
setValidFormData
=
()
=>
{
subject
.
find
(
ScannerProfileSelector
).
vm
.
$emit
(
'
input
'
,
passiveScannerProfile
.
id
);
subject
.
find
(
ScannerProfileSelector
).
vm
.
$emit
(
'
input
'
,
passiveScannerProfile
);
subject
.
find
(
SiteProfileSelector
).
vm
.
$emit
(
'
input
'
,
nonValidatedSiteProfile
.
id
);
subject
.
find
(
SiteProfileSelector
).
vm
.
$emit
(
'
input
'
,
nonValidatedSiteProfile
);
return
subject
.
vm
.
$nextTick
();
return
subject
.
vm
.
$nextTick
();
};
};
const
submitForm
=
()
=>
findForm
().
vm
.
$emit
(
'
submit
'
,
{
preventDefault
:
()
=>
{}
});
const
submitForm
=
()
=>
findForm
().
vm
.
$emit
(
'
submit
'
,
{
preventDefault
:
()
=>
{}
});
const
createMockApolloProvider
=
handlers
=>
{
const
subjectMounterFactory
=
(
mountFn
=
shallowMount
)
=>
(
options
=
{})
=>
{
localVue
.
use
(
VueApollo
);
requestHandlers
=
{
dastScannerProfiles
:
jest
.
fn
().
mockResolvedValue
(
responses
.
dastScannerProfiles
()),
dastSiteProfiles
:
jest
.
fn
().
mockResolvedValue
(
responses
.
dastSiteProfiles
()),
...
handlers
,
};
return
createApolloProvider
([
[
dastScannerProfilesQuery
,
requestHandlers
.
dastScannerProfiles
],
[
dastSiteProfilesQuery
,
requestHandlers
.
dastSiteProfiles
],
]);
};
const
subjectMounterFactory
=
(
mountFn
=
shallowMount
)
=>
(
options
=
{},
withHandlers
)
=>
{
localVue
=
createLocalVue
();
let
defaultMocks
=
{
$apollo
:
{
mutate
:
jest
.
fn
(),
queries
:
{
scannerProfiles
:
{},
siteProfiles
:
{},
},
addSmartQuery
:
jest
.
fn
(),
},
};
let
apolloProvider
;
if
(
withHandlers
)
{
apolloProvider
=
createMockApolloProvider
(
withHandlers
);
defaultMocks
=
{};
}
subject
=
mountFn
(
subject
=
mountFn
(
OnDemandScansForm
,
OnDemandScansForm
,
merge
(
merge
(
...
@@ -103,7 +76,7 @@ describe('OnDemandScansForm', () => {
...
@@ -103,7 +76,7 @@ describe('OnDemandScansForm', () => {
},
},
},
},
},
},
{
...
options
,
localVue
,
apolloProvider
}
,
options
,
{
{
data
()
{
data
()
{
return
{
...
options
.
data
};
return
{
...
options
.
data
};
...
@@ -270,8 +243,8 @@ describe('OnDemandScansForm', () => {
...
@@ -270,8 +243,8 @@ describe('OnDemandScansForm', () => {
'
profiles conflict prevention
'
,
'
profiles conflict prevention
'
,
({
description
,
selectedScannerProfile
,
selectedSiteProfile
,
hasConflict
})
=>
{
({
description
,
selectedScannerProfile
,
selectedSiteProfile
,
hasConflict
})
=>
{
const
setFormData
=
()
=>
{
const
setFormData
=
()
=>
{
subject
.
find
(
ScannerProfileSelector
).
vm
.
$emit
(
'
input
'
,
selectedScannerProfile
.
id
);
subject
.
find
(
ScannerProfileSelector
).
vm
.
$emit
(
'
input
'
,
selectedScannerProfile
);
subject
.
find
(
SiteProfileSelector
).
vm
.
$emit
(
'
input
'
,
selectedSiteProfile
.
id
);
subject
.
find
(
SiteProfileSelector
).
vm
.
$emit
(
'
input
'
,
selectedSiteProfile
);
return
subject
.
vm
.
$nextTick
();
return
subject
.
vm
.
$nextTick
();
};
};
...
@@ -280,12 +253,7 @@ describe('OnDemandScansForm', () => {
...
@@ -280,12 +253,7 @@ describe('OnDemandScansForm', () => {
?
`warns about conflicting profiles when user selects
${
description
}
`
?
`warns about conflicting profiles when user selects
${
description
}
`
:
`does not report any conflict when user selects
${
description
}
`
,
:
`does not report any conflict when user selects
${
description
}
`
,
async
()
=>
{
async
()
=>
{
mountShallowSubject
({
mountShallowSubject
();
data
:
{
scannerProfiles
,
siteProfiles
,
},
});
await
setFormData
();
await
setFormData
();
expect
(
findProfilesConflictAlert
().
exists
()).
toBe
(
hasConflict
);
expect
(
findProfilesConflictAlert
().
exists
()).
toBe
(
hasConflict
);
...
@@ -301,10 +269,6 @@ describe('OnDemandScansForm', () => {
...
@@ -301,10 +269,6 @@ describe('OnDemandScansForm', () => {
securityOnDemandScansSiteValidation
:
false
,
securityOnDemandScansSiteValidation
:
false
,
},
},
},
},
data
:
{
scannerProfiles
,
siteProfiles
,
},
});
});
return
setFormData
();
return
setFormData
();
});
});
...
@@ -316,25 +280,4 @@ describe('OnDemandScansForm', () => {
...
@@ -316,25 +280,4 @@ describe('OnDemandScansForm', () => {
});
});
},
},
);
);
describe
.
each
`
profileType | query | selector | profiles
${
'
scanner
'
}
|
${
'
dastScannerProfiles
'
}
|
${
ScannerProfileSelector
}
|
${
scannerProfiles
}
${
'
site
'
}
|
${
'
dastSiteProfiles
'
}
|
${
SiteProfileSelector
}
|
${
siteProfiles
}
`
(
'
when there is a single $profileType profile
'
,
({
query
,
selector
,
profiles
})
=>
{
const
[
profile
]
=
profiles
;
beforeEach
(()
=>
{
mountShallowSubject
(
{},
{
[
query
]:
jest
.
fn
().
mockResolvedValue
(
responses
[
query
]([
profile
])),
},
);
});
it
(
'
automatically selects the only available profile
'
,
()
=>
{
expect
(
subject
.
find
(
selector
).
attributes
(
'
value
'
)).
toBe
(
profile
.
id
);
});
});
});
});
ee/spec/frontend/on_demand_scans/components/profile_selector/__snapshots__/scanner_profile_selector_spec.js.snap
View file @
7ef723e5
...
@@ -4,7 +4,7 @@ exports[`OnDemandScansScannerProfileSelector renders properly with profiles 1`]
...
@@ -4,7 +4,7 @@ exports[`OnDemandScansScannerProfileSelector renders properly with profiles 1`]
<div
<div
class="gl-card"
class="gl-card"
data-foo="bar"
data-foo="bar"
value="
gid://gitlab/DastScannerProfile/1
"
value="
[object Object]
"
>
>
<div
<div
class="gl-card-header"
class="gl-card-header"
...
...
ee/spec/frontend/on_demand_scans/components/profile_selector/__snapshots__/site_profile_selector_spec.js.snap
View file @
7ef723e5
...
@@ -4,7 +4,7 @@ exports[`OnDemandScansSiteProfileSelector renders properly with profiles 1`] = `
...
@@ -4,7 +4,7 @@ exports[`OnDemandScansSiteProfileSelector renders properly with profiles 1`] = `
<div
<div
class="gl-card"
class="gl-card"
data-foo="bar"
data-foo="bar"
value="
gid://gitlab/DastSiteProfile/1
"
value="
[object Object]
"
>
>
<div
<div
class="gl-card-header"
class="gl-card-header"
...
...
ee/spec/frontend/on_demand_scans/components/profile_selector/profile_selector_spec.js
View file @
7ef723e5
...
@@ -2,7 +2,7 @@ import { GlDropdownItem } from '@gitlab/ui';
...
@@ -2,7 +2,7 @@ import { GlDropdownItem } from '@gitlab/ui';
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
merge
}
from
'
lodash
'
;
import
{
merge
}
from
'
lodash
'
;
import
OnDemandScansProfileSelector
from
'
ee/on_demand_scans/components/profile_selector/profile_selector.vue
'
;
import
OnDemandScansProfileSelector
from
'
ee/on_demand_scans/components/profile_selector/profile_selector.vue
'
;
import
{
scannerProfiles
}
from
'
../../mock
s/mock
_data
'
;
import
{
scannerProfiles
}
from
'
../../mock_data
'
;
describe
(
'
OnDemandScansProfileSelector
'
,
()
=>
{
describe
(
'
OnDemandScansProfileSelector
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
...
@@ -41,10 +41,12 @@ describe('OnDemandScansProfileSelector', () => {
...
@@ -41,10 +41,12 @@ describe('OnDemandScansProfileSelector', () => {
slots
:
{
slots
:
{
title
:
'
Section title
'
,
title
:
'
Section title
'
,
label
:
'
Use existing scanner profile
'
,
label
:
'
Use existing scanner profile
'
,
summary
:
`<div>Profile's summary</div>`
,
'
no-profiles
'
:
'
No profile yet
'
,
'
no-profiles
'
:
'
No profile yet
'
,
'
new-profile
'
:
'
Create a new profile
'
,
'
new-profile
'
:
'
Create a new profile
'
,
},
},
scopedSlots
:
{
summary
:
"
<div>{{ props.profile.profileName }}'s summary</div>
"
,
},
},
},
options
,
options
,
),
),
...
@@ -103,7 +105,7 @@ describe('OnDemandScansProfileSelector', () => {
...
@@ -103,7 +105,7 @@ describe('OnDemandScansProfileSelector', () => {
it
(
'
when a profile is selected, input event is emitted
'
,
async
()
=>
{
it
(
'
when a profile is selected, input event is emitted
'
,
async
()
=>
{
await
selectFirstProfile
();
await
selectFirstProfile
();
expect
(
wrapper
.
emitted
(
'
input
'
)).
toEqual
([[
scannerProfiles
[
0
]
.
id
]]);
expect
(
wrapper
.
emitted
(
'
input
'
)).
toEqual
([[
scannerProfiles
[
0
]]]);
});
});
it
(
'
shows dropdown items for each profile
'
,
()
=>
{
it
(
'
shows dropdown items for each profile
'
,
()
=>
{
...
@@ -128,7 +130,7 @@ describe('OnDemandScansProfileSelector', () => {
...
@@ -128,7 +130,7 @@ describe('OnDemandScansProfileSelector', () => {
createFullComponent
({
createFullComponent
({
propsData
:
{
propsData
:
{
profiles
:
scannerProfiles
,
profiles
:
scannerProfiles
,
value
:
selectedProfile
.
id
,
value
:
selectedProfile
,
},
},
});
});
});
});
...
@@ -137,7 +139,7 @@ describe('OnDemandScansProfileSelector', () => {
...
@@ -137,7 +139,7 @@ describe('OnDemandScansProfileSelector', () => {
const
summary
=
findSelectedProfileSummary
();
const
summary
=
findSelectedProfileSummary
();
expect
(
summary
.
exists
()).
toBe
(
true
);
expect
(
summary
.
exists
()).
toBe
(
true
);
expect
(
summary
.
text
()).
toContain
(
`
Profile
's summary`
);
expect
(
summary
.
text
()).
toContain
(
`
${
scannerProfiles
[
0
].
profileName
}
's summary`
);
});
});
it
(
'
displays item as checked
'
,
()
=>
{
it
(
'
displays item as checked
'
,
()
=>
{
...
...
ee/spec/frontend/on_demand_scans/components/profile_selector/scanner_profile_selector_spec.js
View file @
7ef723e5
...
@@ -2,7 +2,7 @@ import { mount, shallowMount } from '@vue/test-utils';
...
@@ -2,7 +2,7 @@ import { mount, shallowMount } from '@vue/test-utils';
import
{
merge
}
from
'
lodash
'
;
import
{
merge
}
from
'
lodash
'
;
import
ProfileSelector
from
'
ee/on_demand_scans/components/profile_selector/profile_selector.vue
'
;
import
ProfileSelector
from
'
ee/on_demand_scans/components/profile_selector/profile_selector.vue
'
;
import
OnDemandScansScannerProfileSelector
from
'
ee/on_demand_scans/components/profile_selector/scanner_profile_selector.vue
'
;
import
OnDemandScansScannerProfileSelector
from
'
ee/on_demand_scans/components/profile_selector/scanner_profile_selector.vue
'
;
import
{
scannerProfiles
}
from
'
../../mock
s/mock
_data
'
;
import
{
scannerProfiles
}
from
'
../../mock_data
'
;
const
TEST_LIBRARY_PATH
=
'
/test/scanner/profiles/library/path
'
;
const
TEST_LIBRARY_PATH
=
'
/test/scanner/profiles/library/path
'
;
const
TEST_NEW_PATH
=
'
/test/new/scanner/profile/path
'
;
const
TEST_NEW_PATH
=
'
/test/new/scanner/profile/path
'
;
...
@@ -31,8 +31,8 @@ describe('OnDemandScansScannerProfileSelector', () => {
...
@@ -31,8 +31,8 @@ describe('OnDemandScansScannerProfileSelector', () => {
newScannerProfilePath
:
TEST_NEW_PATH
,
newScannerProfilePath
:
TEST_NEW_PATH
,
glFeatures
:
{
securityOnDemandScansSiteValidation
:
true
},
glFeatures
:
{
securityOnDemandScansSiteValidation
:
true
},
},
},
slots
:
{
s
copedS
lots
:
{
summary
:
`<div>
${
profiles
[
0
].
profileName
}
's summary</div>`
,
summary
:
'
<div slot-scope="{ profile }">{{ profile.profileName }}
\'
s summary</div>
'
,
},
},
},
},
options
,
options
,
...
@@ -50,7 +50,7 @@ describe('OnDemandScansScannerProfileSelector', () => {
...
@@ -50,7 +50,7 @@ describe('OnDemandScansScannerProfileSelector', () => {
it
(
'
renders properly with profiles
'
,
()
=>
{
it
(
'
renders properly with profiles
'
,
()
=>
{
createFullComponent
({
createFullComponent
({
propsData
:
{
profiles
,
value
:
profiles
[
0
]
.
id
},
propsData
:
{
profiles
,
value
:
profiles
[
0
]
},
});
});
expect
(
wrapper
.
element
).
toMatchSnapshot
();
expect
(
wrapper
.
element
).
toMatchSnapshot
();
...
...
ee/spec/frontend/on_demand_scans/components/profile_selector/site_profile_selector_spec.js
View file @
7ef723e5
...
@@ -2,7 +2,7 @@ import { mount, shallowMount } from '@vue/test-utils';
...
@@ -2,7 +2,7 @@ import { mount, shallowMount } from '@vue/test-utils';
import
{
merge
}
from
'
lodash
'
;
import
{
merge
}
from
'
lodash
'
;
import
ProfileSelector
from
'
ee/on_demand_scans/components/profile_selector/profile_selector.vue
'
;
import
ProfileSelector
from
'
ee/on_demand_scans/components/profile_selector/profile_selector.vue
'
;
import
OnDemandScansSiteProfileSelector
from
'
ee/on_demand_scans/components/profile_selector/site_profile_selector.vue
'
;
import
OnDemandScansSiteProfileSelector
from
'
ee/on_demand_scans/components/profile_selector/site_profile_selector.vue
'
;
import
{
siteProfiles
}
from
'
../../mock
s/mock
_data
'
;
import
{
siteProfiles
}
from
'
../../mock_data
'
;
const
TEST_LIBRARY_PATH
=
'
/test/site/profiles/library/path
'
;
const
TEST_LIBRARY_PATH
=
'
/test/site/profiles/library/path
'
;
const
TEST_NEW_PATH
=
'
/test/new/site/profile/path
'
;
const
TEST_NEW_PATH
=
'
/test/new/site/profile/path
'
;
...
@@ -34,8 +34,8 @@ describe('OnDemandScansSiteProfileSelector', () => {
...
@@ -34,8 +34,8 @@ describe('OnDemandScansSiteProfileSelector', () => {
newSiteProfilePath
:
TEST_NEW_PATH
,
newSiteProfilePath
:
TEST_NEW_PATH
,
glFeatures
:
{
securityOnDemandScansSiteValidation
:
true
},
glFeatures
:
{
securityOnDemandScansSiteValidation
:
true
},
},
},
slots
:
{
s
copedS
lots
:
{
summary
:
`<div>
${
profiles
[
0
].
profileName
}
's summary</div>`
,
summary
:
'
<div slot-scope="{ profile }">{{ profile.profileName }}
\'
s summary</div>
'
,
},
},
},
},
options
,
options
,
...
@@ -53,7 +53,7 @@ describe('OnDemandScansSiteProfileSelector', () => {
...
@@ -53,7 +53,7 @@ describe('OnDemandScansSiteProfileSelector', () => {
it
(
'
renders properly with profiles
'
,
()
=>
{
it
(
'
renders properly with profiles
'
,
()
=>
{
createFullComponent
({
createFullComponent
({
propsData
:
{
profiles
,
value
:
profiles
[
0
]
.
id
},
propsData
:
{
profiles
,
value
:
profiles
[
0
]
},
});
});
expect
(
wrapper
.
element
).
toMatchSnapshot
();
expect
(
wrapper
.
element
).
toMatchSnapshot
();
...
...
ee/spec/frontend/on_demand_scans/mock
s/mock
_data.js
→
ee/spec/frontend/on_demand_scans/mock_data.js
View file @
7ef723e5
...
@@ -7,7 +7,6 @@ export const scannerProfiles = [
...
@@ -7,7 +7,6 @@ export const scannerProfiles = [
scanType
:
'
PASSIVE
'
,
scanType
:
'
PASSIVE
'
,
useAjaxSpider
:
false
,
useAjaxSpider
:
false
,
showDebugMessages
:
false
,
showDebugMessages
:
false
,
editPath
:
'
/scanner_profile/edit/1
'
,
},
},
{
{
id
:
'
gid://gitlab/DastScannerProfile/2
'
,
id
:
'
gid://gitlab/DastScannerProfile/2
'
,
...
@@ -17,7 +16,6 @@ export const scannerProfiles = [
...
@@ -17,7 +16,6 @@ export const scannerProfiles = [
scanType
:
'
ACTIVE
'
,
scanType
:
'
ACTIVE
'
,
useAjaxSpider
:
true
,
useAjaxSpider
:
true
,
showDebugMessages
:
true
,
showDebugMessages
:
true
,
editPath
:
'
/scanner_profile/edit/2
'
,
},
},
];
];
...
@@ -26,14 +24,12 @@ export const siteProfiles = [
...
@@ -26,14 +24,12 @@ export const siteProfiles = [
id
:
'
gid://gitlab/DastSiteProfile/1
'
,
id
:
'
gid://gitlab/DastSiteProfile/1
'
,
profileName
:
'
Site profile #1
'
,
profileName
:
'
Site profile #1
'
,
targetUrl
:
'
https://foo.com
'
,
targetUrl
:
'
https://foo.com
'
,
editPath
:
'
/site_profiles/edit/1
'
,
validationStatus
:
'
PENDING_VALIDATION
'
,
validationStatus
:
'
PENDING_VALIDATION
'
,
},
},
{
{
id
:
'
gid://gitlab/DastSiteProfile/2
'
,
id
:
'
gid://gitlab/DastSiteProfile/2
'
,
profileName
:
'
Site profile #2
'
,
profileName
:
'
Site profile #2
'
,
targetUrl
:
'
https://bar.com
'
,
targetUrl
:
'
https://bar.com
'
,
editPath
:
'
/site_profiles/edit/2
'
,
validationStatus
:
'
PASSED_VALIDATION
'
,
validationStatus
:
'
PASSED_VALIDATION
'
,
},
},
];
];
ee/spec/frontend/on_demand_scans/mocks/apollo_mocks.js
deleted
100644 → 0
View file @
0255e321
import
{
scannerProfiles
,
siteProfiles
}
from
'
./mock_data
'
;
const
defaults
=
{
pageInfo
:
{
hasNextPage
:
false
,
hasPreviousPage
:
false
,
startCursor
:
null
,
endCursor
:
null
,
},
};
export
const
dastScannerProfiles
=
(
profiles
=
scannerProfiles
)
=>
({
data
:
{
project
:
{
scannerProfiles
:
{
...
defaults
,
edges
:
profiles
.
map
(
profile
=>
({
cursor
:
''
,
node
:
profile
,
})),
},
},
},
});
export
const
dastSiteProfiles
=
(
profiles
=
siteProfiles
)
=>
({
data
:
{
project
:
{
siteProfiles
:
{
...
defaults
,
edges
:
profiles
.
map
(
profile
=>
({
cursor
:
''
,
node
:
profile
,
})),
},
},
},
});
ee/spec/frontend/security_configuration/dast_scanner_profiles_form/components/dast_scanner_profiles_form_spec.js
View file @
7ef723e5
...
@@ -6,7 +6,7 @@ import DastScannerProfileForm from 'ee/security_configuration/dast_scanner_profi
...
@@ -6,7 +6,7 @@ import DastScannerProfileForm from 'ee/security_configuration/dast_scanner_profi
import
{
SCAN_TYPE
}
from
'
ee/security_configuration/dast_scanner_profiles/constants
'
;
import
{
SCAN_TYPE
}
from
'
ee/security_configuration/dast_scanner_profiles/constants
'
;
import
dastScannerProfileCreateMutation
from
'
ee/security_configuration/dast_scanner_profiles/graphql/dast_scanner_profile_create.mutation.graphql
'
;
import
dastScannerProfileCreateMutation
from
'
ee/security_configuration/dast_scanner_profiles/graphql/dast_scanner_profile_create.mutation.graphql
'
;
import
dastScannerProfileUpdateMutation
from
'
ee/security_configuration/dast_scanner_profiles/graphql/dast_scanner_profile_update.mutation.graphql
'
;
import
dastScannerProfileUpdateMutation
from
'
ee/security_configuration/dast_scanner_profiles/graphql/dast_scanner_profile_update.mutation.graphql
'
;
import
{
scannerProfiles
}
from
'
ee_jest/on_demand_scans/mock
s/mock
_data
'
;
import
{
scannerProfiles
}
from
'
ee_jest/on_demand_scans/mock_data
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
redirectTo
}
from
'
~/lib/utils/url_utility
'
;
import
{
redirectTo
}
from
'
~/lib/utils/url_utility
'
;
...
...
ee/spec/frontend/security_configuration/dast_site_profiles_form/components/dast_site_profile_form_spec.js
View file @
7ef723e5
...
@@ -7,7 +7,7 @@ import VueApollo from 'vue-apollo';
...
@@ -7,7 +7,7 @@ import VueApollo from 'vue-apollo';
import
DastSiteProfileForm
from
'
ee/security_configuration/dast_site_profiles_form/components/dast_site_profile_form.vue
'
;
import
DastSiteProfileForm
from
'
ee/security_configuration/dast_site_profiles_form/components/dast_site_profile_form.vue
'
;
import
dastSiteProfileCreateMutation
from
'
ee/security_configuration/dast_site_profiles_form/graphql/dast_site_profile_create.mutation.graphql
'
;
import
dastSiteProfileCreateMutation
from
'
ee/security_configuration/dast_site_profiles_form/graphql/dast_site_profile_create.mutation.graphql
'
;
import
dastSiteProfileUpdateMutation
from
'
ee/security_configuration/dast_site_profiles_form/graphql/dast_site_profile_update.mutation.graphql
'
;
import
dastSiteProfileUpdateMutation
from
'
ee/security_configuration/dast_site_profiles_form/graphql/dast_site_profile_update.mutation.graphql
'
;
import
{
siteProfiles
}
from
'
ee_jest/on_demand_scans/mock
s/mock
_data
'
;
import
{
siteProfiles
}
from
'
ee_jest/on_demand_scans/mock_data
'
;
import
*
as
responses
from
'
ee_jest/security_configuration/dast_site_profiles_form/mock_data/apollo_mock
'
;
import
*
as
responses
from
'
ee_jest/security_configuration/dast_site_profiles_form/mock_data/apollo_mock
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
waitForPromises
from
'
jest/helpers/wait_for_promises
'
;
import
waitForPromises
from
'
jest/helpers/wait_for_promises
'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment