gitlab-org--gitlab-foss/spec/features/profiles/gpg_keys_spec.rb

73 lines
2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'spec_helper'
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) }
before do
sign_in(user)
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)
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)
end
2018-07-05 02:32:05 -04:00
it 'with multiple subkeys' do
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
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)
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)
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)
visit profile_gpg_keys_path
click_link('Remove')
expect(page).to have_content('Your GPG keys (0)')
end
2018-07-05 02:32:05 -04:00
it 'User revokes a key via the key index' do
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
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',
gpg_key: nil
)
end
end