2019-03-02 22:35:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'Clusterable > Show page' 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
|
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
it 'allow the user to set domain' do
|
|
|
|
visit cluster_path
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
within '.js-cluster-integration-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.status_code).to eq(200)
|
|
|
|
expect(page).to have_content('Kubernetes cluster was successfully updated.')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there is a cluster with ingress and external ip' do
|
|
|
|
before do
|
|
|
|
cluster.create_application_ingress!(external_ip: '192.168.1.100')
|
|
|
|
|
|
|
|
visit cluster_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows help text with the domain as an alternative to custom domain' do
|
2020-04-08 14:13:33 +05:30
|
|
|
within '.js-cluster-integration-form' do
|
2019-07-07 11:18:12 +05:30
|
|
|
expect(find(cluster_ingress_help_text_selector)).not_to match_css(hide_modifier_selector)
|
2019-03-02 22:35:43 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there is no ingress' do
|
|
|
|
it 'alternative to custom domain is not shown' do
|
|
|
|
visit cluster_path
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
within '.js-cluster-integration-form' do
|
2019-07-07 11:18:12 +05:30
|
|
|
expect(find(cluster_ingress_help_text_selector)).to match_css(hide_modifier_selector)
|
2019-03-02 22:35:43 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
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-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')
|
|
|
|
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')
|
|
|
|
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) }
|
|
|
|
|
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
|
2019-03-02 22:35:43 +05:30
|
|
|
end
|