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
Jérome Perrin
gitlab-ce
Commits
ff3eeffa
Commit
ff3eeffa
authored
Aug 31, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement /internal/pre-receive for shell operations
parent
8323e55b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
lib/api/internal.rb
lib/api/internal.rb
+8
-0
spec/requests/api/internal_spec.rb
spec/requests/api/internal_spec.rb
+18
-2
No files found.
lib/api/internal.rb
View file @
ff3eeffa
...
@@ -143,6 +143,14 @@ module API
...
@@ -143,6 +143,14 @@ module API
{
success:
true
,
recovery_codes:
codes
}
{
success:
true
,
recovery_codes:
codes
}
end
end
post
'/pre_receive'
do
status
200
reference_counter_increased
=
Gitlab
::
ReferenceCounter
.
new
(
params
[
:gl_repository
]).
increase
{
reference_counter_increased:
reference_counter_increased
}
end
post
"/notify_post_receive"
do
post
"/notify_post_receive"
do
status
200
status
200
...
...
spec/requests/api/internal_spec.rb
View file @
ff3eeffa
...
@@ -5,6 +5,8 @@ describe API::Internal do
...
@@ -5,6 +5,8 @@ describe API::Internal do
let
(
:key
)
{
create
(
:key
,
user:
user
)
}
let
(
:key
)
{
create
(
:key
,
user:
user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:secret_token
)
{
Gitlab
::
Shell
.
secret_token
}
let
(
:secret_token
)
{
Gitlab
::
Shell
.
secret_token
}
let
(
:gl_repository
)
{
"project-
#{
project
.
id
}
"
}
let
(
:reference_counter
)
{
double
(
'ReferenceCounter'
)
}
describe
"GET /internal/check"
do
describe
"GET /internal/check"
do
it
do
it
do
...
@@ -672,9 +674,7 @@ describe API::Internal do
...
@@ -672,9 +674,7 @@ describe API::Internal do
# end
# end
describe
'POST /internal/post_receive'
do
describe
'POST /internal/post_receive'
do
let
(
:gl_repository
)
{
"project-
#{
project
.
id
}
"
}
let
(
:identifier
)
{
'key-123'
}
let
(
:identifier
)
{
'key-123'
}
let
(
:reference_counter
)
{
double
(
'ReferenceCounter'
)
}
let
(
:valid_params
)
do
let
(
:valid_params
)
do
{
{
...
@@ -760,6 +760,22 @@ describe API::Internal do
...
@@ -760,6 +760,22 @@ describe API::Internal do
end
end
end
end
describe
'POST /internal/pre_receive'
do
let
(
:valid_params
)
do
{
gl_repository:
gl_repository
,
secret_token:
secret_token
}
end
it
'decreases the reference counter and returns the result'
do
expect
(
Gitlab
::
ReferenceCounter
).
to
receive
(
:new
).
with
(
gl_repository
)
.
and_return
(
reference_counter
)
expect
(
reference_counter
).
to
receive
(
:increase
).
and_return
(
true
)
post
api
(
"/internal/pre_receive"
),
valid_params
expect
(
json_response
[
'reference_counter_increased'
]).
to
be
(
true
)
end
end
def
project_with_repo_path
(
path
)
def
project_with_repo_path
(
path
)
double
().
tap
do
|
fake_project
|
double
().
tap
do
|
fake_project
|
allow
(
fake_project
).
to
receive_message_chain
(
'repository.path_to_repo'
=>
path
)
allow
(
fake_project
).
to
receive_message_chain
(
'repository.path_to_repo'
=>
path
)
...
...
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