Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Reigel <mail@koffeinfrei.org>2017-02-24 23:28:26 +0300
committerAlexis Reigel <mail@koffeinfrei.org>2017-07-27 16:40:41 +0300
commitf0fe1b9d4397e6c1c6aa2da6e371e234db774fe2 (patch)
treed7d35a328b4aa6fe0535a57554e0996d1deb6c1b /spec/models/gpg_key_spec.rb
parent0668521b2b8ed32f4a3f192a8ad04c64f6c1c0cd (diff)
gpg email verification
Diffstat (limited to 'spec/models/gpg_key_spec.rb')
-rw-r--r--spec/models/gpg_key_spec.rb45
1 files changed, 42 insertions, 3 deletions
diff --git a/spec/models/gpg_key_spec.rb b/spec/models/gpg_key_spec.rb
index e8c41299937..695a2f65c09 100644
--- a/spec/models/gpg_key_spec.rb
+++ b/spec/models/gpg_key_spec.rb
@@ -23,9 +23,20 @@ describe GpgKey do
end
describe 'add_to_keychain' do
- it 'calls add_to_keychain after create' do
- expect(Gitlab::Gpg::CurrentKeyChain).to receive(:add).with(GpgHelpers::User1.public_key)
- create :gpg_key
+ context "user's email matches one of the key's emails" do
+ it 'calls .add after create' do
+ expect(Gitlab::Gpg::CurrentKeyChain).to receive(:add).with(GpgHelpers::User2.public_key)
+ user = create :user, email: GpgHelpers::User2.emails.first
+ create :gpg_key, user: user, key: GpgHelpers::User2.public_key
+ end
+ end
+
+ context "user's email does not match one of the key's emails" do
+ it 'does not call .add after create' do
+ expect(Gitlab::Gpg::CurrentKeyChain).not_to receive(:add)
+ user = create :user
+ create :gpg_key, user: user, key: GpgHelpers::User2.public_key
+ end
end
end
@@ -64,4 +75,32 @@ describe GpgKey do
expect(gpg_key.emails).to eq GpgHelpers::User1.emails
end
end
+
+ describe '#emails_with_verified_status', :gpg do
+ context 'key is in the keychain' do
+ it 'email is verified if the user has the matching 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.emails_with_verified_status).to match_array [
+ ['bette.cartwright@example.com', true],
+ ['bette.cartwright@example.net', false]
+ ]
+ end
+ end
+
+ context 'key is in not the keychain' do
+ it 'emails are unverified' do
+ user = create :user, email: 'bette.cartwright@example.com'
+ gpg_key = create :gpg_key, key: GpgHelpers::User2.public_key, user: user
+
+ Gitlab::Gpg::CurrentKeyChain.remove(GpgHelpers::User2.fingerprint)
+
+ expect(gpg_key.emails_with_verified_status).to match_array [
+ ['bette.cartwright@example.com', false],
+ ['bette.cartwright@example.net', false]
+ ]
+ end
+ end
+ end
end