summaryrefslogtreecommitdiff
path: root/spec/features/projects/deploy_keys_spec.rb
blob: 06462263f5a17e42a9e2549a7fdbfba4a74c140f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Project deploy keys', :js do
  let_it_be(:user) { create(:user) }
  let_it_be(:project) { create(:project_empty_repo) }
  let_it_be(:deploy_keys_project) { create(:deploy_keys_project, project: project) }
  let_it_be(:deploy_key) { deploy_keys_project.deploy_key }

  before do
    project.add_maintainer(user)
    sign_in(user)
  end

  context 'editing key' do
    it 'shows fingerprints' do
      visit edit_project_deploy_key_path(project, deploy_key)

      expect(page).to have_content('Fingerprint (SHA256)')
      expect(find('#deploy_key_fingerprint_sha256').value).to eq(deploy_key.fingerprint_sha256)

      if Gitlab::FIPS.enabled?
        expect(page).not_to have_content('Fingerprint (MD5)')
      else
        expect(page).to have_content('Fingerprint (MD5)')
        expect(find('#deploy_key_fingerprint').value).to eq(deploy_key.fingerprint)
      end
    end
  end

  describe 'removing key' do
    before do
      visit project_settings_repository_path(project)
    end

    it 'removes association between project and deploy key' do
      page.within(find('.rspec-deploy-keys-settings')) do
        expect(page).to have_selector('.deploy-key', count: 1)

        click_button 'Remove'
        click_button 'Remove deploy key'

        wait_for_requests

        expect(page).to have_selector('.deploy-key', count: 0)
      end
    end
  end
end