2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
require 'spec_helper'
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
RSpec.describe 'Profile > GPG Keys', feature_category: :user_profile do
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:user) { create(:user, email: GpgHelpers::User2.emails.first) }
|
|
|
|
|
|
|
|
before do
|
2018-03-17 18:26:18 +05:30
|
|
|
sign_in(user)
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
describe 'User adds a key' do
|
|
|
|
before do
|
|
|
|
visit profile_gpg_keys_path
|
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'saves the new key' do
|
2017-09-10 17:25:29 +05:30
|
|
|
fill_in('Key', with: GpgHelpers::User2.public_key)
|
|
|
|
click_button('Add key')
|
|
|
|
|
|
|
|
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)
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'with multiple subkeys' do
|
2018-03-17 18:26:18 +05:30
|
|
|
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-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
it 'user sees their key' do
|
2017-09-10 17:25:29 +05:30
|
|
|
create(:gpg_key, user: user, key: GpgHelpers::User2.public_key)
|
|
|
|
visit profile_gpg_keys_path
|
|
|
|
|
|
|
|
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)
|
|
|
|
end
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
it 'user removes a key via the key index' do
|
2017-09-10 17:25:29 +05:30
|
|
|
create(:gpg_key, user: user, key: GpgHelpers::User2.public_key)
|
|
|
|
visit profile_gpg_keys_path
|
|
|
|
|
|
|
|
click_link('Remove')
|
|
|
|
|
|
|
|
expect(page).to have_content('Your GPG keys (0)')
|
|
|
|
end
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
it 'user revokes a key via the key index' do
|
2017-09-10 17:25:29 +05:30
|
|
|
gpg_key = create :gpg_key, user: user, key: GpgHelpers::User2.public_key
|
2018-03-17 18:26:18 +05:30
|
|
|
gpg_signature = create :gpg_signature, gpg_key: gpg_key, verification_status: :verified
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
visit profile_gpg_keys_path
|
|
|
|
|
|
|
|
click_link('Revoke')
|
|
|
|
|
|
|
|
expect(page).to have_content('Your GPG keys (0)')
|
|
|
|
|
|
|
|
expect(gpg_signature.reload).to have_attributes(
|
2018-03-17 18:26:18 +05:30
|
|
|
verification_status: 'unknown_key',
|
2017-09-10 17:25:29 +05:30
|
|
|
gpg_key: nil
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|