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
44e2a3a4
Commit
44e2a3a4
authored
Feb 18, 2021
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more permission checks to HTTP Integration specs
parent
545f89c0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
9 deletions
+42
-9
ee/spec/requests/api/graphql/project/alert_management/http_integrations_spec.rb
...raphql/project/alert_management/http_integrations_spec.rb
+24
-4
spec/graphql/resolvers/alert_management/http_integrations_resolver_spec.rb
...lvers/alert_management/http_integrations_resolver_spec.rb
+18
-5
No files found.
ee/spec/requests/api/graphql/project/alert_management/http_integrations_spec.rb
View file @
44e2a3a4
...
...
@@ -23,7 +23,9 @@ RSpec.describe 'getting Alert Management HTTP Integrations' do
end
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:maintainer
)
{
create
(
:user
)
}
let_it_be
(
:developer
)
{
create
(
:user
)
}
let_it_be
(
:guest
)
{
create
(
:user
)
}
let_it_be
(
:prometheus_service
)
{
create
(
:prometheus_service
,
project:
project
)
}
let_it_be
(
:project_alerting_setting
)
{
create
(
:project_alerting_setting
,
project:
project
)
}
let_it_be
(
:inactive_http_integration
)
{
create
(
:alert_management_http_integration
,
:inactive
,
project:
project
)
}
...
...
@@ -58,11 +60,16 @@ RSpec.describe 'getting Alert Management HTTP Integrations' do
stub_feature_flags
(
multiple_http_integrations_custom_mapping:
project
)
end
before_all
do
project
.
add_developer
(
developer
)
project
.
add_maintainer
(
maintainer
)
end
context
'with integrations'
do
let
(
:integrations
)
{
graphql_data
.
dig
(
'project'
,
'alertManagementHttpIntegrations'
,
'nodes'
)
}
context
'without project permissions'
do
let
(
:
user
)
{
create
(
:user
)
}
let
(
:
current_user
)
{
guest
}
before
do
post_graphql
(
query
,
current_user:
current_user
)
...
...
@@ -73,9 +80,22 @@ RSpec.describe 'getting Alert Management HTTP Integrations' do
specify
{
expect
(
integrations
).
to
be_nil
}
end
context
'with project permissions'
do
context
'with developer permissions'
do
let
(
:current_user
)
{
developer
}
before
do
post_graphql
(
query
,
current_user:
current_user
)
end
it_behaves_like
'a working graphql query'
specify
{
expect
(
integrations
).
to
eq
([])
}
end
context
'with maintainer permissions'
do
let
(
:current_user
)
{
maintainer
}
before
do
project
.
add_maintainer
(
current_user
)
post_graphql
(
query
,
current_user:
current_user
)
end
...
...
spec/graphql/resolvers/alert_management/http_integrations_resolver_spec.rb
View file @
44e2a3a4
...
...
@@ -5,7 +5,9 @@ require 'spec_helper'
RSpec
.
describe
Resolvers
::
AlertManagement
::
HttpIntegrationsResolver
do
include
GraphqlHelpers
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:guest
)
{
create
(
:user
)
}
let_it_be
(
:developer
)
{
create
(
:user
)
}
let_it_be
(
:maintainer
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:prometheus_integration
)
{
create
(
:prometheus_service
,
project:
project
)
}
let_it_be
(
:active_http_integration
)
{
create
(
:alert_management_http_integration
,
project:
project
)
}
...
...
@@ -14,19 +16,30 @@ RSpec.describe Resolvers::AlertManagement::HttpIntegrationsResolver do
subject
{
sync
(
resolve_http_integrations
)
}
before
do
project
.
add_developer
(
developer
)
project
.
add_maintainer
(
maintainer
)
end
specify
do
expect
(
described_class
).
to
have_nullable_graphql_type
(
Types
::
AlertManagement
::
HttpIntegrationType
.
connection_type
)
end
context
'user does not have permission'
do
let
(
:current_user
)
{
guest
}
it
{
is_expected
.
to
be_empty
}
end
context
'user has permission'
do
before
do
project
.
add_maintainer
(
current_user
)
context
'user has developer permission'
do
let
(
:current_user
)
{
developer
}
it
{
is_expected
.
to
be_empty
}
end
context
'user has maintainer permission'
do
let
(
:current_user
)
{
maintainer
}
it
{
is_expected
.
to
contain_exactly
(
active_http_integration
)
}
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