diff options
Diffstat (limited to 'spec/features/profiles/keys_spec.rb')
-rw-r--r-- | spec/features/profiles/keys_spec.rb | 77 |
1 files changed, 59 insertions, 18 deletions
diff --git a/spec/features/profiles/keys_spec.rb b/spec/features/profiles/keys_spec.rb index 7a2a12d8dca..ae61f1cf492 100644 --- a/spec/features/profiles/keys_spec.rb +++ b/spec/features/profiles/keys_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Profile > SSH Keys', feature_category: :users do +RSpec.describe 'Profile > SSH Keys', feature_category: :user_profile do let(:user) { create(:user) } before do @@ -76,35 +76,76 @@ RSpec.describe 'Profile > SSH Keys', feature_category: :users do expect(page).to have_content(key.title) end + def destroy_key(path, action, confirmation_button) + visit path + + page.click_button(action) + + page.within('.modal') do + page.click_button(confirmation_button) + end + + expect(page).to have_content('Your SSH keys (0)') + end + describe 'User removes a key', :js do - shared_examples 'removes key' do - it 'removes key' do - visit path - find('[data-testid=remove-icon]').click + let!(:key) { create(:key, user: user) } - page.within('.modal') do - page.click_button('Delete') - end + context 'via the key index' do + it 'removes key' do + destroy_key(profile_keys_path, 'Remove', 'Delete') + end + end - expect(page).to have_content('Your SSH keys (0)') + context 'via its details page' do + it 'removes key' do + destroy_key(profile_keys_path(key), 'Remove', 'Delete') end end + end + + describe 'User revokes a key', :js do + context 'when a commit is signed using SSH key' do + let!(:project) { create(:project, :repository) } + let!(:key) { create(:key, user: user) } + let!(:commit) { project.commit('ssh-signed-commit') } + + let!(:signature) do + create(:ssh_signature, + project: project, + key: key, + key_fingerprint_sha256: key.fingerprint_sha256, + commit_sha: commit.sha) + end - context 'via the key index' do before do - create(:key, user: user) + project.add_developer(user) end - let(:path) { profile_keys_path } + it 'revoking the SSH key marks commits as unverified' do + visit project_commit_path(project, commit) + wait_for_all_requests - it_behaves_like 'removes key' - end + find('a.signature-badge', text: 'Verified').click - context 'via its details page' do - let(:key) { create(:key, user: user) } - let(:path) { profile_keys_path(key) } + within('.popover') do + expect(page).to have_content("Verified commit") + expect(page).to have_content("SSH key fingerprint: #{key.fingerprint_sha256}") + end + + destroy_key(profile_keys_path, 'Revoke', 'Revoke') + + visit project_commit_path(project, commit) + wait_for_all_requests - it_behaves_like 'removes key' + find('a.signature-badge', text: 'Unverified').click + + within('.popover') do + expect(page).to have_content("Unverified signature") + expect(page).to have_content('This commit was signed with a key that was revoked.') + expect(page).to have_content("SSH key fingerprint: #{signature.key_fingerprint_sha256}") + end + end end end end |