2017-09-10 17:25:29 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
feature 'Repository settings' do
|
|
|
|
let(:project) { create(:project_empty_repo) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:role) { :developer }
|
|
|
|
|
|
|
|
background do
|
2018-03-17 18:26:18 +05:30
|
|
|
project.add_role(user, role)
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for developer' do
|
|
|
|
given(:role) { :developer }
|
|
|
|
|
|
|
|
scenario 'is not allowed to view' do
|
|
|
|
visit project_settings_repository_path(project)
|
|
|
|
|
|
|
|
expect(page.status_code).to eq(404)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for master' do
|
|
|
|
given(:role) { :master }
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
context 'Deploy Keys', :js do
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:private_deploy_key) { create(:deploy_key, title: 'private_deploy_key', public: false) }
|
|
|
|
let(:public_deploy_key) { create(:another_deploy_key, title: 'public_deploy_key', public: true) }
|
|
|
|
let(:new_ssh_key) { attributes_for(:key)[:key] }
|
|
|
|
|
|
|
|
scenario 'get list of keys' do
|
|
|
|
project.deploy_keys << private_deploy_key
|
|
|
|
project.deploy_keys << public_deploy_key
|
|
|
|
|
|
|
|
visit project_settings_repository_path(project)
|
|
|
|
|
|
|
|
expect(page).to have_content('private_deploy_key')
|
|
|
|
expect(page).to have_content('public_deploy_key')
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'add a new deploy key' do
|
|
|
|
visit project_settings_repository_path(project)
|
|
|
|
|
|
|
|
fill_in 'deploy_key_title', with: 'new_deploy_key'
|
|
|
|
fill_in 'deploy_key_key', with: new_ssh_key
|
2018-03-17 18:26:18 +05:30
|
|
|
check 'deploy_key_deploy_keys_projects_attributes_0_can_push'
|
2017-09-10 17:25:29 +05:30
|
|
|
click_button 'Add key'
|
|
|
|
|
|
|
|
expect(page).to have_content('new_deploy_key')
|
|
|
|
expect(page).to have_content('Write access allowed')
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'edit an existing deploy key' do
|
|
|
|
project.deploy_keys << private_deploy_key
|
|
|
|
visit project_settings_repository_path(project)
|
|
|
|
|
|
|
|
find('li', text: private_deploy_key.title).click_link('Edit')
|
|
|
|
|
|
|
|
fill_in 'deploy_key_title', with: 'updated_deploy_key'
|
2018-03-17 18:26:18 +05:30
|
|
|
check 'deploy_key_deploy_keys_projects_attributes_0_can_push'
|
2017-09-10 17:25:29 +05:30
|
|
|
click_button 'Save changes'
|
|
|
|
|
|
|
|
expect(page).to have_content('updated_deploy_key')
|
|
|
|
expect(page).to have_content('Write access allowed')
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'edit a deploy key from projects user has access to' do
|
|
|
|
project2 = create(:project_empty_repo)
|
2018-03-17 18:26:18 +05:30
|
|
|
project2.add_role(user, role)
|
2017-09-10 17:25:29 +05:30
|
|
|
project2.deploy_keys << private_deploy_key
|
|
|
|
|
|
|
|
visit project_settings_repository_path(project)
|
|
|
|
|
|
|
|
find('li', text: private_deploy_key.title).click_link('Edit')
|
|
|
|
|
|
|
|
fill_in 'deploy_key_title', with: 'updated_deploy_key'
|
|
|
|
click_button 'Save changes'
|
|
|
|
|
|
|
|
expect(page).to have_content('updated_deploy_key')
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'remove an existing deploy key' do
|
|
|
|
project.deploy_keys << private_deploy_key
|
|
|
|
visit project_settings_repository_path(project)
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
accept_confirm { find('li', text: private_deploy_key.title).click_button('Remove') }
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
expect(page).not_to have_content(private_deploy_key.title)
|
|
|
|
end
|
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
context 'Deploy tokens' do
|
|
|
|
let!(:deploy_token) { create(:deploy_token, projects: [project]) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
stub_container_registry_config(enabled: true)
|
|
|
|
visit project_settings_repository_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'view deploy tokens' do
|
|
|
|
within('.deploy-tokens') do
|
|
|
|
expect(page).to have_content(deploy_token.name)
|
|
|
|
expect(page).to have_content('read_repository')
|
|
|
|
expect(page).to have_content('read_registry')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'add a new deploy token' do
|
|
|
|
fill_in 'deploy_token_name', with: 'new_deploy_key'
|
|
|
|
fill_in 'deploy_token_expires_at', with: (Date.today + 1.month).to_s
|
|
|
|
check 'deploy_token_read_repository'
|
|
|
|
check 'deploy_token_read_registry'
|
|
|
|
click_button 'Create deploy token'
|
|
|
|
|
|
|
|
expect(page).to have_content('Your new project deploy token has been created')
|
|
|
|
end
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|