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 | |
parent | d1101ec02ec718d0ce15e76217980f6fa21c9089 (diff) | |
download | gitlab-ce-7e13d96715750f74db399bf40ee4ec9679bbe806.tar.gz |
don't sync to keychain file
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/gpg_spec.rb | 33 | ||||
-rw-r--r-- | spec/models/gpg_key_spec.rb | 95 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 20 |
3 files changed, 8 insertions, 140 deletions
diff --git a/spec/lib/gitlab/gpg_spec.rb b/spec/lib/gitlab/gpg_spec.rb index c0df719c0c2..bdcf9ee0e65 100644 --- a/spec/lib/gitlab/gpg_spec.rb +++ b/spec/lib/gitlab/gpg_spec.rb @@ -29,36 +29,3 @@ describe Gitlab::Gpg do end end end - -describe Gitlab::Gpg::CurrentKeyChain, :gpg do - describe '.emails' do - it 'returns the emails' do - Gitlab::Gpg::CurrentKeyChain.add(GpgHelpers::User2.public_key) - - expect( - described_class.emails(GpgHelpers::User2.fingerprint) - ).to match_array GpgHelpers::User2.emails - end - end - - describe '.add', :gpg do - it 'stores the key in the keychain' do - expect(GPGME::Key.find(:public, GpgHelpers::User1.fingerprint)).to eq [] - - Gitlab::Gpg::CurrentKeyChain.add(GpgHelpers::User1.public_key) - - expect(GPGME::Key.find(:public, GpgHelpers::User1.fingerprint)).not_to eq [] - end - end - - describe '.remove', :gpg do - it 'removes the key from the keychain' do - Gitlab::Gpg::CurrentKeyChain.add(GpgHelpers::User1.public_key) - expect(GPGME::Key.find(:public, GpgHelpers::User1.fingerprint)).not_to eq [] - - Gitlab::Gpg::CurrentKeyChain.remove(GpgHelpers::User1.fingerprint) - - expect(GPGME::Key.find(:public, GpgHelpers::User1.fingerprint)).to eq [] - end - end -end 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 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 60979fd6c06..20bdb7e37da 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1956,24 +1956,4 @@ describe User, models: true do expect(user.allow_password_authentication?).to be_falsey end end - - context 'callbacks' do - context '.synchronize_gpg_keys' do - let(:user) do - create(:user, email: 'tula.torphy@abshire.ca').tap do |user| - user.skip_reconfirmation! - end - end - - it 'does nothing when the name is updated' do - expect(user).not_to receive(:synchronize_gpg_keys) - user.update_attributes!(name: 'Bette') - end - - it 'synchronizes the gpg keys when the email is updated' do - expect(user).to receive(:synchronize_gpg_keys) - user.update_attributes!(email: 'shawnee.ritchie@denesik.com') - end - end - end end |