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
20a5a6e8
Commit
20a5a6e8
authored
Feb 04, 2021
by
Philip Cunningham
Committed by
Luke Duncalfe
Feb 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Retrieve Dast::Profile in controller
parent
a94f7e22
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
9 deletions
+56
-9
ee/app/controllers/projects/on_demand_scans_controller.rb
ee/app/controllers/projects/on_demand_scans_controller.rb
+9
-6
ee/app/views/projects/on_demand_scans/edit.html.haml
ee/app/views/projects/on_demand_scans/edit.html.haml
+1
-1
ee/spec/requests/projects/on_demand_scans_controller_spec.rb
ee/spec/requests/projects/on_demand_scans_controller_spec.rb
+46
-2
No files found.
ee/app/controllers/projects/on_demand_scans_controller.rb
View file @
20a5a6e8
...
...
@@ -22,12 +22,15 @@ module Projects
def
edit
not_found
unless
Feature
.
enabled?
(
:dast_saved_scans
,
@project
,
default_enabled: :yaml
)
@dast_scan
=
{
id:
1
,
name:
"My saved DAST scan"
,
description:
"My scan's description"
,
scannerProfileId:
"gid://gitlab/DastScannerProfile/5"
,
siteProfileId:
"gid://gitlab/DastSiteProfile/15"
dast_profile
=
Dast
::
ProfilesFinder
.
new
(
project_id:
@project
.
id
,
id:
params
[
:id
]).
execute
.
first!
# rubocop: disable CodeReuse/ActiveRecord
@dast_profile
=
{
id:
dast_profile
.
to_global_id
.
to_s
,
name:
dast_profile
.
name
,
description:
dast_profile
.
description
,
site_profile_id:
DastSiteProfile
.
new
(
id:
dast_profile
.
dast_site_profile_id
).
to_global_id
.
to_s
,
scanner_profile_id:
DastScannerProfile
.
new
(
id:
dast_profile
.
dast_scanner_profile_id
).
to_global_id
.
to_s
}
end
end
...
...
ee/app/views/projects/on_demand_scans/edit.html.haml
View file @
20a5a6e8
-
breadcrumb_title
s_
(
'OnDemandScans|Edit on-demand DAST scan'
)
-
page_title
s_
(
'OnDemandScans|Edit on-demand DAST scan'
)
#js-on-demand-scans-app
{
data:
on_demand_scans_data
(
@project
).
merge
({
dast_scan:
@dast_scan
.
to_json
})
}
#js-on-demand-scans-app
{
data:
on_demand_scans_data
(
@project
).
merge
({
dast_scan:
@dast_profile
.
to_json
})
}
ee/spec/requests/projects/on_demand_scans_controller_spec.rb
View file @
20a5a6e8
...
...
@@ -3,6 +3,8 @@
require
'spec_helper'
RSpec
.
describe
Projects
::
OnDemandScansController
,
type: :request
do
include
GraphqlHelpers
let_it_be
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
...
...
@@ -70,9 +72,51 @@ RSpec.describe Projects::OnDemandScansController, type: :request do
end
describe
'GET #edit'
do
let_it_be
(
:dast_profile
)
{
create
(
:dast_profile
,
project:
project
)
}
let
(
:dast_profile_id
)
{
dast_profile
.
id
}
let
(
:edit_path
)
{
edit_project_on_demand_scan_path
(
project
,
id:
dast_profile_id
)
}
it_behaves_like
'on-demand scans page'
do
# This should be improved as part of https://gitlab.com/gitlab-org/gitlab/-/issues/295242
let
(
:path
)
{
edit_project_on_demand_scan_path
(
project
,
id:
1
)
}
let
(
:path
)
{
edit_path
}
end
context
'feature available and user can access page'
do
before
do
stub_licensed_features
(
security_on_demand_scans:
true
)
project
.
add_developer
(
user
)
login_as
(
user
)
end
context
'dast_profile exists in the database'
do
it
'includes a serialized dast_profile in the response body'
do
get
edit_path
json_data
=
{
id:
global_id_of
(
dast_profile
),
name:
dast_profile
.
name
,
description:
dast_profile
.
description
,
site_profile_id:
global_id_of
(
DastSiteProfile
.
new
(
id:
dast_profile
.
dast_site_profile_id
)),
scanner_profile_id:
global_id_of
(
DastScannerProfile
.
new
(
id:
dast_profile
.
dast_scanner_profile_id
))
}.
to_json
on_demand_div
=
Nokogiri
::
HTML
.
parse
(
response
.
body
).
at_css
(
'div#js-on-demand-scans-app'
)
expect
(
on_demand_div
.
attributes
[
'data-dast-scan'
].
value
).
to
include
(
json_data
)
end
end
context
'dast_profile does not exist in the database'
do
let
(
:dast_profile_id
)
{
0
}
it
'sees a 404 error'
do
get
edit_path
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
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