BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
0a0f66c8
Commit
0a0f66c8
authored
May 22, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor to remove a special case
parent
7d469cf1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
7 deletions
+29
-7
ci_access.rb
lib/gitlab/ci_access.rb
+9
-0
git_access.rb
lib/gitlab/git_access.rb
+5
-7
ci_access_spec.rb
spec/lib/gitlab/ci_access_spec.rb
+15
-0
No files found.
lib/gitlab/ci_access.rb
0 → 100644
View file @
0a0f66c8
module
Gitlab
# For backwards compatibility, generic CI (which is a build without a user) is
# allowed to :build_download_code without any other checks.
class
CiAccess
def
can_do_action?
(
action
)
action
==
:build_download_code
end
end
end
lib/gitlab/git_access.rb
View file @
0a0f66c8
...
...
@@ -29,7 +29,11 @@ module Gitlab
@project
=
project
@protocol
=
protocol
@authentication_abilities
=
authentication_abilities
@user_access
=
UserAccess
.
new
(
user
,
project:
project
)
@user_access
=
if
ci?
CiAccess
.
new
else
UserAccess
.
new
(
user
,
project:
project
)
end
end
def
check
(
cmd
,
changes
)
...
...
@@ -62,11 +66,6 @@ module Gitlab
authentication_abilities
.
include?
(
:build_download_code
)
&&
user_access
.
can_do_action?
(
:build_download_code
)
end
# Allow generic CI (build without a user) for backwards compatibility
def
ci_can_download_code?
authentication_abilities
.
include?
(
:build_download_code
)
&&
ci?
end
def
protocol_allowed?
Gitlab
::
ProtocolAccess
.
allowed?
(
protocol
)
end
...
...
@@ -129,7 +128,6 @@ module Gitlab
return
if
deploy_key?
passed
=
user_can_download_code?
||
ci_can_download_code?
||
build_can_download_code?
||
guest_can_download_code?
...
...
spec/lib/gitlab/ci_access_spec.rb
0 → 100644
View file @
0a0f66c8
require
'spec_helper'
describe
Gitlab
::
CiAccess
,
lib:
true
do
let
(
:access
)
{
Gitlab
::
CiAccess
.
new
}
describe
'#can_do_action?'
do
context
'when action is :build_download_code'
do
it
{
expect
(
access
.
can_do_action?
(
:build_download_code
)).
to
be_truthy
}
end
context
'when action is not :build_download_code'
do
it
{
expect
(
access
.
can_do_action?
(
:download_code
)).
to
be_falsey
}
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