debian-mirror-gitlab/spec/features/profiles/gpg_keys_spec.rb

71 lines
2 KiB
Ruby
Raw Normal View History

2017-09-10 17:25:29 +05:30
require 'rails_helper'
2018-11-08 19:23:39 +05:30
describe 'Profile > GPG Keys' 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
2018-11-08 19:23:39 +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
2018-11-08 19:23:39 +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
2018-11-08 19:23:39 +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