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
0f813189
Commit
0f813189
authored
Jul 02, 2018
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow all but "/" chars for groups and projects paths on Jira dev panel integration
parent
d555a8a4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
8 deletions
+74
-8
ee/changelogs/unreleased/5868-osw-allow-all-char-but-slashes-jira-integration.yml
.../5868-osw-allow-all-char-but-slashes-jira-integration.yml
+5
-0
ee/lib/api/v3/github.rb
ee/lib/api/v3/github.rb
+7
-4
ee/spec/requests/api/v3/github_spec.rb
ee/spec/requests/api/v3/github_spec.rb
+62
-4
No files found.
ee/changelogs/unreleased/5868-osw-allow-all-char-but-slashes-jira-integration.yml
0 → 100644
View file @
0f813189
---
title
:
Allow all but "/" chars for groups and projects paths on Jira dev panel integration
merge_request
:
author
:
type
:
fixed
ee/lib/api/v3/github.rb
View file @
0f813189
...
...
@@ -7,6 +7,9 @@ module API
module
V3
class
Github
<
Grape
::
API
JIRA_DEV_PANEL_FEATURE
=
:jira_dev_panel_integration
.
freeze
NO_SLASH_URL_PART_REGEX
=
%r{[^/]+}
NAMESPACE_ENDPOINT_REQUIREMENTS
=
{
namespace:
NO_SLASH_URL_PART_REGEX
}.
freeze
PROJECT_ENDPOINT_REQUIREMENTS
=
NAMESPACE_ENDPOINT_REQUIREMENTS
.
merge
(
project:
NO_SLASH_URL_PART_REGEX
).
freeze
include
PaginationParams
...
...
@@ -60,7 +63,7 @@ module API
end
resource
:orgs
do
get
':namespace/repos'
do
get
':namespace/repos'
,
requirements:
NAMESPACE_ENDPOINT_REQUIREMENTS
do
present
[]
end
end
...
...
@@ -75,7 +78,7 @@ module API
params
do
use
:pagination
end
get
':namespace/repos'
do
get
':namespace/repos'
,
requirements:
NAMESPACE_ENDPOINT_REQUIREMENTS
do
projects
=
current_user
.
authorized_projects
.
select
{
|
project
|
licensed_project?
(
project
)
}
projects
=
::
Kaminari
.
paginate_array
(
projects
)
present
paginate
(
projects
),
with:
::
API
::
Github
::
Entities
::
Repository
...
...
@@ -120,7 +123,7 @@ module API
use
:project_full_path
use
:pagination
end
get
':namespace/:project/branches'
do
get
':namespace/:project/branches'
,
requirements:
PROJECT_ENDPOINT_REQUIREMENTS
do
namespace
=
params
[
:namespace
]
project
=
params
[
:project
]
user_project
=
find_project_with_access
(
"
#{
namespace
}
/
#{
project
}
"
)
...
...
@@ -133,7 +136,7 @@ module API
params
do
use
:project_full_path
end
get
':namespace/:project/commits/:sha'
do
get
':namespace/:project/commits/:sha'
,
requirements:
PROJECT_ENDPOINT_REQUIREMENTS
do
namespace
=
params
[
:namespace
]
project
=
params
[
:project
]
user_project
=
find_project_with_access
(
"
#{
namespace
}
/
#{
project
}
"
)
...
...
ee/spec/requests/api/v3/github_spec.rb
View file @
0f813189
...
...
@@ -18,6 +18,14 @@ describe API::V3::Github do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
).
to
eq
([])
end
it
'returns 200 when namespace path include a dot'
do
group
=
create
(
:group
,
path:
'foo.bar'
)
get
v3_api
(
"/orgs/
#{
group
.
path
}
/repos"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
end
describe
'GET /user/repos'
do
...
...
@@ -116,11 +124,11 @@ describe API::V3::Github do
before
do
stub_licensed_features
(
jira_dev_panel_integration:
true
)
group
.
add_master
(
user
)
get
v3_api
(
'/users/foo/repos'
,
user
)
end
it
'returns an array of projects with github format'
do
get
v3_api
(
'/users/foo/repos'
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
(
Array
)
...
...
@@ -129,7 +137,17 @@ describe API::V3::Github do
expect
(
response
).
to
match_response_schema
(
'entities/github/repositories'
,
dir:
'ee'
)
end
it
'returns 200 when namespace path include a dot'
do
group
=
create
(
:group
,
path:
'foo.bar'
)
get
v3_api
(
"/users/
#{
group
.
path
}
/repos"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
it
'returns valid project path as name'
do
get
v3_api
(
'/users/foo/repos'
,
user
)
project_names
=
json_response
.
map
{
|
r
|
r
[
'name'
]
}
expect
(
project_names
).
to
include
(
project
.
path
,
group_project
.
path
)
...
...
@@ -165,9 +183,11 @@ describe API::V3::Github do
describe
'GET /repos/:namespace/:project/branches'
do
context
'authenticated'
do
it
'returns an array of project branches with github format'
do
before
do
stub_licensed_features
(
jira_dev_panel_integration:
true
)
end
it
'returns an array of project branches with github format'
do
get
v3_api
(
"/repos/
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
/branches"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
...
...
@@ -176,6 +196,24 @@ describe API::V3::Github do
expect
(
response
).
to
match_response_schema
(
'entities/github/branches'
,
dir:
'ee'
)
end
it
'returns 200 when project path include a dot'
do
project
.
update!
(
path:
'foo.bar'
)
get
v3_api
(
"/repos/
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
/branches"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
it
'returns 200 when namespace path include a dot'
do
group
=
create
(
:group
,
path:
'foo.bar'
)
project
=
create
(
:project
,
:repository
,
group:
group
)
project
.
add_reporter
(
user
)
get
v3_api
(
"/repos/
#{
group
.
path
}
/
#{
project
.
path
}
/branches"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
end
context
'unauthenticated'
do
...
...
@@ -206,14 +244,34 @@ describe API::V3::Github do
let
(
:commit_id
)
{
commit
.
id
}
context
'authenticated'
do
it
'returns commit with github format'
do
before
do
stub_licensed_features
(
jira_dev_panel_integration:
true
)
end
it
'returns commit with github format'
do
get
v3_api
(
"/repos/
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
/commits/
#{
commit_id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
match_response_schema
(
'entities/github/commit'
,
dir:
'ee'
)
end
it
'returns 200 when project path include a dot'
do
project
.
update!
(
path:
'foo.bar'
)
get
v3_api
(
"/repos/
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
/commits/
#{
commit_id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
it
'returns 200 when namespace path include a dot'
do
group
=
create
(
:group
,
path:
'foo.bar'
)
project
=
create
(
:project
,
:repository
,
group:
group
)
project
.
add_reporter
(
user
)
get
v3_api
(
"/repos/
#{
group
.
path
}
/
#{
project
.
path
}
/commits/
#{
commit_id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
end
context
'unauthenticated'
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