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
d5539749
Commit
d5539749
authored
Nov 16, 2020
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Define permissions to read and modify on-call schedules
Renames a permissions prefix from manage_ to admin_
parent
5ceeea56
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
5 deletions
+57
-5
ee/app/graphql/mutations/incident_management/oncall_schedule/oncall_schedule_base.rb
...cident_management/oncall_schedule/oncall_schedule_base.rb
+1
-1
ee/app/policies/ee/project_policy.rb
ee/app/policies/ee/project_policy.rb
+2
-2
ee/app/services/incident_management/oncall_schedules/create_service.rb
...es/incident_management/oncall_schedules/create_service.rb
+1
-1
ee/spec/graphql/mutations/incident_management/oncall_schedule/create_spec.rb
...ations/incident_management/oncall_schedule/create_spec.rb
+1
-1
ee/spec/policies/project_policy_spec.rb
ee/spec/policies/project_policy_spec.rb
+52
-0
No files found.
ee/app/graphql/mutations/incident_management/oncall_schedule/oncall_schedule_base.rb
View file @
d5539749
...
@@ -9,7 +9,7 @@ module Mutations
...
@@ -9,7 +9,7 @@ module Mutations
null:
true
,
null:
true
,
description:
'The on-call schedule'
description:
'The on-call schedule'
authorize
:
modify
_incident_management_oncall_schedule
authorize
:
admin
_incident_management_oncall_schedule
private
private
...
...
ee/app/policies/ee/project_policy.rb
View file @
d5539749
...
@@ -178,6 +178,7 @@ module EE
...
@@ -178,6 +178,7 @@ module EE
enable
:read_deploy_board
enable
:read_deploy_board
enable
:admin_epic_issue
enable
:admin_epic_issue
enable
:read_group_timelogs
enable
:read_group_timelogs
enable
:read_incident_management_oncall_schedule
end
end
rule
{
can?
(
:developer_access
)
}.
policy
do
rule
{
can?
(
:developer_access
)
}.
policy
do
...
@@ -241,8 +242,7 @@ module EE
...
@@ -241,8 +242,7 @@ module EE
enable
:modify_auto_fix_setting
enable
:modify_auto_fix_setting
enable
:modify_merge_request_author_setting
enable
:modify_merge_request_author_setting
enable
:modify_merge_request_committer_setting
enable
:modify_merge_request_committer_setting
enable
:read_incident_management_oncall_schedule
enable
:admin_incident_management_oncall_schedule
enable
:modify_incident_management_oncall_schedule
end
end
rule
{
license_scanning_enabled
&
can?
(
:maintainer_access
)
}.
enable
:admin_software_license_policy
rule
{
license_scanning_enabled
&
can?
(
:maintainer_access
)
}.
enable
:admin_software_license_policy
...
...
ee/app/services/incident_management/oncall_schedules/create_service.rb
View file @
d5539749
...
@@ -27,7 +27,7 @@ module IncidentManagement
...
@@ -27,7 +27,7 @@ module IncidentManagement
attr_reader
:project
,
:user
,
:params
attr_reader
:project
,
:user
,
:params
def
allowed?
def
allowed?
user
&
.
can?
(
:
modify
_incident_management_oncall_schedule
,
project
)
user
&
.
can?
(
:
admin
_incident_management_oncall_schedule
,
project
)
end
end
def
available?
def
available?
...
...
ee/spec/graphql/mutations/incident_management/oncall_schedule/create_spec.rb
View file @
d5539749
...
@@ -14,7 +14,7 @@ RSpec.describe Mutations::IncidentManagement::OncallSchedule::Create do
...
@@ -14,7 +14,7 @@ RSpec.describe Mutations::IncidentManagement::OncallSchedule::Create do
}
}
end
end
specify
{
expect
(
described_class
).
to
require_graphql_authorizations
(
:
modify
_incident_management_oncall_schedule
)
}
specify
{
expect
(
described_class
).
to
require_graphql_authorizations
(
:
admin
_incident_management_oncall_schedule
)
}
describe
'#resolve'
do
describe
'#resolve'
do
subject
(
:resolve
)
{
mutation_for
(
project
,
current_user
).
resolve
(
args
)
}
subject
(
:resolve
)
{
mutation_for
(
project
,
current_user
).
resolve
(
args
)
}
...
...
ee/spec/policies/project_policy_spec.rb
View file @
d5539749
...
@@ -1342,6 +1342,58 @@ RSpec.describe ProjectPolicy do
...
@@ -1342,6 +1342,58 @@ RSpec.describe ProjectPolicy do
end
end
end
end
describe
'Incident Management on-call schedules'
do
using
RSpec
::
Parameterized
::
TableSyntax
context
':read_incident_management_oncall_schedule'
do
let
(
:policy
)
{
:read_incident_management_oncall_schedule
}
where
(
:role
,
:admin_mode
,
:allowed
)
do
:guest
|
nil
|
false
:reporter
|
nil
|
true
:developer
|
nil
|
true
:maintainer
|
nil
|
true
:owner
|
nil
|
true
:admin
|
false
|
false
:admin
|
true
|
true
end
before
do
enable_admin_mode!
(
current_user
)
if
admin_mode
end
with_them
do
let
(
:current_user
)
{
public_send
(
role
)
}
it
{
is_expected
.
to
(
allowed
?
be_allowed
(
policy
)
:
be_disallowed
(
policy
))
}
end
end
context
':admin_incident_management_oncall_schedule'
do
let
(
:policy
)
{
:admin_incident_management_oncall_schedule
}
where
(
:role
,
:admin_mode
,
:allowed
)
do
:guest
|
nil
|
false
:reporter
|
nil
|
false
:developer
|
nil
|
false
:maintainer
|
nil
|
true
:owner
|
nil
|
true
:admin
|
false
|
false
:admin
|
true
|
true
end
before
do
enable_admin_mode!
(
current_user
)
if
admin_mode
end
with_them
do
let
(
:current_user
)
{
public_send
(
role
)
}
it
{
is_expected
.
to
(
allowed
?
be_allowed
(
policy
)
:
be_disallowed
(
policy
))
}
end
end
end
context
'when project is readonly because the storage usage limit has been exceeded on the root namespace'
do
context
'when project is readonly because the storage usage limit has been exceeded on the root namespace'
do
let
(
:current_user
)
{
owner
}
let
(
:current_user
)
{
owner
}
let
(
:abilities
)
do
let
(
:abilities
)
do
...
...
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