Commit f0b4fe2f authored by Douwe Maan's avatar Douwe Maan

Merge branch 'fix-ssh-key-mutation' into 'master'

Ensure key fingerprints are generated correctly when modified

See merge request gitlab-org/gitlab-ce!14663
parents c958c201 eaa1ce4f
...@@ -34,6 +34,7 @@ class Key < ActiveRecord::Base ...@@ -34,6 +34,7 @@ class Key < ActiveRecord::Base
value&.delete!("\n\r") value&.delete!("\n\r")
value.strip! unless value.blank? value.strip! unless value.blank?
write_attribute(:key, value) write_attribute(:key, value)
@public_key = nil
end end
def publishable_key def publishable_key
......
...@@ -155,5 +155,15 @@ describe Key, :mailer do ...@@ -155,5 +155,15 @@ describe Key, :mailer do
it 'strips white spaces' do it 'strips white spaces' do
expect(described_class.new(key: " #{valid_key} ").key).to eq(valid_key) expect(described_class.new(key: " #{valid_key} ").key).to eq(valid_key)
end end
it 'invalidates the public_key attribute' do
key = build(:key)
original = key.public_key
key.key = valid_key
expect(original.key_text).not_to be_nil
expect(key.public_key.key_text).to eq(valid_key)
end
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