Commit aa82832f authored by Ash McKenzie's avatar Ash McKenzie Committed by Igor Drozdov

More consistent console messages (Ruby)

parent 1bade9e1
...@@ -8,6 +8,7 @@ describe 'Custom bin/gitlab-shell git-receive-pack' do ...@@ -8,6 +8,7 @@ describe 'Custom bin/gitlab-shell git-receive-pack' do
include_context 'gitlab shell' include_context 'gitlab shell'
let(:env) { {'SSH_CONNECTION' => 'fake', 'SSH_ORIGINAL_COMMAND' => 'git-receive-pack group/repo' } } let(:env) { {'SSH_CONNECTION' => 'fake', 'SSH_ORIGINAL_COMMAND' => 'git-receive-pack group/repo' } }
let(:divider) { "remote: ========================================================================\n" }
before(:context) do before(:context) do
write_config("gitlab_url" => "http+unix://#{CGI.escape(tmp_socket_path)}") write_config("gitlab_url" => "http+unix://#{CGI.escape(tmp_socket_path)}")
...@@ -65,21 +66,24 @@ describe 'Custom bin/gitlab-shell git-receive-pack' do ...@@ -65,21 +66,24 @@ describe 'Custom bin/gitlab-shell git-receive-pack' do
end end
describe 'dialog for performing a custom action' do describe 'dialog for performing a custom action' do
let(:inaccessible_error) { "Internal API error (403)\n" }
context 'when API calls perform successfully' do context 'when API calls perform successfully' do
let(:remote_blank_line) { "remote: \n" }
def verify_successful_call!(cmd) def verify_successful_call!(cmd)
Open3.popen3(env, cmd) do |stdin, stdout, stderr| Open3.popen3(env, cmd) do |stdin, stdout, stderr|
expect(stderr.gets).to eq("> GitLab: console\n") expect(stderr.gets).to eq(remote_blank_line)
expect(stderr.gets).to eq("> GitLab: message\n") expect(stderr.gets).to eq("remote: console\n")
expect(stderr.gets).to eq("remote: message\n")
expect(stderr.gets).to eq(remote_blank_line)
expect(stderr.gets).to eq("> GitLab: info_message\n") expect(stderr.gets).to eq(remote_blank_line)
expect(stderr.gets).to eq("> GitLab: another_message\n") expect(stderr.gets).to eq("remote: info_message\n")
expect(stdout.gets(6)).to eq("custom") expect(stderr.gets).to eq("remote: another_message\n")
expect(stderr.gets).to eq(remote_blank_line)
stdin.puts("input") stdin.puts("input")
stdin.close stdin.close
expect(stdout.gets(6)).to eq("custom")
expect(stdout.flush.read).to eq("input\n") expect(stdout.flush.read).to eq("input\n")
end end
end end
...@@ -106,7 +110,13 @@ describe 'Custom bin/gitlab-shell git-receive-pack' do ...@@ -106,7 +110,13 @@ describe 'Custom bin/gitlab-shell git-receive-pack' do
it 'custom action is not performed' do it 'custom action is not performed' do
Open3.popen2e(env, cmd) do |stdin, stdout| Open3.popen2e(env, cmd) do |stdin, stdout|
expect(stdout.gets).to eq(inaccessible_error) expect(stdout.gets).to eq("remote: \n")
expect(stdout.gets).to eq(divider)
expect(stdout.gets).to eq("remote: \n")
expect(stdout.gets).to eq("remote: Internal API error (403)\n")
expect(stdout.gets).to eq("remote: \n")
expect(stdout.gets).to eq(divider)
expect(stdout.gets).to eq("remote: \n")
end end
end end
end end
......
...@@ -117,9 +117,10 @@ describe 'bin/gitlab-shell git-lfs-authentication' do ...@@ -117,9 +117,10 @@ describe 'bin/gitlab-shell git-lfs-authentication' do
let(:env) { {'SSH_CONNECTION' => 'fake', 'SSH_ORIGINAL_COMMAND' => 'git-lfs-authenticate project/repo unknown' } } let(:env) { {'SSH_CONNECTION' => 'fake', 'SSH_ORIGINAL_COMMAND' => 'git-lfs-authenticate project/repo unknown' } }
it 'the command is disallowed' do it 'the command is disallowed' do
divider = "remote: \nremote: ========================================================================\nremote: \n"
_, stderr, status = Open3.capture3(env, cmd) _, stderr, status = Open3.capture3(env, cmd)
expect(stderr).to eq("> GitLab: Disallowed command\n") expect(stderr).to eq("#{divider}remote: Disallowed command\n#{divider}")
expect(status).not_to be_success expect(status).not_to be_success
end end
end end
......
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