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
c70a6991
Commit
c70a6991
authored
Mar 12, 2021
by
Serena Fang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for read and destroy tokens
parent
11d2b257
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
app/policies/project_policy.rb
app/policies/project_policy.rb
+4
-0
spec/support/shared_examples/policies/resource_access_token_shared_examples.rb
...xamples/policies/resource_access_token_shared_examples.rb
+28
-0
No files found.
app/policies/project_policy.rb
View file @
c70a6991
...
@@ -644,6 +644,10 @@ class ProjectPolicy < BasePolicy
...
@@ -644,6 +644,10 @@ class ProjectPolicy < BasePolicy
enable
:create_resource_access_tokens
enable
:create_resource_access_tokens
end
end
rule
{
can?
(
:project_bot_access
)
}.
policy
do
prevent
:create_resource_access_tokens
end
rule
{
user_defined_variables_allowed
|
can?
(
:maintainer_access
)
}.
policy
do
rule
{
user_defined_variables_allowed
|
can?
(
:maintainer_access
)
}.
policy
do
enable
:set_pipeline_variables
enable
:set_pipeline_variables
end
end
...
...
spec/support/shared_examples/policies/resource_access_token_shared_examples.rb
View file @
c70a6991
...
@@ -18,6 +18,34 @@ RSpec.shared_examples 'Self-managed Core resource access tokens' do
...
@@ -18,6 +18,34 @@ RSpec.shared_examples 'Self-managed Core resource access tokens' do
it
{
is_expected
.
not_to
be_allowed
(
:create_resource_access_tokens
)
}
it
{
is_expected
.
not_to
be_allowed
(
:create_resource_access_tokens
)
}
end
end
end
end
context
'read resource access tokens'
do
context
'with owner'
do
let
(
:current_user
)
{
owner
}
it
{
is_expected
.
to
be_allowed
(
:read_resource_access_tokens
)
}
end
context
'with developer'
do
let
(
:current_user
)
{
developer
}
it
{
is_expected
.
not_to
be_allowed
(
:read_resource_access_tokens
)
}
end
end
context
'destroy resource access tokens'
do
context
'with owner'
do
let
(
:current_user
)
{
owner
}
it
{
is_expected
.
to
be_allowed
(
:destroy_resource_access_tokens
)
}
end
context
'with developer'
do
let
(
:current_user
)
{
developer
}
it
{
is_expected
.
not_to
be_allowed
(
:destroy_resource_access_tokens
)
}
end
end
end
end
RSpec
.
shared_examples
'GitLab.com Core resource access tokens'
do
RSpec
.
shared_examples
'GitLab.com Core resource access tokens'
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