debian-mirror-gitlab/spec/models/clusters/applications/helm_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

113 lines
3 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
require 'spec_helper'
2018-03-17 18:26:18 +05:30
2020-07-28 23:09:34 +05:30
RSpec.describe Clusters::Applications::Helm do
2018-03-27 19:54:05 +05:30
include_examples 'cluster application core specs', :clusters_applications_helm
2018-03-17 18:26:18 +05:30
2019-07-07 11:18:12 +05:30
describe '.available' do
subject { described_class.available }
2018-05-09 12:01:36 +05:30
2018-11-18 11:00:15 +05:30
let!(:installed_cluster) { create(:clusters_applications_helm, :installed) }
2019-07-07 11:18:12 +05:30
let!(:updated_cluster) { create(:clusters_applications_helm, :updated) }
2018-05-09 12:01:36 +05:30
before do
create(:clusters_applications_helm, :errored)
end
2019-07-07 11:18:12 +05:30
it { is_expected.to contain_exactly(installed_cluster, updated_cluster) }
2018-11-18 11:00:15 +05:30
end
2019-07-31 22:56:46 +05:30
describe '#can_uninstall?' do
2021-02-22 17:27:13 +05:30
subject(:application) { build(:clusters_applications_helm).can_uninstall? }
2019-10-12 21:52:04 +05:30
2021-02-22 17:27:13 +05:30
it { is_expected.to eq true }
2019-07-31 22:56:46 +05:30
end
2018-11-18 11:00:15 +05:30
describe '#issue_client_cert' do
let(:application) { create(:clusters_applications_helm) }
2020-03-13 15:44:24 +05:30
2018-11-18 11:00:15 +05:30
subject { application.issue_client_cert }
it 'returns a new cert' do
2021-01-29 00:20:46 +05:30
is_expected.to be_kind_of(Gitlab::Kubernetes::Helm::V2::Certificate)
2018-11-18 11:00:15 +05:30
expect(subject.cert_string).not_to eq(application.ca_cert)
expect(subject.key_string).not_to eq(application.ca_key)
end
2018-05-09 12:01:36 +05:30
end
2018-03-17 18:26:18 +05:30
describe '#install_command' do
2018-03-27 19:54:05 +05:30
let(:helm) { create(:clusters_applications_helm) }
2018-03-17 18:26:18 +05:30
2018-03-27 19:54:05 +05:30
subject { helm.install_command }
2018-03-17 18:26:18 +05:30
2021-01-29 00:20:46 +05:30
it { is_expected.to be_an_instance_of(Gitlab::Kubernetes::Helm::V2::InitCommand) }
2018-03-17 18:26:18 +05:30
2019-07-07 11:18:12 +05:30
it 'is initialized with 1 arguments' do
2018-03-27 19:54:05 +05:30
expect(subject.name).to eq('helm')
2018-03-17 18:26:18 +05:30
end
2018-11-18 11:00:15 +05:30
2019-07-07 11:18:12 +05:30
it 'has cert files' do
2018-11-18 11:00:15 +05:30
expect(subject.files[:'ca.pem']).to be_present
expect(subject.files[:'ca.pem']).to eq(helm.ca_cert)
expect(subject.files[:'cert.pem']).to be_present
expect(subject.files[:'key.pem']).to be_present
cert = OpenSSL::X509::Certificate.new(subject.files[:'cert.pem'])
expect(cert.not_after).to be > 999.years.from_now
end
2018-11-20 20:47:30 +05:30
describe 'rbac' do
2019-02-15 15:39:39 +05:30
context 'rbac cluster' do
it { expect(subject).to be_rbac }
2018-11-20 20:47:30 +05:30
end
2019-02-15 15:39:39 +05:30
context 'non rbac cluster' do
2018-11-20 20:47:30 +05:30
before do
2019-02-15 15:39:39 +05:30
helm.cluster.platform_kubernetes.abac!
2018-11-20 20:47:30 +05:30
end
2019-02-15 15:39:39 +05:30
it { expect(subject).not_to be_rbac }
2018-11-20 20:47:30 +05:30
end
end
2018-03-17 18:26:18 +05:30
end
2019-10-12 21:52:04 +05:30
describe '#uninstall_command' do
let(:helm) { create(:clusters_applications_helm) }
subject { helm.uninstall_command }
2021-01-29 00:20:46 +05:30
it { is_expected.to be_an_instance_of(Gitlab::Kubernetes::Helm::V2::ResetCommand) }
2019-10-12 21:52:04 +05:30
it 'has name' do
expect(subject.name).to eq('helm')
end
it 'has cert files' do
expect(subject.files[:'ca.pem']).to be_present
expect(subject.files[:'ca.pem']).to eq(helm.ca_cert)
expect(subject.files[:'cert.pem']).to be_present
expect(subject.files[:'key.pem']).to be_present
cert = OpenSSL::X509::Certificate.new(subject.files[:'cert.pem'])
expect(cert.not_after).to be > 999.years.from_now
end
describe 'rbac' do
context 'rbac cluster' do
it { expect(subject).to be_rbac }
end
context 'non rbac cluster' do
before do
helm.cluster.platform_kubernetes.abac!
end
it { expect(subject).not_to be_rbac }
end
end
end
2018-03-17 18:26:18 +05:30
end