2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 03:56:52 -04:00
|
|
|
require 'spec_helper'
|
2017-02-22 10:24:48 -05:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
describe 'Profile > GPG Keys' do
|
2017-02-24 15:28:26 -05:00
|
|
|
let(:user) { create(:user, email: GpgHelpers::User2.emails.first) }
|
2017-02-22 10:24:48 -05:00
|
|
|
|
|
|
|
before do
|
2017-09-20 07:24:42 -04:00
|
|
|
sign_in(user)
|
2017-02-22 10:24:48 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'User adds a key' do
|
|
|
|
before do
|
|
|
|
visit profile_gpg_keys_path
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'saves the new key' do
|
2017-02-24 15:28:26 -05:00
|
|
|
fill_in('Key', with: GpgHelpers::User2.public_key)
|
2017-02-22 10:24:48 -05:00
|
|
|
click_button('Add key')
|
|
|
|
|
2017-02-24 15:28:26 -05:00
|
|
|
expect(page).to have_content('bette.cartwright@example.com Verified')
|
|
|
|
expect(page).to have_content('bette.cartwright@example.net Unverified')
|
|
|
|
expect(page).to have_content(GpgHelpers::User2.fingerprint)
|
2017-02-22 10:24:48 -05:00
|
|
|
end
|
2017-09-28 20:57:49 -04:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'with multiple subkeys' do
|
2017-09-28 20:57:49 -04:00
|
|
|
fill_in('Key', with: GpgHelpers::User3.public_key)
|
|
|
|
click_button('Add key')
|
|
|
|
|
|
|
|
expect(page).to have_content('john.doe@example.com Unverified')
|
|
|
|
expect(page).to have_content(GpgHelpers::User3.fingerprint)
|
|
|
|
|
|
|
|
GpgHelpers::User3.subkey_fingerprints.each do |fingerprint|
|
|
|
|
expect(page).to have_content(fingerprint)
|
|
|
|
end
|
|
|
|
end
|
2017-02-22 10:24:48 -05:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'User sees their key' do
|
2017-02-24 15:28:26 -05:00
|
|
|
create(:gpg_key, user: user, key: GpgHelpers::User2.public_key)
|
2017-02-22 10:24:48 -05:00
|
|
|
visit profile_gpg_keys_path
|
|
|
|
|
2017-02-24 15:28:26 -05:00
|
|
|
expect(page).to have_content('bette.cartwright@example.com Verified')
|
|
|
|
expect(page).to have_content('bette.cartwright@example.net Unverified')
|
|
|
|
expect(page).to have_content(GpgHelpers::User2.fingerprint)
|
2017-02-22 10:24:48 -05:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'User removes a key via the key index' do
|
2017-02-24 15:28:26 -05:00
|
|
|
create(:gpg_key, user: user, key: GpgHelpers::User2.public_key)
|
2017-02-22 10:24:48 -05:00
|
|
|
visit profile_gpg_keys_path
|
|
|
|
|
|
|
|
click_link('Remove')
|
|
|
|
|
|
|
|
expect(page).to have_content('Your GPG keys (0)')
|
|
|
|
end
|
2017-07-12 01:59:28 -04:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'User revokes a key via the key index' do
|
2017-07-12 01:59:28 -04:00
|
|
|
gpg_key = create :gpg_key, user: user, key: GpgHelpers::User2.public_key
|
2017-08-30 07:27:40 -04:00
|
|
|
gpg_signature = create :gpg_signature, gpg_key: gpg_key, verification_status: :verified
|
2017-07-12 01:59:28 -04:00
|
|
|
|
|
|
|
visit profile_gpg_keys_path
|
|
|
|
|
|
|
|
click_link('Revoke')
|
|
|
|
|
|
|
|
expect(page).to have_content('Your GPG keys (0)')
|
|
|
|
|
|
|
|
expect(gpg_signature.reload).to have_attributes(
|
2017-08-30 07:27:40 -04:00
|
|
|
verification_status: 'unknown_key',
|
2017-07-12 01:59:28 -04:00
|
|
|
gpg_key: nil
|
|
|
|
)
|
|
|
|
end
|
2017-02-22 10:24:48 -05:00
|
|
|
end
|