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
8b074b4e
Commit
8b074b4e
authored
Jun 26, 2017
by
Kim "BKC" Carlbäcker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send Gitaly Repository with /api/internal/allowed
- Make single gitaly payload - Add feature-flag specs to verify payload
parent
4eb6b7c1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
7 deletions
+77
-7
internal_helpers.rb
lib/api/helpers/internal_helpers.rb
+27
-4
internal.rb
lib/api/internal.rb
+2
-1
internal_spec.rb
spec/requests/api/internal_spec.rb
+48
-2
No files found.
lib/api/helpers/internal_helpers.rb
View file @
8b074b4e
module
API
module
Helpers
module
InternalHelpers
SSH_GITALY_FEATURES
=
{
'git-receive-pack'
=>
:ssh_receive_pack
,
'git-upload-pack'
=>
:ssh_upload_pack
}.
freeze
def
wiki?
set_project
unless
defined?
(
@wiki
)
@wiki
...
...
@@ -54,14 +59,32 @@ module API
Gitlab
::
GlRepository
.
gl_repository
(
project
,
wiki?
)
end
# Return the repository depending on whether we want the wiki or the
# regular repository
def
repository
if
wiki?
project
.
wiki
.
repository
else
project
.
repository
end
end
# Return the repository full path so that gitlab-shell has it when
# handling ssh commands
def
repository_path
if
wiki?
project
.
wiki
.
repository
.
path_to_repo
else
project
.
repository
.
path_to_repo
repository
.
path_to_repo
end
# Return the Gitaly Address if it is enabled
def
gitaly_payload
(
action
)
feature
=
SSH_GITALY_FEATURES
[
action
]
return
unless
feature
&&
Gitlab
::
GitalyClient
.
feature_enabled?
(
feature
)
{
repository:
repository
.
gitaly_repository
,
address:
Gitlab
::
GitalyClient
.
address
(
project
.
repository_storage
),
token:
Gitlab
::
GitalyClient
.
token
(
project
.
repository_storage
)
}
end
end
end
...
...
lib/api/internal.rb
View file @
8b074b4e
...
...
@@ -47,7 +47,8 @@ module API
{
status:
true
,
gl_repository:
gl_repository
,
repository_path:
repository_path
repository_path:
repository_path
,
gitaly:
gitaly_payload
(
params
[
:action
])
}
end
...
...
spec/requests/api/internal_spec.rb
View file @
8b074b4e
...
...
@@ -220,27 +220,73 @@ describe API::Internal do
end
context
"git pull"
do
it
do
context
"gitaly disabled"
do
it
"has the correct payload"
do
allow
(
Gitlab
::
GitalyClient
).
to
receive
(
:feature_enabled?
).
with
(
:ssh_upload_pack
).
and_return
(
false
)
pull
(
key
,
project
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
"status"
]).
to
be_truthy
expect
(
json_response
[
"repository_path"
]).
to
eq
(
project
.
repository
.
path_to_repo
)
expect
(
json_response
[
"gl_repository"
]).
to
eq
(
"project-
#{
project
.
id
}
"
)
expect
(
json_response
[
"gitaly"
]).
to
be_nil
expect
(
user
).
to
have_an_activity_record
end
end
context
"gitaly enabled"
do
it
"has the correct payload"
do
allow
(
Gitlab
::
GitalyClient
).
to
receive
(
:feature_enabled?
).
with
(
:ssh_upload_pack
).
and_return
(
true
)
pull
(
key
,
project
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
"status"
]).
to
be_truthy
expect
(
json_response
[
"repository_path"
]).
to
eq
(
project
.
repository
.
path_to_repo
)
expect
(
json_response
[
"gl_repository"
]).
to
eq
(
"project-
#{
project
.
id
}
"
)
expect
(
json_response
[
"gitaly"
]).
not_to
be_nil
expect
(
json_response
[
"gitaly"
][
"repository"
]).
not_to
be_nil
expect
(
json_response
[
"gitaly"
][
"repository"
][
"storage_name"
]).
to
eq
(
project
.
repository
.
gitaly_repository
.
storage_name
)
expect
(
json_response
[
"gitaly"
][
"repository"
][
"relative_path"
]).
to
eq
(
project
.
repository
.
gitaly_repository
.
relative_path
)
expect
(
json_response
[
"gitaly"
][
"address"
]).
to
eq
(
Gitlab
::
GitalyClient
.
address
(
project
.
repository_storage
))
expect
(
json_response
[
"gitaly"
][
"token"
]).
to
eq
(
Gitlab
::
GitalyClient
.
token
(
project
.
repository_storage
))
expect
(
user
).
to
have_an_activity_record
end
end
end
context
"git push"
do
it
do
context
"gitaly disabled"
do
it
"has the correct payload"
do
allow
(
Gitlab
::
GitalyClient
).
to
receive
(
:feature_enabled?
).
with
(
:ssh_receive_pack
).
and_return
(
false
)
push
(
key
,
project
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
"status"
]).
to
be_truthy
expect
(
json_response
[
"repository_path"
]).
to
eq
(
project
.
repository
.
path_to_repo
)
expect
(
json_response
[
"gl_repository"
]).
to
eq
(
"project-
#{
project
.
id
}
"
)
expect
(
json_response
[
"gitaly"
]).
to
be_nil
expect
(
user
).
not_to
have_an_activity_record
end
end
context
"gitaly enabled"
do
it
"has the correct payload"
do
allow
(
Gitlab
::
GitalyClient
).
to
receive
(
:feature_enabled?
).
with
(
:ssh_receive_pack
).
and_return
(
true
)
push
(
key
,
project
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
"status"
]).
to
be_truthy
expect
(
json_response
[
"repository_path"
]).
to
eq
(
project
.
repository
.
path_to_repo
)
expect
(
json_response
[
"gl_repository"
]).
to
eq
(
"project-
#{
project
.
id
}
"
)
expect
(
json_response
[
"gitaly"
]).
not_to
be_nil
expect
(
json_response
[
"gitaly"
][
"repository"
]).
not_to
be_nil
expect
(
json_response
[
"gitaly"
][
"repository"
][
"storage_name"
]).
to
eq
(
project
.
repository
.
gitaly_repository
.
storage_name
)
expect
(
json_response
[
"gitaly"
][
"repository"
][
"relative_path"
]).
to
eq
(
project
.
repository
.
gitaly_repository
.
relative_path
)
expect
(
json_response
[
"gitaly"
][
"address"
]).
to
eq
(
Gitlab
::
GitalyClient
.
address
(
project
.
repository_storage
))
expect
(
json_response
[
"gitaly"
][
"token"
]).
to
eq
(
Gitlab
::
GitalyClient
.
token
(
project
.
repository_storage
))
expect
(
user
).
not_to
have_an_activity_record
end
end
context
'project as /namespace/project'
do
it
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