diff options
author | Stan Hu <stanhu@gmail.com> | 2017-04-04 23:09:04 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-04-04 23:12:08 -0700 |
commit | 54849afc6c94fbc16b0b320741cadafb272deb9d (patch) | |
tree | 53a5f5994229f87ddbfab7645ef81b203431dd38 /spec | |
parent | ced322c5f6de61c30794140a08fa45b612474850 (diff) | |
download | gitlab-ce-54849afc6c94fbc16b0b320741cadafb272deb9d.tar.gz |
Handle SSH keys that have multiple spaces between each marker
Notice what happens when a user adds a key with a space in between:
```
irb(main):004:0> 'ssh-rsa foobar'.split(/ /)
=> ["ssh-rsa", "", "foobar"]
```
This would cause gitlab-shell to receive a blank argument for the actual
key, leading to users unable to login.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/backend/shell_spec.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/lib/gitlab/backend/shell_spec.rb b/spec/lib/gitlab/backend/shell_spec.rb index 4b08a02ec73..6675d26734e 100644 --- a/spec/lib/gitlab/backend/shell_spec.rb +++ b/spec/lib/gitlab/backend/shell_spec.rb @@ -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") |