Commit f1b8d79f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'fix/gpg/case-insensitive' into 'master'

Make GPG validation case insensitive

See merge request gitlab-org/gitlab-ce!14376
parents 1440342f a212391f
...@@ -73,7 +73,7 @@ class GpgKey < ActiveRecord::Base ...@@ -73,7 +73,7 @@ class GpgKey < ActiveRecord::Base
end end
def verified_and_belongs_to_email?(email) def verified_and_belongs_to_email?(email)
emails_with_verified_status.fetch(email, false) emails_with_verified_status.fetch(email.downcase, false)
end end
def update_invalid_gpg_signatures def update_invalid_gpg_signatures
......
---
title: Compare email addresses case insensitively when verifying GPG signatures
merge_request: 14376
author: Tim Bishop
type: fixed
...@@ -138,6 +138,14 @@ describe GpgKey do ...@@ -138,6 +138,14 @@ describe GpgKey do
expect(gpg_key.verified?).to be_truthy expect(gpg_key.verified?).to be_truthy
expect(gpg_key.verified_and_belongs_to_email?('bette.cartwright@example.com')).to be_truthy expect(gpg_key.verified_and_belongs_to_email?('bette.cartwright@example.com')).to be_truthy
end end
it 'returns true if one of the email addresses in the key belongs to the user and case-insensitively matches the provided email' do
user = create :user, email: 'bette.cartwright@example.com'
gpg_key = create :gpg_key, key: GpgHelpers::User2.public_key, user: user
expect(gpg_key.verified?).to be_truthy
expect(gpg_key.verified_and_belongs_to_email?('Bette.Cartwright@example.com')).to be_truthy
end
end end
describe '#revoke' do describe '#revoke' do
......
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