2019-01-23 11:28:19 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Clusterable > Show page' do
|
2019-05-27 04:23:17 -04:00
|
|
|
include KubernetesHelpers
|
|
|
|
|
2019-01-23 11:28:19 -05:00
|
|
|
let(:current_user) { create(:user) }
|
2019-03-18 10:26:50 -04:00
|
|
|
let(:cluster_ingress_help_text_selector) { '.js-ingress-domain-help-text' }
|
|
|
|
let(:hide_modifier_selector) { '.hide' }
|
2019-01-23 11:28:19 -05:00
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(current_user)
|
|
|
|
end
|
|
|
|
|
2019-09-20 05:06:17 -04:00
|
|
|
shared_examples 'show page' do
|
2020-04-10 11:09:50 -04:00
|
|
|
it 'displays cluster type label' do
|
|
|
|
visit cluster_path
|
|
|
|
|
|
|
|
expect(page).to have_content(cluster_type_label)
|
|
|
|
end
|
|
|
|
|
2020-08-17 08:10:12 -04:00
|
|
|
it 'allow the user to set domain', :js do
|
2019-01-23 11:28:19 -05:00
|
|
|
visit cluster_path
|
|
|
|
|
2021-03-31 08:08:55 -04:00
|
|
|
within '.js-cluster-details-form' do
|
2019-01-31 09:58:58 -05:00
|
|
|
fill_in('cluster_base_domain', with: 'test.com')
|
2019-01-23 11:28:19 -05:00
|
|
|
click_on 'Save changes'
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content('Kubernetes cluster was successfully updated.')
|
|
|
|
end
|
|
|
|
|
2019-09-20 05:06:17 -04:00
|
|
|
it 'does not show the environments tab' do
|
|
|
|
visit cluster_path
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('.js-cluster-nav-environments', text: 'Environments')
|
|
|
|
end
|
2019-01-23 11:28:19 -05:00
|
|
|
end
|
|
|
|
|
2019-03-29 14:23:18 -04:00
|
|
|
shared_examples 'editing a GCP cluster' do
|
|
|
|
before do
|
|
|
|
visit cluster_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is not able to edit the name, API url, CA certificate nor token' do
|
2020-03-12 11:09:39 -04:00
|
|
|
within('.js-provider-details') do
|
2019-03-29 14:23:18 -04:00
|
|
|
cluster_name_field = find('.cluster-name')
|
|
|
|
api_url_field = find('#cluster_platform_kubernetes_attributes_api_url')
|
|
|
|
ca_certificate_field = find('#cluster_platform_kubernetes_attributes_ca_cert')
|
|
|
|
token_field = find('#cluster_platform_kubernetes_attributes_token')
|
|
|
|
|
|
|
|
expect(cluster_name_field).to be_readonly
|
|
|
|
expect(api_url_field).to be_readonly
|
|
|
|
expect(ca_certificate_field).to be_readonly
|
|
|
|
expect(token_field).to be_readonly
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays GKE information' do
|
2020-03-12 11:09:39 -04:00
|
|
|
click_link 'Advanced Settings'
|
|
|
|
|
2019-03-29 14:23:18 -04:00
|
|
|
within('#advanced-settings-section') do
|
|
|
|
expect(page).to have_content('Google Kubernetes Engine')
|
|
|
|
expect(page).to have_content('Manage your Kubernetes cluster by visiting')
|
2020-10-02 05:08:33 -04:00
|
|
|
expect_common_advanced_options
|
2019-03-29 14:23:18 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples 'editing a user-provided cluster' do
|
|
|
|
before do
|
2019-05-27 04:23:17 -04:00
|
|
|
stub_kubeclient_discover(cluster.platform.api_url)
|
2019-03-29 14:23:18 -04:00
|
|
|
visit cluster_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is able to edit the name, API url, CA certificate and token' do
|
2020-03-12 11:09:39 -04:00
|
|
|
within('.js-provider-details') do
|
2019-03-29 14:23:18 -04:00
|
|
|
cluster_name_field = find('#cluster_name')
|
|
|
|
api_url_field = find('#cluster_platform_kubernetes_attributes_api_url')
|
|
|
|
ca_certificate_field = find('#cluster_platform_kubernetes_attributes_ca_cert')
|
|
|
|
token_field = find('#cluster_platform_kubernetes_attributes_token')
|
|
|
|
|
|
|
|
expect(cluster_name_field).not_to be_readonly
|
|
|
|
expect(api_url_field).not_to be_readonly
|
|
|
|
expect(ca_certificate_field).not_to be_readonly
|
|
|
|
expect(token_field).not_to be_readonly
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not display GKE information' do
|
2020-03-12 11:09:39 -04:00
|
|
|
click_link 'Advanced Settings'
|
|
|
|
|
2019-03-29 14:23:18 -04:00
|
|
|
within('#advanced-settings-section') do
|
|
|
|
expect(page).not_to have_content('Google Kubernetes Engine')
|
|
|
|
expect(page).not_to have_content('Manage your Kubernetes cluster by visiting')
|
2020-10-02 05:08:33 -04:00
|
|
|
expect_common_advanced_options
|
2019-03-29 14:23:18 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-01-23 11:28:19 -05:00
|
|
|
context 'when clusterable is a project' do
|
2019-09-20 05:06:17 -04:00
|
|
|
let(:clusterable) { create(:project) }
|
|
|
|
let(:cluster_path) { project_cluster_path(clusterable, cluster) }
|
|
|
|
let(:cluster) { create(:cluster, :provided_by_gcp, :project, projects: [clusterable]) }
|
2019-03-29 14:23:18 -04:00
|
|
|
|
2019-10-15 02:07:25 -04:00
|
|
|
before do
|
|
|
|
clusterable.add_maintainer(current_user)
|
|
|
|
end
|
|
|
|
|
2020-04-10 11:09:50 -04:00
|
|
|
it_behaves_like 'show page' do
|
|
|
|
let(:cluster_type_label) { 'Project cluster' }
|
|
|
|
end
|
2019-09-20 05:06:17 -04:00
|
|
|
|
|
|
|
it_behaves_like 'editing a GCP cluster'
|
2019-03-29 14:23:18 -04:00
|
|
|
|
|
|
|
it_behaves_like 'editing a user-provided cluster' do
|
|
|
|
let(:cluster) { create(:cluster, :provided_by_user, :project, projects: [clusterable]) }
|
|
|
|
end
|
2019-01-23 11:28:19 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when clusterable is a group' do
|
2019-09-20 05:06:17 -04:00
|
|
|
let(:clusterable) { create(:group) }
|
|
|
|
let(:cluster_path) { group_cluster_path(clusterable, cluster) }
|
|
|
|
let(:cluster) { create(:cluster, :provided_by_gcp, :group, groups: [clusterable]) }
|
2019-03-29 14:23:18 -04:00
|
|
|
|
2019-10-15 02:07:25 -04:00
|
|
|
before do
|
|
|
|
clusterable.add_maintainer(current_user)
|
|
|
|
end
|
|
|
|
|
2020-04-10 11:09:50 -04:00
|
|
|
it_behaves_like 'show page' do
|
|
|
|
let(:cluster_type_label) { 'Group cluster' }
|
|
|
|
end
|
2019-09-20 05:06:17 -04:00
|
|
|
|
|
|
|
it_behaves_like 'editing a GCP cluster'
|
2019-03-29 14:23:18 -04:00
|
|
|
|
|
|
|
it_behaves_like 'editing a user-provided cluster' do
|
|
|
|
let(:cluster) { create(:cluster, :provided_by_user, :group, groups: [clusterable]) }
|
|
|
|
end
|
2019-01-23 11:28:19 -05:00
|
|
|
end
|
2019-10-15 02:07:25 -04:00
|
|
|
|
|
|
|
context 'when clusterable is an instance' do
|
|
|
|
let(:current_user) { create(:admin) }
|
|
|
|
let(:cluster_path) { admin_cluster_path(cluster) }
|
|
|
|
let(:cluster) { create(:cluster, :provided_by_gcp, :instance) }
|
|
|
|
|
2020-11-23 10:09:37 -05:00
|
|
|
before do
|
|
|
|
gitlab_enable_admin_mode_sign_in(current_user)
|
|
|
|
end
|
|
|
|
|
2020-04-10 11:09:50 -04:00
|
|
|
it_behaves_like 'show page' do
|
|
|
|
let(:cluster_type_label) { 'Instance cluster' }
|
|
|
|
end
|
2019-10-15 02:07:25 -04:00
|
|
|
|
|
|
|
it_behaves_like 'editing a GCP cluster'
|
|
|
|
|
|
|
|
it_behaves_like 'editing a user-provided cluster' do
|
|
|
|
let(:cluster) { create(:cluster, :provided_by_user, :instance) }
|
|
|
|
end
|
|
|
|
end
|
2020-10-02 05:08:33 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def expect_common_advanced_options
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_content('Cluster management project')
|
|
|
|
expect(page).to have_content('Clear cluster cache')
|
|
|
|
expect(page).to have_content('Remove Kubernetes cluster integration')
|
|
|
|
end
|
|
|
|
end
|
2019-01-23 11:28:19 -05:00
|
|
|
end
|