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
c923769b
Commit
c923769b
authored
Jan 07, 2021
by
Dheeraj Joshi
Committed by
Mark Florian
Jan 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Populate On-demand Scan profiles using query params
parent
68a0396f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
2 deletions
+54
-2
ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_form.vue
...ripts/on_demand_scans/components/on_demand_scans_form.vue
+14
-1
ee/app/assets/javascripts/on_demand_scans/settings.js
ee/app/assets/javascripts/on_demand_scans/settings.js
+3
-0
ee/spec/frontend/on_demand_scans/components/on_demand_scans_form_spec.js
...d/on_demand_scans/components/on_demand_scans_form_spec.js
+37
-1
No files found.
ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_form.vue
View file @
c923769b
...
...
@@ -22,7 +22,8 @@ import { s__ } from '~/locale';
import
validation
from
'
~/vue_shared/directives/validation
'
;
import
*
as
Sentry
from
'
~/sentry/wrapper
'
;
import
glFeatureFlagsMixin
from
'
~/vue_shared/mixins/gl_feature_flags_mixin
'
;
import
{
redirectTo
}
from
'
~/lib/utils/url_utility
'
;
import
{
redirectTo
,
queryToObject
}
from
'
~/lib/utils/url_utility
'
;
import
{
convertToGraphQLId
}
from
'
~/graphql_shared/utils
'
;
import
{
ERROR_RUN_SCAN
,
ERROR_FETCH_SCANNER_PROFILES
,
...
...
@@ -31,6 +32,8 @@ import {
SCANNER_PROFILES_QUERY
,
SITE_PROFILES_QUERY
,
SITE_PROFILES_EXTENDED_QUERY
,
TYPE_SITE_PROFILE
,
TYPE_SCANNER_PROFILE
,
}
from
'
../settings
'
;
import
dastScanCreateMutation
from
'
../graphql/dast_scan_create.mutation.graphql
'
;
import
dastScanUpdateMutation
from
'
../graphql/dast_scan_update.mutation.graphql
'
;
...
...
@@ -219,6 +222,16 @@ export default {
return
isFormInvalid
||
(
loading
&&
loading
!==
saveScanBtnId
);
},
},
created
()
{
const
params
=
queryToObject
(
window
.
location
.
search
);
this
.
selectedSiteProfileId
=
params
.
site_profile_id
?
convertToGraphQLId
(
TYPE_SITE_PROFILE
,
params
.
site_profile_id
)
:
this
.
selectedSiteProfileId
;
this
.
selectedScannerProfileId
=
params
.
scanner_profile_id
?
convertToGraphQLId
(
TYPE_SCANNER_PROFILE
,
params
.
scanner_profile_id
)
:
this
.
selectedScannerProfileId
;
},
methods
:
{
onSubmit
({
runAfterCreate
=
true
,
button
=
this
.
$options
.
saveAndRunScanBtnId
}
=
{})
{
if
(
this
.
glFeatures
.
dastSavedScans
)
{
...
...
ee/app/assets/javascripts/on_demand_scans/settings.js
View file @
c923769b
...
...
@@ -33,3 +33,6 @@ export const SITE_PROFILES_EXTENDED_QUERY = {
...
SITE_PROFILES_QUERY
,
fetchQuery
:
dastSiteProfilesExtendedQuery
,
};
export
const
TYPE_SITE_PROFILE
=
'
DastSiteProfile
'
;
export
const
TYPE_SCANNER_PROFILE
=
'
DastScannerProfile
'
;
ee/spec/frontend/on_demand_scans/components/on_demand_scans_form_spec.js
View file @
c923769b
...
...
@@ -14,8 +14,9 @@ import dastSiteProfilesQuery from 'ee/security_configuration/dast_profiles/graph
import
{
stubComponent
}
from
'
helpers/stub_component
'
;
import
*
as
responses
from
'
../mocks/apollo_mocks
'
;
import
{
scannerProfiles
,
siteProfiles
}
from
'
../mocks/mock_data
'
;
import
{
redirectTo
}
from
'
~/lib/utils/url_utility
'
;
import
{
redirectTo
,
setUrlParams
}
from
'
~/lib/utils/url_utility
'
;
const
URL_HOST
=
'
https://localhost/
'
;
const
helpPagePath
=
'
/application_security/dast/index#on-demand-scans
'
;
const
projectPath
=
'
group/project
'
;
const
defaultBranch
=
'
master
'
;
...
...
@@ -44,6 +45,8 @@ const dastScan = {
jest
.
mock
(
'
~/lib/utils/url_utility
'
,
()
=>
({
isAbsolute
:
jest
.
requireActual
(
'
~/lib/utils/url_utility
'
).
isAbsolute
,
queryToObject
:
jest
.
requireActual
(
'
~/lib/utils/url_utility
'
).
queryToObject
,
setUrlParams
:
jest
.
requireActual
(
'
~/lib/utils/url_utility
'
).
setUrlParams
,
redirectTo
:
jest
.
fn
(),
}));
...
...
@@ -504,4 +507,37 @@ describe('OnDemandScansForm', () => {
expect
(
summary
).
toMatch
(
authEnabledProfile
.
auth
.
passwordField
);
});
});
describe
(
'
populate profiles from query params
'
,
()
=>
{
const
[
siteProfile
]
=
siteProfiles
;
const
[
scannerProfile
]
=
scannerProfiles
;
it
(
'
scanner profile
'
,
()
=>
{
global
.
jsdom
.
reconfigure
({
url
:
setUrlParams
({
scanner_profile_id
:
1
},
URL_HOST
),
});
mountShallowSubject
();
expect
(
subject
.
find
(
ScannerProfileSelector
).
attributes
(
'
value
'
)).
toBe
(
scannerProfile
.
id
);
});
it
(
'
site profile
'
,
()
=>
{
global
.
jsdom
.
reconfigure
({
url
:
setUrlParams
({
site_profile_id
:
1
},
URL_HOST
),
});
mountShallowSubject
();
expect
(
subject
.
find
(
SiteProfileSelector
).
attributes
(
'
value
'
)).
toBe
(
siteProfile
.
id
);
});
it
(
'
both scanner & site profile
'
,
()
=>
{
global
.
jsdom
.
reconfigure
({
url
:
setUrlParams
({
site_profile_id
:
1
,
scanner_profile_id
:
1
},
URL_HOST
),
});
mountShallowSubject
();
expect
(
subject
.
find
(
SiteProfileSelector
).
attributes
(
'
value
'
)).
toBe
(
siteProfile
.
id
);
expect
(
subject
.
find
(
ScannerProfileSelector
).
attributes
(
'
value
'
)).
toBe
(
scannerProfile
.
id
);
});
});
});
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