2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
RSpec.shared_examples 'cluster application helm specs' do |application_name|
|
2018-12-13 13:39:08 +05:30
|
|
|
let(:application) { create(application_name) }
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
describe '#uninstall_command' do
|
|
|
|
subject { application.uninstall_command }
|
|
|
|
|
|
|
|
it { is_expected.to be_an_instance_of(Gitlab::Kubernetes::Helm::DeleteCommand) }
|
|
|
|
|
|
|
|
it 'has files' do
|
|
|
|
expect(subject.files).to eq(application.files)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is rbac' do
|
|
|
|
expect(subject).to be_rbac
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'on a non rbac enabled cluster' do
|
|
|
|
before do
|
|
|
|
application.cluster.platform_kubernetes.abac!
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.not_to be_rbac }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
describe '#files' do
|
|
|
|
subject { application.files }
|
|
|
|
|
|
|
|
context 'when the helm application does not have a ca_cert' do
|
|
|
|
before do
|
|
|
|
application.cluster.application_helm.ca_cert = nil
|
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
it 'does not include cert files when there is no ca_cert entry' do
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(subject).not_to include(:'ca.pem', :'cert.pem', :'key.pem')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
it 'includes cert files when there is a ca_cert entry' do
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(subject).to include(:'ca.pem', :'cert.pem', :'key.pem')
|
|
|
|
expect(subject[:'ca.pem']).to eq(application.cluster.application_helm.ca_cert)
|
|
|
|
|
|
|
|
cert = OpenSSL::X509::Certificate.new(subject[:'cert.pem'])
|
|
|
|
expect(cert.not_after).to be < 60.minutes.from_now
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|