Commit b54228ad authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch...

Merge branch '9217-warn-on-git-fetch-over-ssh-if-the-secondary-is-lagging-the-primary' into 'master'

Display console messages, if available

See merge request gitlab-org/gitlab-ce!26692
parents 3ccb4d95 6b7a9b74
......@@ -87,7 +87,8 @@ module API
gl_id: Gitlab::GlId.gl_id(user),
gl_username: user&.username,
git_config_options: [],
gitaly: gitaly_payload(params[:action])
gitaly: gitaly_payload(params[:action]),
gl_console_messages: check_result.console_messages
}
# Custom option for git-receive-pack command
......
......@@ -85,7 +85,7 @@ module Gitlab
check_push_access!
end
::Gitlab::GitAccessResult::Success.new
::Gitlab::GitAccessResult::Success.new(console_messages: check_for_console_messages(cmd))
end
def guest_can_download_code?
......@@ -116,6 +116,10 @@ module Gitlab
nil
end
def check_for_console_messages(cmd)
[]
end
def check_valid_actor!
return unless actor.is_a?(Key)
......
......@@ -3,6 +3,11 @@
module Gitlab
module GitAccessResult
class Success
attr_reader :console_messages
def initialize(console_messages: [])
@console_messages = console_messages
end
end
end
end
......@@ -498,6 +498,40 @@ describe API::Internal do
end
end
context "console message" do
before do
project.add_developer(user)
end
context "git pull" do
context "with no console message" do
it "has the correct payload" do
pull(key, project)
expect(response).to have_gitlab_http_status(200)
expect(json_response['gl_console_messages']).to eq([])
end
end
context "with a console message" do
let(:console_messages) { ['message for the console'] }
it "has the correct payload" do
expect_next_instance_of(Gitlab::GitAccess) do |access|
expect(access).to receive(:check_for_console_messages)
.with('git-upload-pack')
.and_return(console_messages)
end
pull(key, project)
expect(response).to have_gitlab_http_status(200)
expect(json_response['gl_console_messages']).to eq(console_messages)
end
end
end
end
context "blocked user" do
let(:personal_project) { create(:project, namespace: user.namespace) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment