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
54eca155
Commit
54eca155
authored
Jun 10, 2021
by
Pedro Pombeiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add policy tests for update_runners_registration_token
parent
8482efbd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
116 additions
and
0 deletions
+116
-0
spec/policies/global_policy_spec.rb
spec/policies/global_policy_spec.rb
+30
-0
spec/policies/group_policy_spec.rb
spec/policies/group_policy_spec.rb
+50
-0
spec/policies/project_policy_spec.rb
spec/policies/project_policy_spec.rb
+36
-0
No files found.
spec/policies/global_policy_spec.rb
View file @
54eca155
...
...
@@ -565,4 +565,34 @@ RSpec.describe GlobalPolicy do
it
{
is_expected
.
not_to
be_allowed
(
:log_in
)
}
end
end
describe
'update_runners_registration_token'
do
context
'when anonymous'
do
let
(
:current_user
)
{
nil
}
it
{
is_expected
.
not_to
be_allowed
(
:update_runners_registration_token
)
}
end
context
'regular user'
do
it
{
is_expected
.
not_to
be_allowed
(
:update_runners_registration_token
)
}
end
context
'when external'
do
let
(
:current_user
)
{
build
(
:user
,
:external
)
}
it
{
is_expected
.
not_to
be_allowed
(
:update_runners_registration_token
)
}
end
context
'admin'
do
let
(
:current_user
)
{
create
(
:admin
)
}
context
'when admin mode is enabled'
,
:enable_admin_mode
do
it
{
is_expected
.
to
be_allowed
(
:update_runners_registration_token
)
}
end
context
'when admin mode is disabled'
do
it
{
is_expected
.
to
be_disallowed
(
:update_runners_registration_token
)
}
end
end
end
end
spec/policies/group_policy_spec.rb
View file @
54eca155
...
...
@@ -923,4 +923,54 @@ RSpec.describe GroupPolicy do
it
{
expect
(
described_class
.
new
(
current_user
,
subgroup
)).
to
be_allowed
(
:read_label
)
}
end
end
describe
'update_runners_registration_token'
do
context
'admin'
do
let
(
:current_user
)
{
admin
}
context
'when admin mode is enabled'
,
:enable_admin_mode
do
it
{
is_expected
.
to
be_allowed
(
:update_runners_registration_token
)
}
end
context
'when admin mode is disabled'
do
it
{
is_expected
.
to
be_disallowed
(
:update_runners_registration_token
)
}
end
end
context
'with owner'
do
let
(
:current_user
)
{
owner
}
it
{
is_expected
.
to
be_allowed
(
:update_runners_registration_token
)
}
end
context
'with maintainer'
do
let
(
:current_user
)
{
maintainer
}
it
{
is_expected
.
to
be_allowed
(
:update_runners_registration_token
)
}
end
context
'with reporter'
do
let
(
:current_user
)
{
reporter
}
it
{
is_expected
.
to
be_disallowed
(
:update_runners_registration_token
)
}
end
context
'with guest'
do
let
(
:current_user
)
{
guest
}
it
{
is_expected
.
to
be_disallowed
(
:update_runners_registration_token
)
}
end
context
'with non member'
do
let
(
:current_user
)
{
create
(
:user
)
}
it
{
is_expected
.
to
be_disallowed
(
:update_runners_registration_token
)
}
end
context
'with anonymous'
do
let
(
:current_user
)
{
nil
}
it
{
is_expected
.
to
be_disallowed
(
:update_runners_registration_token
)
}
end
end
end
spec/policies/project_policy_spec.rb
View file @
54eca155
...
...
@@ -1595,4 +1595,40 @@ RSpec.describe ProjectPolicy do
end
end
end
describe
'update_runners_registration_token'
do
context
'when anonymous'
do
let
(
:current_user
)
{
anonymous
}
it
{
is_expected
.
not_to
be_allowed
(
:update_runners_registration_token
)
}
end
context
'admin'
do
let
(
:current_user
)
{
create
(
:admin
)
}
context
'when admin mode is enabled'
,
:enable_admin_mode
do
it
{
is_expected
.
to
be_allowed
(
:update_runners_registration_token
)
}
end
context
'when admin mode is disabled'
do
it
{
is_expected
.
to
be_disallowed
(
:update_runners_registration_token
)
}
end
end
%w(guest reporter developer)
.
each
do
|
role
|
context
role
do
let
(
:current_user
)
{
send
(
role
)
}
it
{
is_expected
.
to
be_disallowed
(
:update_runners_registration_token
)
}
end
end
%w(maintainer owner)
.
each
do
|
role
|
context
role
do
let
(
:current_user
)
{
send
(
role
)
}
it
{
is_expected
.
to
be_allowed
(
:update_runners_registration_token
)
}
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