2016-08-24 12:49:21 +05:30
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
feature 'Admin disables Git access protocol' do
|
2017-08-17 22:00:37 +05:30
|
|
|
include StubENV
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project) { create(:project, :empty_repo) }
|
2016-08-24 12:49:21 +05:30
|
|
|
let(:admin) { create(:admin) }
|
|
|
|
|
|
|
|
background do
|
2017-08-17 22:00:37 +05:30
|
|
|
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(admin)
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'with HTTP disabled' do
|
|
|
|
background do
|
|
|
|
disable_http_protocol
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'shows only SSH url' do
|
|
|
|
visit_project
|
|
|
|
|
|
|
|
expect(page).to have_content("git clone #{project.ssh_url_to_repo}")
|
|
|
|
expect(page).not_to have_selector('#clone-dropdown')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with SSH disabled' do
|
|
|
|
background do
|
|
|
|
disable_ssh_protocol
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'shows only HTTP url' do
|
|
|
|
visit_project
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(page).to have_content("git clone #{project.http_url_to_repo}")
|
2016-08-24 12:49:21 +05:30
|
|
|
expect(page).not_to have_selector('#clone-dropdown')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with nothing disabled' do
|
|
|
|
background do
|
|
|
|
create(:personal_key, user: admin)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'shows default SSH url and protocol selection dropdown' do
|
|
|
|
visit_project
|
|
|
|
|
|
|
|
expect(page).to have_content("git clone #{project.ssh_url_to_repo}")
|
|
|
|
expect(page).to have_selector('#clone-dropdown')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def visit_project
|
2017-09-10 17:25:29 +05:30
|
|
|
visit project_path(project)
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def disable_http_protocol
|
|
|
|
visit admin_application_settings_path
|
|
|
|
find('#application_setting_enabled_git_access_protocol').find(:xpath, 'option[2]').select_option
|
|
|
|
click_on 'Save'
|
|
|
|
end
|
|
|
|
|
|
|
|
def disable_ssh_protocol
|
|
|
|
visit admin_application_settings_path
|
|
|
|
find('#application_setting_enabled_git_access_protocol').find(:xpath, 'option[3]').select_option
|
|
|
|
click_on 'Save'
|
|
|
|
end
|
|
|
|
end
|