Commit 6b7a9b74 authored by Ash McKenzie's avatar Ash McKenzie

Allow console messages be sent to gitlab-shell

Currently a no-op for CE
parent 74ace2a4
...@@ -87,7 +87,8 @@ module API ...@@ -87,7 +87,8 @@ module API
gl_id: Gitlab::GlId.gl_id(user), gl_id: Gitlab::GlId.gl_id(user),
gl_username: user&.username, gl_username: user&.username,
git_config_options: [], 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 # Custom option for git-receive-pack command
......
...@@ -85,7 +85,7 @@ module Gitlab ...@@ -85,7 +85,7 @@ module Gitlab
check_push_access! check_push_access!
end end
::Gitlab::GitAccessResult::Success.new ::Gitlab::GitAccessResult::Success.new(console_messages: check_for_console_messages(cmd))
end end
def guest_can_download_code? def guest_can_download_code?
...@@ -116,6 +116,10 @@ module Gitlab ...@@ -116,6 +116,10 @@ module Gitlab
nil nil
end end
def check_for_console_messages(cmd)
[]
end
def check_valid_actor! def check_valid_actor!
return unless actor.is_a?(Key) return unless actor.is_a?(Key)
......
...@@ -3,6 +3,11 @@ ...@@ -3,6 +3,11 @@
module Gitlab module Gitlab
module GitAccessResult module GitAccessResult
class Success class Success
attr_reader :console_messages
def initialize(console_messages: [])
@console_messages = console_messages
end
end end
end end
end end
...@@ -498,6 +498,40 @@ describe API::Internal do ...@@ -498,6 +498,40 @@ describe API::Internal do
end end
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 context "blocked user" do
let(:personal_project) { create(:project, namespace: user.namespace) } 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