2019-03-02 22:35:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
RSpec.describe 'Clusterable > Show page', feature_category: :deployment_management do
|
2019-09-04 21:01:54 +05:30
|
|
|
include KubernetesHelpers
|
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
let(:current_user) { create(:user) }
|
2019-07-07 11:18:12 +05:30
|
|
|
let(:cluster_ingress_help_text_selector) { '.js-ingress-domain-help-text' }
|
|
|
|
let(:hide_modifier_selector) { '.hide' }
|
2019-03-02 22:35:43 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(current_user)
|
|
|
|
end
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
shared_examples 'show page' do
|
2020-04-22 19:07:51 +05:30
|
|
|
it 'displays cluster type label' do
|
|
|
|
visit cluster_path
|
|
|
|
|
|
|
|
expect(page).to have_content(cluster_type_label)
|
|
|
|
end
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it 'allow the user to set domain', :js do
|
2019-03-02 22:35:43 +05:30
|
|
|
visit cluster_path
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
within '.js-cluster-details-form' do
|
2019-03-02 22:35:43 +05:30
|
|
|
fill_in('cluster_base_domain', with: 'test.com')
|
|
|
|
click_on 'Save changes'
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content('Kubernetes cluster was successfully updated.')
|
|
|
|
end
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
it 'does not show the environments tab' do
|
|
|
|
visit cluster_path
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
expect(page).not_to have_selector('[data-testid="cluster-environments-tab"]')
|
2019-12-04 20:38:33 +05:30
|
|
|
end
|
2019-03-02 22:35:43 +05:30
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
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-04-08 14:13:33 +05:30
|
|
|
within('.js-provider-details') do
|
2019-07-07 11:18:12 +05:30
|
|
|
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-04-08 14:13:33 +05:30
|
|
|
click_link 'Advanced Settings'
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
within('#advanced-settings-section') do
|
|
|
|
expect(page).to have_content('Google Kubernetes Engine')
|
|
|
|
expect(page).to have_content('Manage your Kubernetes cluster by visiting')
|
2021-01-03 14:25:43 +05:30
|
|
|
expect_common_advanced_options
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples 'editing a user-provided cluster' do
|
|
|
|
before do
|
2019-09-04 21:01:54 +05:30
|
|
|
stub_kubeclient_discover(cluster.platform.api_url)
|
2019-07-07 11:18:12 +05:30
|
|
|
visit cluster_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is able to edit the name, API url, CA certificate and token' do
|
2020-04-08 14:13:33 +05:30
|
|
|
within('.js-provider-details') do
|
2019-07-07 11:18:12 +05:30
|
|
|
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-04-08 14:13:33 +05:30
|
|
|
click_link 'Advanced Settings'
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
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')
|
2021-01-03 14:25:43 +05:30
|
|
|
expect_common_advanced_options
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
context 'when clusterable is a project' do
|
2019-12-04 20:38:33 +05:30
|
|
|
let(:clusterable) { create(:project) }
|
|
|
|
let(:cluster_path) { project_cluster_path(clusterable, cluster) }
|
|
|
|
let(:cluster) { create(:cluster, :provided_by_gcp, :project, projects: [clusterable]) }
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
before do
|
|
|
|
clusterable.add_maintainer(current_user)
|
|
|
|
end
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
it_behaves_like 'show page' do
|
|
|
|
let(:cluster_type_label) { 'Project cluster' }
|
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
it_behaves_like 'editing a GCP cluster'
|
2019-07-07 11:18:12 +05:30
|
|
|
|
|
|
|
it_behaves_like 'editing a user-provided cluster' do
|
|
|
|
let(:cluster) { create(:cluster, :provided_by_user, :project, projects: [clusterable]) }
|
|
|
|
end
|
2019-03-02 22:35:43 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'when clusterable is a group' do
|
2019-12-04 20:38:33 +05:30
|
|
|
let(:clusterable) { create(:group) }
|
|
|
|
let(:cluster_path) { group_cluster_path(clusterable, cluster) }
|
|
|
|
let(:cluster) { create(:cluster, :provided_by_gcp, :group, groups: [clusterable]) }
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
before do
|
|
|
|
clusterable.add_maintainer(current_user)
|
|
|
|
end
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
it_behaves_like 'show page' do
|
|
|
|
let(:cluster_type_label) { 'Group cluster' }
|
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
it_behaves_like 'editing a GCP cluster'
|
2019-07-07 11:18:12 +05:30
|
|
|
|
|
|
|
it_behaves_like 'editing a user-provided cluster' do
|
|
|
|
let(:cluster) { create(:cluster, :provided_by_user, :group, groups: [clusterable]) }
|
|
|
|
end
|
2019-03-02 22:35:43 +05:30
|
|
|
end
|
2019-12-21 20:55:43 +05:30
|
|
|
|
|
|
|
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) }
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
before do
|
|
|
|
gitlab_enable_admin_mode_sign_in(current_user)
|
|
|
|
end
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
it_behaves_like 'show page' do
|
|
|
|
let(:cluster_type_label) { 'Instance cluster' }
|
|
|
|
end
|
2019-12-21 20:55:43 +05:30
|
|
|
|
|
|
|
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
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
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-03-02 22:35:43 +05:30
|
|
|
end
|