2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
require 'spec_helper'
|
2016-08-24 12:49:21 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe 'Admin disables Git access protocol', :js do
|
2017-08-17 22:00:37 +05:30
|
|
|
include StubENV
|
2019-02-15 15:39:39 +05:30
|
|
|
include MobileHelpers
|
2017-08-17 22:00:37 +05:30
|
|
|
|
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) }
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
before 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)
|
2021-02-22 17:27:13 +05:30
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'with HTTP disabled' do
|
2018-11-08 19:23:39 +05:30
|
|
|
before do
|
2016-08-24 12:49:21 +05:30
|
|
|
disable_http_protocol
|
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'shows only SSH url' do
|
2016-08-24 12:49:21 +05:30
|
|
|
visit_project
|
|
|
|
|
|
|
|
expect(page).to have_content("git clone #{project.ssh_url_to_repo}")
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
find('.clone-dropdown-btn').click
|
|
|
|
|
|
|
|
within('.git-clone-holder') do
|
|
|
|
expect(page).to have_content('Clone with SSH')
|
|
|
|
expect(page).not_to have_content('Clone with HTTP')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'mobile component' do
|
|
|
|
it 'shows only the SSH clone information' do
|
|
|
|
resize_screen_xs
|
|
|
|
visit_project
|
2021-03-11 19:13:27 +05:30
|
|
|
|
|
|
|
within('.js-mobile-git-clone') do
|
|
|
|
find('.dropdown-toggle').click
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
expect(page).to have_content('Copy SSH clone URL')
|
|
|
|
expect(page).not_to have_content('Copy HTTP clone URL')
|
|
|
|
end
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with SSH disabled' do
|
2018-11-08 19:23:39 +05:30
|
|
|
before do
|
2016-08-24 12:49:21 +05:30
|
|
|
disable_ssh_protocol
|
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'shows only HTTP url' do
|
2016-08-24 12:49:21 +05:30
|
|
|
visit_project
|
2019-02-15 15:39:39 +05:30
|
|
|
find('.clone-dropdown-btn').click
|
2016-08-24 12:49:21 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(page).to have_content("git clone #{project.http_url_to_repo}")
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
within('.git-clone-holder') do
|
|
|
|
expect(page).to have_content('Clone with HTTP')
|
|
|
|
expect(page).not_to have_content('Clone with SSH')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'mobile component' do
|
|
|
|
it 'shows only the HTTP clone information' do
|
|
|
|
resize_screen_xs
|
|
|
|
visit_project
|
2021-03-11 19:13:27 +05:30
|
|
|
|
|
|
|
within('.js-mobile-git-clone') do
|
|
|
|
find('.dropdown-toggle').click
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
expect(page).to have_content('Copy HTTP clone URL')
|
|
|
|
expect(page).not_to have_content('Copy SSH clone URL')
|
|
|
|
end
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with nothing disabled' do
|
2018-11-08 19:23:39 +05:30
|
|
|
before do
|
2016-08-24 12:49:21 +05:30
|
|
|
create(:personal_key, user: admin)
|
2019-12-04 20:38:33 +05:30
|
|
|
allow_all_protocols
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'shows default SSH url and protocol selection dropdown' do
|
2016-08-24 12:49:21 +05:30
|
|
|
visit_project
|
|
|
|
|
|
|
|
expect(page).to have_content("git clone #{project.ssh_url_to_repo}")
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
find('.clone-dropdown-btn').click
|
|
|
|
|
|
|
|
within('.git-clone-holder') do
|
|
|
|
expect(page).to have_content('Clone with SSH')
|
|
|
|
expect(page).to have_content('Clone with HTTP')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'mobile component' do
|
|
|
|
it 'shows both SSH and HTTP clone information' do
|
|
|
|
resize_screen_xs
|
|
|
|
visit_project
|
2021-03-11 19:13:27 +05:30
|
|
|
|
|
|
|
within('.js-mobile-git-clone') do
|
|
|
|
find('.dropdown-toggle').click
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
expect(page).to have_content('Copy HTTP clone URL')
|
|
|
|
expect(page).to have_content('Copy SSH clone URL')
|
|
|
|
end
|
2016-08-24 12:49:21 +05:30
|
|
|
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
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
def allow_all_protocols
|
|
|
|
switch_git_protocol(1)
|
|
|
|
end
|
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
def disable_http_protocol
|
2018-05-09 12:01:36 +05:30
|
|
|
switch_git_protocol(2)
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def disable_ssh_protocol
|
2018-05-09 12:01:36 +05:30
|
|
|
switch_git_protocol(3)
|
|
|
|
end
|
|
|
|
|
|
|
|
def switch_git_protocol(value)
|
2020-03-13 15:44:24 +05:30
|
|
|
visit general_admin_application_settings_path
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
page.within('.as-visibility-access') do
|
|
|
|
find('#application_setting_enabled_git_access_protocol').find(:xpath, "option[#{value}]").select_option
|
|
|
|
click_on 'Save'
|
|
|
|
end
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|
|
|
|
end
|