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
24411b6f
Commit
24411b6f
authored
Sep 05, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify Jira dev integration license check
parent
4b9543bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
31 deletions
+9
-31
ee/app/policies/ee/project_policy.rb
ee/app/policies/ee/project_policy.rb
+0
-10
lib/api/v3/github_repos.rb
lib/api/v3/github_repos.rb
+3
-3
spec/requests/api/v3/github_repos_spec.rb
spec/requests/api/v3/github_repos_spec.rb
+6
-18
No files found.
ee/app/policies/ee/project_policy.rb
View file @
24411b6f
...
...
@@ -12,11 +12,6 @@ module EE
with_scope
:subject
condition
(
:deploy_board_disabled
)
{
!
@subject
.
feature_available?
(
:deploy_board
)
}
with_scope
:subject
condition
(
:jira_dev_panel_integration_disabled
)
do
!
@subject
.
feature_available?
(
:jira_dev_panel_integration
)
end
with_scope
:global
condition
(
:is_development
)
{
Rails
.
env
.
development?
}
...
...
@@ -39,17 +34,12 @@ module EE
prevent
:admin_issue_link
end
rule
{
jira_dev_panel_integration_disabled
}.
policy
do
prevent
:integrate_to_jira_dev_panel
end
rule
{
can?
(
:read_issue
)
}.
enable
:read_issue_link
rule
{
can?
(
:reporter_access
)
}.
policy
do
enable
:admin_board
enable
:read_deploy_board
enable
:admin_issue_link
enable
:integrate_to_jira_dev_panel
end
rule
{
can?
(
:developer_access
)
}.
enable
:admin_board
...
...
lib/api/v3/github_repos.rb
View file @
24411b6f
...
...
@@ -9,9 +9,9 @@ module API
requires
:project
,
type:
String
end
def
find_project_with_access
(
full_path
,
access_level
=
:integrate_to_jira_dev_panel
)
def
find_project_with_access
(
full_path
)
project
=
find_project!
(
full_path
)
authorize!
access_level
,
project
not_found!
unless
project
.
feature_available?
(
:jira_dev_panel_integration
)
project
end
end
...
...
@@ -30,7 +30,7 @@ module API
resource
:users
do
get
':namespace/repos'
do
projects
=
current_user
.
authorized_projects
.
select
{
|
project
|
can?
(
current_user
,
:integrate_to_jira_dev_panel
,
project
)
}
projects
=
current_user
.
authorized_projects
.
select
{
|
project
|
project
.
feature_available?
(
:jira_dev_panel_integration
)
}
projects
=
::
Kaminari
.
paginate_array
(
projects
)
present
paginate
(
projects
),
with:
::
API
::
Entities
::
Github
::
Repository
end
...
...
spec/requests/api/v3/github_repos_spec.rb
View file @
24411b6f
...
...
@@ -100,9 +100,6 @@ describe API::V3::GithubRepos do
end
context
'unauthenticated'
do
before
do
end
it
'returns 401'
do
stub_licensed_features
(
jira_dev_panel_integration:
true
)
...
...
@@ -113,23 +110,14 @@ describe API::V3::GithubRepos do
end
context
'unauthorized'
do
it
'returns 403 when lower access level'
do
unauthorized_user
=
create
(
:user
)
project
.
add_guest
(
unauthorized_user
)
get
v3_api
(
"/repos/
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
/branches"
,
unauthorized_user
)
expect
(
response
).
to
have_http_status
(
403
)
end
it
'returns 403 when not licensed'
do
it
'returns 404 when not licensed'
do
stub_licensed_features
(
jira_dev_panel_integration:
false
)
unauthorized_user
=
create
(
:user
)
project
.
add_reporter
(
unauthorized_user
)
get
v3_api
(
"/repos/
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
/branches"
,
unauthorized_user
)
expect
(
response
).
to
have_http_status
(
40
3
)
expect
(
response
).
to
have_http_status
(
40
4
)
end
end
end
...
...
@@ -178,17 +166,17 @@ describe API::V3::GithubRepos do
end
context
'unauthorized'
do
it
'returns 40
3
when lower access level'
do
it
'returns 40
4
when lower access level'
do
unauthorized_user
=
create
(
:user
)
project
.
add_guest
(
unauthorized_user
)
get
v3_api
(
"/repos/
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
/commits/
#{
commit_id
}
"
,
unauthorized_user
)
expect
(
response
).
to
have_http_status
(
40
3
)
expect
(
response
).
to
have_http_status
(
40
4
)
end
it
'returns 40
3
when not licensed'
do
it
'returns 40
4
when not licensed'
do
stub_licensed_features
(
jira_dev_panel_integration:
false
)
unauthorized_user
=
create
(
:user
)
project
.
add_reporter
(
unauthorized_user
)
...
...
@@ -196,7 +184,7 @@ describe API::V3::GithubRepos do
get
v3_api
(
"/repos/
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
/commits/
#{
commit_id
}
"
,
unauthorized_user
)
expect
(
response
).
to
have_http_status
(
40
3
)
expect
(
response
).
to
have_http_status
(
40
4
)
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