diff options
author | Alexis Reigel <mail@koffeinfrei.org> | 2017-06-12 16:16:33 +0200 |
---|---|---|
committer | Alexis Reigel <mail@koffeinfrei.org> | 2017-07-27 15:42:53 +0200 |
commit | 7e13d96715750f74db399bf40ee4ec9679bbe806 (patch) | |
tree | b26af883e7055a7d8990bdc2e168117b260bbc7f /spec/models/gpg_key_spec.rb | |
parent | d1101ec02ec718d0ce15e76217980f6fa21c9089 (diff) | |
download | gitlab-ce-7e13d96715750f74db399bf40ee4ec9679bbe806.tar.gz |
don't sync to keychain file
Diffstat (limited to 'spec/models/gpg_key_spec.rb')
-rw-r--r-- | spec/models/gpg_key_spec.rb | 95 |
1 files changed, 8 insertions, 87 deletions
diff --git a/spec/models/gpg_key_spec.rb b/spec/models/gpg_key_spec.rb index 18746ad9d88..6ee436b6a6d 100644 --- a/spec/models/gpg_key_spec.rb +++ b/spec/models/gpg_key_spec.rb @@ -21,20 +21,6 @@ describe GpgKey do expect(gpg_key.fingerprint).to eq GpgHelpers::User1.fingerprint end end - - describe 'synchronize_keychain' do - it 'calls #synchronize_keychain after create' do - gpg_key = build :gpg_key - expect(gpg_key).to receive(:synchronize_keychain) - gpg_key.save! - end - - it 'calls #remove_from_keychain after destroy' do - gpg_key = create :gpg_key - expect(gpg_key).to receive(:synchronize_keychain) - gpg_key.destroy! - end - end end describe '#key=' do @@ -59,80 +45,15 @@ describe GpgKey do end end - describe '#emails_in_keychain', :gpg do - it 'returns the emails from the keychain' do - user = create :user, email: GpgHelpers::User1.emails.first - gpg_key = create :gpg_key, key: GpgHelpers::User1.public_key, user: user - - expect(gpg_key.emails_in_keychain).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 - - describe '#synchronize_keychain', :gpg do - context "user's email matches one of the key's emails" do - it 'adds the key to the keychain' do - user = create :user, email: GpgHelpers::User1.emails.first - gpg_key = create :gpg_key, user: user - - expect(gpg_key).to receive(:add_to_keychain) - - gpg_key.synchronize_keychain - end - end - - context "user's email does not match one of the key's emails" do - it 'does not add the key to the keychain' do - user = create :user, email: 'stepanie@cole.us' - gpg_key = create :gpg_key, user: user - - expect(gpg_key).to receive(:remove_from_keychain) - - gpg_key.synchronize_keychain - end - end - end - - describe '#add_to_keychain', :gpg do - it 'calls .add_to_keychain' do - expect(Gitlab::Gpg::CurrentKeyChain).to receive(:add).with(GpgHelpers::User2.public_key) - gpg_key = create :gpg_key, key: GpgHelpers::User2.public_key - gpg_key.send(:add_to_keychain) - end - end - - describe '#remove_from_keychain', :gpg do - it 'calls .remove_from_keychain' do - allow(Gitlab::Gpg::CurrentKeyChain).to receive(:remove).with(GpgHelpers::User2.fingerprint) - gpg_key = create :gpg_key, key: GpgHelpers::User2.public_key - gpg_key.send(:remove_from_keychain) + 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 |