Merge branch 'sh-fix-ssh-keys-with-spaces' into 'master'
Handle SSH keys that have multiple spaces between each marker See merge request !10466
This commit is contained in:
commit
d4d95ad32f
3 changed files with 14 additions and 1 deletions
4
changelogs/unreleased/sh-fix-ssh-keys-with-spaces.yml
Normal file
4
changelogs/unreleased/sh-fix-ssh-keys-with-spaces.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Handle SSH keys that have multiple spaces between each marker
|
||||
merge_request:
|
||||
author:
|
|
@ -35,7 +35,7 @@ module Gitlab
|
|||
end
|
||||
|
||||
def strip_key(key)
|
||||
key.split(/ /)[0, 2].join(' ')
|
||||
key.split(/[ ]+/)[0, 2].join(' ')
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -69,6 +69,15 @@ describe Gitlab::Shell, lib: true do
|
|||
expect(io).to have_received(:puts).with("key-42\tssh-rsa foo")
|
||||
end
|
||||
|
||||
it 'handles multiple spaces in the key' do
|
||||
io = spy(:io)
|
||||
adder = described_class.new(io)
|
||||
|
||||
adder.add_key('key-42', "ssh-rsa foo")
|
||||
|
||||
expect(io).to have_received(:puts).with("key-42\tssh-rsa foo")
|
||||
end
|
||||
|
||||
it 'raises an exception if the key contains a tab' do
|
||||
expect do
|
||||
described_class.new(StringIO.new).add_key('key-42', "ssh-rsa\tfoobar")
|
||||
|
|
Loading…
Reference in a new issue