2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-22 15:24:48 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
describe 'Profile > GPG Keys' do
|
2017-02-24 20:28:26 +00:00
|
|
|
let(:user) { create(:user, email: GpgHelpers::User2.emails.first) }
|
2017-02-22 15:24:48 +00:00
|
|
|
|
|
|
|
before do
|
2017-09-20 11:24:42 +00:00
|
|
|
sign_in(user)
|
2017-02-22 15:24:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'User adds a key' do
|
|
|
|
before do
|
|
|
|
visit profile_gpg_keys_path
|
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'saves the new key' do
|
2017-02-24 20:28:26 +00:00
|
|
|
fill_in('Key', with: GpgHelpers::User2.public_key)
|
2017-02-22 15:24:48 +00:00
|
|
|
click_button('Add key')
|
|
|
|
|
2017-02-24 20:28:26 +00: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 15:24:48 +00:00
|
|
|
end
|
2017-09-29 00:57:49 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'with multiple subkeys' do
|
2017-09-29 00:57:49 +00: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 15:24:48 +00:00
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'User sees their key' do
|
2017-02-24 20:28:26 +00:00
|
|
|
create(:gpg_key, user: user, key: GpgHelpers::User2.public_key)
|
2017-02-22 15:24:48 +00:00
|
|
|
visit profile_gpg_keys_path
|
|
|
|
|
2017-02-24 20:28:26 +00: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 15:24:48 +00:00
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'User removes a key via the key index' do
|
2017-02-24 20:28:26 +00:00
|
|
|
create(:gpg_key, user: user, key: GpgHelpers::User2.public_key)
|
2017-02-22 15:24:48 +00:00
|
|
|
visit profile_gpg_keys_path
|
|
|
|
|
|
|
|
click_link('Remove')
|
|
|
|
|
|
|
|
expect(page).to have_content('Your GPG keys (0)')
|
|
|
|
end
|
2017-07-12 05:59:28 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'User revokes a key via the key index' do
|
2017-07-12 05:59:28 +00:00
|
|
|
gpg_key = create :gpg_key, user: user, key: GpgHelpers::User2.public_key
|
2017-08-30 11:27:40 +00:00
|
|
|
gpg_signature = create :gpg_signature, gpg_key: gpg_key, verification_status: :verified
|
2017-07-12 05:59:28 +00: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 11:27:40 +00:00
|
|
|
verification_status: 'unknown_key',
|
2017-07-12 05:59:28 +00:00
|
|
|
gpg_key: nil
|
|
|
|
)
|
|
|
|
end
|
2017-02-22 15:24:48 +00:00
|
|
|
end
|