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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
2190704c
Commit
2190704c
authored
Jan 15, 2019
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: Support username with dots
parent
f821a53b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
5 deletions
+14
-5
lib/api/projects.rb
lib/api/projects.rb
+1
-1
lib/api/users.rb
lib/api/users.rb
+1
-1
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+11
-2
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+1
-1
No files found.
lib/api/projects.rb
View file @
2190704c
...
@@ -128,7 +128,7 @@ module API
...
@@ -128,7 +128,7 @@ module API
end
end
end
end
resource
:users
,
requirements:
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
do
resource
:users
,
requirements:
{
user_id:
API
::
NO_SLASH_URL_PART_REGEX
}
do
desc
'Get a user projects'
do
desc
'Get a user projects'
do
success
Entities
::
BasicProjectDetails
success
Entities
::
BasicProjectDetails
end
end
...
...
lib/api/users.rb
View file @
2190704c
...
@@ -135,7 +135,7 @@ module API
...
@@ -135,7 +135,7 @@ module API
params
do
params
do
requires
:id_or_username
,
type:
String
,
desc:
'The ID or username of the user'
requires
:id_or_username
,
type:
String
,
desc:
'The ID or username of the user'
end
end
get
":id_or_username/status"
do
get
":id_or_username/status"
,
requirements:
{
id_or_username:
API
::
NO_SLASH_URL_PART_REGEX
}
do
user
=
find_user
(
params
[
:id_or_username
])
user
=
find_user
(
params
[
:id_or_username
])
not_found!
(
'User'
)
unless
user
&&
can?
(
current_user
,
:read_user
,
user
)
not_found!
(
'User'
)
unless
user
&&
can?
(
current_user
,
:read_user
,
user
)
...
...
spec/requests/api/projects_spec.rb
View file @
2190704c
...
@@ -21,7 +21,7 @@ describe API::Projects do
...
@@ -21,7 +21,7 @@ describe API::Projects do
let
(
:project
)
{
create
(
:project
,
:repository
,
namespace:
user
.
namespace
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
namespace:
user
.
namespace
)
}
let
(
:project2
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let
(
:project2
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let
(
:project_member
)
{
create
(
:project_member
,
:developer
,
user:
user3
,
project:
project
)
}
let
(
:project_member
)
{
create
(
:project_member
,
:developer
,
user:
user3
,
project:
project
)
}
let
(
:user4
)
{
create
(
:user
)
}
let
(
:user4
)
{
create
(
:user
,
username:
'user.with.dot'
)
}
let
(
:project3
)
do
let
(
:project3
)
do
create
(
:project
,
create
(
:project
,
:private
,
:private
,
...
@@ -724,7 +724,7 @@ describe API::Projects do
...
@@ -724,7 +724,7 @@ describe API::Projects do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 User Not Found'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 User Not Found'
)
end
end
it
'returns projects filtered by user'
do
it
'returns projects filtered by user
id
'
do
get
api
(
"/users/
#{
user4
.
id
}
/projects/"
,
user
)
get
api
(
"/users/
#{
user4
.
id
}
/projects/"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
...
@@ -733,6 +733,15 @@ describe API::Projects do
...
@@ -733,6 +733,15 @@ describe API::Projects do
expect
(
json_response
.
map
{
|
project
|
project
[
'id'
]
}).
to
contain_exactly
(
public_project
.
id
)
expect
(
json_response
.
map
{
|
project
|
project
[
'id'
]
}).
to
contain_exactly
(
public_project
.
id
)
end
end
it
'returns projects filtered by username'
do
get
api
(
"/users/
#{
user4
.
username
}
/projects/"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
map
{
|
project
|
project
[
'id'
]
}).
to
contain_exactly
(
public_project
.
id
)
end
it
'returns projects filtered by minimal access level'
do
it
'returns projects filtered by minimal access level'
do
private_project1
=
create
(
:project
,
:private
,
name:
'private_project1'
,
creator_id:
user4
.
id
,
namespace:
user4
.
namespace
)
private_project1
=
create
(
:project
,
:private
,
name:
'private_project1'
,
creator_id:
user4
.
id
,
namespace:
user4
.
namespace
)
private_project2
=
create
(
:project
,
:private
,
name:
'private_project2'
,
creator_id:
user4
.
id
,
namespace:
user4
.
namespace
)
private_project2
=
create
(
:project
,
:private
,
name:
'private_project2'
,
creator_id:
user4
.
id
,
namespace:
user4
.
namespace
)
...
...
spec/requests/api/users_spec.rb
View file @
2190704c
require
'spec_helper'
require
'spec_helper'
describe
API
::
Users
do
describe
API
::
Users
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
,
username:
'user.with.dot'
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:key
)
{
create
(
:key
,
user:
user
)
}
let
(
:key
)
{
create
(
:key
,
user:
user
)
}
let
(
:gpg_key
)
{
create
(
:gpg_key
,
user:
user
)
}
let
(
:gpg_key
)
{
create
(
:gpg_key
,
user:
user
)
}
...
...
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