Merge branch 'sh-handle-orphaned-deploy-keys' into 'master'
Gracefully handle orphaned write deploy keys in /internal/post_receive Closes #41466 See merge request gitlab-org/gitlab-ce!16127
This commit is contained in:
commit
228f42b58b
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Gracefully handle orphaned write deploy keys in /internal/post_receive
|
||||
merge_request:
|
||||
author:
|
||||
type: fixed
|
|
@ -190,9 +190,12 @@ module API
|
|||
|
||||
project = Gitlab::GlRepository.parse(params[:gl_repository]).first
|
||||
user = identify(params[:identifier])
|
||||
redirect_message = Gitlab::Checks::ProjectMoved.fetch_redirect_message(user.id, project.id)
|
||||
if redirect_message
|
||||
output[:redirected_message] = redirect_message
|
||||
|
||||
# A user is not guaranteed to be returned; an orphaned write deploy
|
||||
# key could be used
|
||||
if user
|
||||
redirect_message = Gitlab::Checks::ProjectMoved.fetch_redirect_message(user.id, project.id)
|
||||
output[:redirected_message] = redirect_message if redirect_message
|
||||
end
|
||||
|
||||
output
|
||||
|
|
|
@ -784,6 +784,16 @@ describe API::Internal do
|
|||
expect(json_response["redirected_message"]).to eq(project_moved.redirect_message)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an orphaned write deploy key' do
|
||||
it 'does not try to notify that project moved' do
|
||||
allow_any_instance_of(Gitlab::Identifier).to receive(:identify).and_return(nil)
|
||||
|
||||
post api("/internal/post_receive"), valid_params
|
||||
|
||||
expect(response).to have_gitlab_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST /internal/pre_receive' do
|
||||
|
|
Loading…
Reference in New Issue