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
de33a5bd
Commit
de33a5bd
authored
May 18, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent errors from non-functional notify_post_receive endpoint
parent
9a10a6bf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
89 deletions
+91
-89
GITLAB_SHELL_VERSION
GITLAB_SHELL_VERSION
+1
-1
lib/api/internal.rb
lib/api/internal.rb
+9
-8
spec/requests/api/internal_spec.rb
spec/requests/api/internal_spec.rb
+81
-80
No files found.
GITLAB_SHELL_VERSION
View file @
de33a5bd
5.0.
3
5.0.
4
lib/api/internal.rb
View file @
de33a5bd
...
@@ -136,14 +136,15 @@ module API
...
@@ -136,14 +136,15 @@ module API
post
"/notify_post_receive"
do
post
"/notify_post_receive"
do
status
200
status
200
return
unless
Gitlab
::
GitalyClient
.
enabled?
# TODO: Re-enable when Gitaly is processing the post-receive notification
# return unless Gitlab::GitalyClient.enabled?
begin
#
repository
=
wiki?
?
project
.
wiki
.
repository
:
project
.
repository
# begin
Gitlab
::
GitalyClient
::
Notifications
.
new
(
repository
.
raw_repository
).
post_receive
# repository = wiki? ? project.wiki.repository : project.repository
rescue
GRPC
::
Unavailable
=>
e
# Gitlab::GitalyClient::Notifications.new(repository.raw_repository).post_receive
render_api_error!
(
e
,
500
)
# rescue GRPC::Unavailable => e
end
# render_api_error!(e, 500)
# end
end
end
end
end
end
end
...
...
spec/requests/api/internal_spec.rb
View file @
de33a5bd
...
@@ -466,86 +466,87 @@ describe API::Internal do
...
@@ -466,86 +466,87 @@ describe API::Internal do
end
end
end
end
describe
'POST /notify_post_receive'
do
# TODO: Uncomment when the end-point is reenabled
let
(
:valid_params
)
do
# describe 'POST /notify_post_receive' do
{
project:
project
.
repository
.
path
,
secret_token:
secret_token
}
# let(:valid_params) do
end
# { project: project.repository.path, secret_token: secret_token }
# end
let
(
:valid_wiki_params
)
do
#
{
project:
project
.
wiki
.
repository
.
path
,
secret_token:
secret_token
}
# let(:valid_wiki_params) do
end
# { project: project.wiki.repository.path, secret_token: secret_token }
# end
before
do
#
allow
(
Gitlab
.
config
.
gitaly
).
to
receive
(
:enabled
).
and_return
(
true
)
# before do
end
# allow(Gitlab.config.gitaly).to receive(:enabled).and_return(true)
# end
it
"calls the Gitaly client with the project's repository"
do
#
expect
(
Gitlab
::
GitalyClient
::
Notifications
).
# it "calls the Gitaly client with the project's repository" do
to
receive
(
:new
).
with
(
gitlab_git_repository_with
(
path:
project
.
repository
.
path
)).
# expect(Gitlab::GitalyClient::Notifications).
and_call_original
# to receive(:new).with(gitlab_git_repository_with(path: project.repository.path)).
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Notifications
).
# and_call_original
to
receive
(
:post_receive
)
# expect_any_instance_of(Gitlab::GitalyClient::Notifications).
# to receive(:post_receive)
post
api
(
"/internal/notify_post_receive"
),
valid_params
#
# post api("/internal/notify_post_receive"), valid_params
expect
(
response
).
to
have_http_status
(
200
)
#
end
# expect(response).to have_http_status(200)
# end
it
"calls the Gitaly client with the wiki's repository if it's a wiki"
do
#
expect
(
Gitlab
::
GitalyClient
::
Notifications
).
# it "calls the Gitaly client with the wiki's repository if it's a wiki" do
to
receive
(
:new
).
with
(
gitlab_git_repository_with
(
path:
project
.
wiki
.
repository
.
path
)).
# expect(Gitlab::GitalyClient::Notifications).
and_call_original
# to receive(:new).with(gitlab_git_repository_with(path: project.wiki.repository.path)).
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Notifications
).
# and_call_original
to
receive
(
:post_receive
)
# expect_any_instance_of(Gitlab::GitalyClient::Notifications).
# to receive(:post_receive)
post
api
(
"/internal/notify_post_receive"
),
valid_wiki_params
#
# post api("/internal/notify_post_receive"), valid_wiki_params
expect
(
response
).
to
have_http_status
(
200
)
#
end
# expect(response).to have_http_status(200)
# end
it
"returns 500 if the gitaly call fails"
do
#
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Notifications
).
# it "returns 500 if the gitaly call fails" do
to
receive
(
:post_receive
).
and_raise
(
GRPC
::
Unavailable
)
# expect_any_instance_of(Gitlab::GitalyClient::Notifications).
# to receive(:post_receive).and_raise(GRPC::Unavailable)
post
api
(
"/internal/notify_post_receive"
),
valid_params
#
# post api("/internal/notify_post_receive"), valid_params
expect
(
response
).
to
have_http_status
(
500
)
#
end
# expect(response).to have_http_status(500)
# end
context
'with a gl_repository parameter'
do
#
let
(
:valid_params
)
do
# context 'with a gl_repository parameter' do
{
gl_repository:
"project-
#{
project
.
id
}
"
,
secret_token:
secret_token
}
# let(:valid_params) do
end
# { gl_repository: "project-#{project.id}", secret_token: secret_token }
# end
let
(
:valid_wiki_params
)
do
#
{
gl_repository:
"wiki-
#{
project
.
id
}
"
,
secret_token:
secret_token
}
# let(:valid_wiki_params) do
end
# { gl_repository: "wiki-#{project.id}", secret_token: secret_token }
# end
it
"calls the Gitaly client with the project's repository"
do
#
expect
(
Gitlab
::
GitalyClient
::
Notifications
).
# it "calls the Gitaly client with the project's repository" do
to
receive
(
:new
).
with
(
gitlab_git_repository_with
(
path:
project
.
repository
.
path
)).
# expect(Gitlab::GitalyClient::Notifications).
and_call_original
# to receive(:new).with(gitlab_git_repository_with(path: project.repository.path)).
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Notifications
).
# and_call_original
to
receive
(
:post_receive
)
# expect_any_instance_of(Gitlab::GitalyClient::Notifications).
# to receive(:post_receive)
post
api
(
"/internal/notify_post_receive"
),
valid_params
#
# post api("/internal/notify_post_receive"), valid_params
expect
(
response
).
to
have_http_status
(
200
)
#
end
# expect(response).to have_http_status(200)
# end
it
"calls the Gitaly client with the wiki's repository if it's a wiki"
do
#
expect
(
Gitlab
::
GitalyClient
::
Notifications
).
# it "calls the Gitaly client with the wiki's repository if it's a wiki" do
to
receive
(
:new
).
with
(
gitlab_git_repository_with
(
path:
project
.
wiki
.
repository
.
path
)).
# expect(Gitlab::GitalyClient::Notifications).
and_call_original
# to receive(:new).with(gitlab_git_repository_with(path: project.wiki.repository.path)).
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Notifications
).
# and_call_original
to
receive
(
:post_receive
)
# expect_any_instance_of(Gitlab::GitalyClient::Notifications).
# to receive(:post_receive)
post
api
(
"/internal/notify_post_receive"
),
valid_wiki_params
#
# post api("/internal/notify_post_receive"), valid_wiki_params
expect
(
response
).
to
have_http_status
(
200
)
#
end
# expect(response).to have_http_status(200)
end
# end
end
# end
# end
def
project_with_repo_path
(
path
)
def
project_with_repo_path
(
path
)
double
().
tap
do
|
fake_project
|
double
().
tap
do
|
fake_project
|
...
...
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