debian-mirror-gitlab/spec/features/admin/admin_deploy_keys_spec.rb

97 lines
2.6 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2022-03-02 08:16:31 +05:30
RSpec.describe 'admin deploy keys', :js do
2022-01-26 12:08:38 +05:30
include Spec::Support::Helpers::ModalHelpers
2021-12-11 22:18:48 +05:30
let_it_be(:admin) { create(:admin) }
2017-08-17 22:00:37 +05:30
let!(:deploy_key) { create(:deploy_key, public: true) }
let!(:another_deploy_key) { create(:another_deploy_key, public: true) }
before do
2021-02-22 17:27:13 +05:30
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
2017-08-17 22:00:37 +05:30
end
2022-03-02 08:16:31 +05:30
it 'show all public deploy keys' do
visit admin_deploy_keys_path
2017-08-17 22:00:37 +05:30
2022-03-02 08:16:31 +05:30
page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
expect(page).to have_content(deploy_key.title)
expect(page).to have_content(another_deploy_key.title)
2017-09-10 17:25:29 +05:30
end
2022-03-02 08:16:31 +05:30
end
2017-08-17 22:00:37 +05:30
2022-03-02 08:16:31 +05:30
it 'shows all the projects the deploy key has write access' do
write_key = create(:deploy_keys_project, :write_access, deploy_key: deploy_key)
2018-03-17 18:26:18 +05:30
2022-03-02 08:16:31 +05:30
visit admin_deploy_keys_path
2018-03-17 18:26:18 +05:30
2022-03-02 08:16:31 +05:30
page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
expect(page).to have_content(write_key.project.full_name)
2018-03-17 18:26:18 +05:30
end
2022-03-02 08:16:31 +05:30
end
2018-03-17 18:26:18 +05:30
2022-03-02 08:16:31 +05:30
describe 'create a new deploy key' do
let(:new_ssh_key) { attributes_for(:key)[:key] }
2017-08-17 22:00:37 +05:30
2022-03-02 08:16:31 +05:30
before do
visit admin_deploy_keys_path
click_link 'New deploy key'
2017-09-10 17:25:29 +05:30
end
2017-08-17 22:00:37 +05:30
2022-03-02 08:16:31 +05:30
it 'creates a new deploy key' do
fill_in 'deploy_key_title', with: 'laptop'
fill_in 'deploy_key_key', with: new_ssh_key
click_button 'Create'
2017-08-17 22:00:37 +05:30
2022-03-02 08:16:31 +05:30
expect(current_path).to eq admin_deploy_keys_path
2017-09-10 17:25:29 +05:30
2022-03-02 08:16:31 +05:30
page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
expect(page).to have_content('laptop')
2017-09-10 17:25:29 +05:30
end
2017-08-17 22:00:37 +05:30
end
2017-09-10 17:25:29 +05:30
end
2017-08-17 22:00:37 +05:30
2022-03-02 08:16:31 +05:30
describe 'update an existing deploy key' do
before do
visit admin_deploy_keys_path
page.within('tr', text: deploy_key.title) do
click_link(_('Edit deploy key'))
2022-01-26 12:08:38 +05:30
end
2022-03-02 08:16:31 +05:30
end
2017-09-10 17:25:29 +05:30
2022-03-02 08:16:31 +05:30
it 'updates an existing deploy key' do
fill_in 'deploy_key_title', with: 'new-title'
click_button 'Save changes'
2022-01-26 12:08:38 +05:30
2022-03-02 08:16:31 +05:30
expect(current_path).to eq admin_deploy_keys_path
page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
expect(page).to have_content('new-title')
2017-09-10 17:25:29 +05:30
end
2017-08-17 22:00:37 +05:30
end
end
2021-12-11 22:18:48 +05:30
2022-03-02 08:16:31 +05:30
describe 'remove an existing deploy key' do
2021-12-11 22:18:48 +05:30
before do
2022-03-02 08:16:31 +05:30
visit admin_deploy_keys_path
2021-12-11 22:18:48 +05:30
end
2022-03-02 08:16:31 +05:30
it 'removes an existing deploy key' do
accept_gl_confirm('Are you sure you want to delete this deploy key?', button_text: 'Delete') do
2022-01-26 12:08:38 +05:30
page.within('tr', text: deploy_key.title) do
2022-03-02 08:16:31 +05:30
click_button _('Delete deploy key')
2022-01-26 12:08:38 +05:30
end
2022-03-02 08:16:31 +05:30
end
2022-01-26 12:08:38 +05:30
2022-03-02 08:16:31 +05:30
expect(current_path).to eq admin_deploy_keys_path
page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
expect(page).not_to have_content(deploy_key.title)
2022-01-26 12:08:38 +05:30
end
2021-12-11 22:18:48 +05:30
end
end
2017-08-17 22:00:37 +05:30
end