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
59ad8552
Commit
59ad8552
authored
Jul 31, 2020
by
Philip Cunningham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to fetch DastSiteProfile via GraphQL
Adds new field to project and associated tests.
parent
cf057764
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
155 additions
and
0 deletions
+155
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+10
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+27
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+1
-0
ee/app/graphql/ee/types/project_type.rb
ee/app/graphql/ee/types/project_type.rb
+10
-0
ee/changelogs/unreleased/dast-site-profile-graphql-query.yml
ee/changelogs/unreleased/dast-site-profile-graphql-query.yml
+5
-0
ee/spec/requests/api/graphql/project/dast_site_profile_spec.rb
...ec/requests/api/graphql/project/dast_site_profile_spec.rb
+102
-0
No files found.
doc/api/graphql/reference/gitlab_schema.graphql
View file @
59ad8552
...
...
@@ -11115,6 +11115,16 @@ type Project {
last
:
Int
):
DastScannerProfileConnection
"""
DAST
Site
Profile
associated
with
the
project
"""
dastSiteProfile
(
"""
ID
of
the
site
profile
"""
id
:
DastSiteProfileID
!
):
DastSiteProfile
"""
DAST
Site
Profiles
associated
with
the
project
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
59ad8552
...
...
@@ -33320,6 +33320,33 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "dastSiteProfile",
"description": "DAST Site Profile associated with the project",
"args": [
{
"name": "id",
"description": "ID of the site profile",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "DastSiteProfileID",
"ofType": null
}
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
"name": "DastSiteProfile",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "dastSiteProfiles",
"description": "DAST Site Profiles associated with the project",
doc/api/graphql/reference/index.md
View file @
59ad8552
...
...
@@ -1717,6 +1717,7 @@ Autogenerated return type of PipelineRetry
|
`containerExpirationPolicy`
| ContainerExpirationPolicy | The container expiration policy of the project |
|
`containerRegistryEnabled`
| Boolean | Indicates if the project stores Docker container images in a container registry |
|
`createdAt`
| Time | Timestamp of the project creation |
|
`dastSiteProfile`
| DastSiteProfile | DAST Site Profile associated with the project |
|
`description`
| String | Short description of the project |
|
`descriptionHtml`
| String | The GitLab Flavored Markdown rendering of
`description`
|
|
`environment`
| Environment | A single environment of the project |
...
...
ee/app/graphql/ee/types/project_type.rb
View file @
59ad8552
...
...
@@ -77,6 +77,16 @@ module EE
description:
'Find iterations'
,
resolver:
::
Resolvers
::
IterationsResolver
field
:dast_site_profile
,
::
Types
::
DastSiteProfileType
,
null:
true
,
resolve:
->
(
obj
,
args
,
_ctx
)
do
DastSiteProfilesFinder
.
new
(
project_id:
obj
.
id
,
id:
args
[
:id
].
model_id
).
execute
.
first
end
,
description:
'DAST Site Profile associated with the project'
do
argument
:id
,
::
Types
::
GlobalIDType
[
::
DastSiteProfile
],
required:
true
,
description:
'ID of the site profile'
end
field
:dast_site_profiles
,
::
Types
::
DastSiteProfileType
.
connection_type
,
null:
true
,
...
...
ee/changelogs/unreleased/dast-site-profile-graphql-query.yml
0 → 100644
View file @
59ad8552
---
title
:
Add ability to fetch DastSiteProfile via GraphQL
merge_request
:
38380
author
:
type
:
added
ee/spec/requests/api/graphql/project/dast_site_profile_spec.rb
0 → 100644
View file @
59ad8552
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'Query.project(fullPath).dastSiteProfile'
do
include
GraphqlHelpers
let_it_be
(
:dast_site_profile
)
{
create
(
:dast_site_profile
)
}
let_it_be
(
:project
)
{
dast_site_profile
.
project
}
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let
(
:query
)
do
%(
query project($fullPath: ID!, $id: DastSiteProfileID!) {
project(fullPath: $fullPath) {
dastSiteProfile(id: $id) {
id
profileName
targetUrl
validationStatus
}
}
}
)
end
let
(
:project_response
)
{
subject
.
dig
(
'project'
)
}
let
(
:dast_site_profile_response
)
{
project_response
.
dig
(
'dastSiteProfile'
)
}
subject
do
post_graphql
(
query
,
current_user:
current_user
,
variables:
{
fullPath:
project
.
full_path
,
id:
dast_site_profile
.
to_global_id
.
to_s
}
)
graphql_data
end
before
do
stub_licensed_features
(
security_on_demand_scans:
true
)
end
context
'when a user does not have access to the project'
do
it
'returns a null project'
do
expect
(
project_response
).
to
be_nil
end
end
context
'when a user does not have access to dast_site_profiles'
do
it
'returns a null dast_site_profile'
do
project
.
add_guest
(
current_user
)
expect
(
dast_site_profile_response
).
to
be_nil
end
end
context
'when a user has access to dast_site_profiles'
do
before
do
project
.
add_developer
(
current_user
)
end
it
'returns a dast_site_profile'
do
expect
(
dast_site_profile_response
[
'id'
]).
to
eq
(
dast_site_profile
.
to_global_id
.
to_s
)
end
context
'when the wrong type of global id is supplied'
do
it
'returns a null dast_site_profile'
do
post_graphql
(
query
,
current_user:
current_user
,
variables:
{
fullPath:
project
.
full_path
,
id:
project
.
to_global_id
.
to_s
}
)
expected_message
=
'Variable $id of type DastSiteProfileID! was provided invalid value'
expect
(
graphql_errors
[
0
]).
to
include
(
'message'
=>
expected_message
)
end
end
context
'when on demand scan feature flag is disabled'
do
it
'returns a null dast_site_profile'
do
stub_feature_flags
(
security_on_demand_scans_feature_flag:
false
)
expect
(
dast_site_profile_response
).
to
be_nil
end
end
context
'when on demand scan licensed feature is not available'
do
it
'returns a null dast_site_profile'
do
stub_licensed_features
(
security_on_demand_scans:
false
)
expect
(
dast_site_profile_response
).
to
be_nil
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