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
c5ea95a1
Commit
c5ea95a1
authored
Jul 02, 2020
by
Philip Cunningham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stub out DAST site profile creation mutation
parent
01682e0e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
118 additions
and
0 deletions
+118
-0
ee/app/graphql/mutations/dast_site_profiles/create.rb
ee/app/graphql/mutations/dast_site_profiles/create.rb
+44
-0
ee/spec/graphql/mutations/dast_site_profiles/create_spec.rb
ee/spec/graphql/mutations/dast_site_profiles/create_spec.rb
+74
-0
No files found.
ee/app/graphql/mutations/dast_site_profiles/create.rb
0 → 100644
View file @
c5ea95a1
# frozen_string_literal: true
module
Mutations
module
DastSiteProfiles
class
Create
<
BaseMutation
include
ResolvesProject
graphql_name
'DastSiteProfileCreate'
field
:id
,
GraphQL
::
ID_TYPE
,
null:
false
,
description:
'ID of the site profile.'
argument
:full_path
,
GraphQL
::
ID_TYPE
,
required:
true
,
description:
'The project the site profile belongs to.'
argument
:profile_name
,
GraphQL
::
STRING_TYPE
,
required:
true
,
description:
'The name of the site profile.'
argument
:target_url
,
GraphQL
::
STRING_TYPE
,
required:
false
,
description:
'The URL of the target to be scanned.'
authorize
:run_ondemand_dast_scan
def
resolve
(
full_path
:,
profile_name
:,
target_url:
nil
)
project
=
authorized_find!
(
full_path:
full_path
)
raise_resource_not_available_error!
unless
Feature
.
enabled?
(
:security_on_demand_scans_feature_flag
,
project
)
{
errors:
[
'Not implemented'
]
}
end
private
def
find_object
(
full_path
:)
resolve_project
(
full_path:
full_path
)
end
end
end
end
ee/spec/graphql/mutations/dast_site_profiles/create_spec.rb
0 → 100644
View file @
c5ea95a1
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Mutations
::
DastSiteProfiles
::
Create
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:full_path
)
{
project
.
full_path
}
let
(
:profile_name
)
{
SecureRandom
.
hex
}
let
(
:target_url
)
{
FFaker
::
Internet
.
uri
(
:https
)
}
subject
(
:mutation
)
{
described_class
.
new
(
object:
nil
,
context:
{
current_user:
user
},
field:
nil
)
}
describe
'#resolve'
do
subject
do
mutation
.
resolve
(
full_path:
full_path
,
profile_name:
profile_name
,
target_url:
target_url
)
end
context
'when on demand scan feature is not enabled'
do
it
'raises an exception'
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
)
end
end
context
'when on demand scan feature is enabled'
do
before
do
stub_feature_flags
(
security_on_demand_scans_feature_flag:
true
)
end
context
'when the project does not exist'
do
let
(
:full_path
)
{
SecureRandom
.
hex
}
it
'raises an exception'
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
)
end
end
context
'when the user is not associated with the project'
do
it
'raises an exception'
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
)
end
end
context
'when the user is an owner'
do
it
'stubs out the response'
do
group
.
add_owner
(
user
)
expect
(
subject
[
:errors
]).
to
eq
([
'Not implemented'
])
end
end
context
'when the user is a maintainer'
do
it
'stubs out the response'
do
project
.
add_maintainer
(
user
)
expect
(
subject
[
:errors
]).
to
eq
([
'Not implemented'
])
end
end
context
'when the user is a developer'
do
it
'stubs out the response'
do
project
.
add_developer
(
user
)
expect
(
subject
[
:errors
]).
to
eq
([
'Not implemented'
])
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