downcase gpg key's emails
this is necessary for email comparisons
This commit is contained in:
parent
c5e0bd56fb
commit
2a89037b63
2 changed files with 16 additions and 1 deletions
|
@ -39,7 +39,7 @@ module Gitlab
|
|||
fingerprints = CurrentKeyChain.fingerprints_from_key(key)
|
||||
|
||||
GPGME::Key.find(:public, fingerprints).flat_map do |raw_key|
|
||||
raw_key.uids.map { |uid| { name: uid.name, email: uid.email } }
|
||||
raw_key.uids.map { |uid| { name: uid.name, email: uid.email.downcase } }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,6 +42,21 @@ describe Gitlab::Gpg do
|
|||
described_class.user_infos_from_key('bogus')
|
||||
).to eq []
|
||||
end
|
||||
|
||||
it 'downcases the email' do
|
||||
public_key = double(:key)
|
||||
fingerprints = double(:fingerprints)
|
||||
uid = double(:uid, name: 'Nannie Bernhard', email: 'NANNIE.BERNHARD@EXAMPLE.COM')
|
||||
raw_key = double(:raw_key, uids: [uid])
|
||||
allow(Gitlab::Gpg::CurrentKeyChain).to receive(:fingerprints_from_key).with(public_key).and_return(fingerprints)
|
||||
allow(GPGME::Key).to receive(:find).with(:public, anything).and_return([raw_key])
|
||||
|
||||
user_infos = described_class.user_infos_from_key(public_key)
|
||||
expect(user_infos).to eq([{
|
||||
name: 'Nannie Bernhard',
|
||||
email: 'nannie.bernhard@example.com'
|
||||
}])
|
||||
end
|
||||
end
|
||||
|
||||
describe '.current_home_dir' do
|
||||
|
|
Loading…
Reference in a new issue