summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-11-23 15:24:32 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2018-11-23 15:24:32 +0000
commit9c98e2a9226c5ee0787b2f36c253eef6a03ecb7b (patch)
treea328247746bf4497f0b540028497276ff3226d22 /spec/models
parent52ca66fc54f15641104a8ccc9232baeb7d1f53a1 (diff)
parentc3041b7f7c4b407f1d32ac2f7ab1e21812b40694 (diff)
downloadgitlab-ce-9c98e2a9226c5ee0787b2f36c253eef6a03ecb7b.tar.gz
Merge branch 'certmanager-temp' into 'master'
Deploy cert-manager to managed cluster for SSL certificates See merge request gitlab-org/gitlab-ce!23036
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/clusters/applications/cert_manager_spec.rb79
-rw-r--r--spec/models/clusters/cluster_spec.rb3
2 files changed, 81 insertions, 1 deletions
diff --git a/spec/models/clusters/applications/cert_manager_spec.rb b/spec/models/clusters/applications/cert_manager_spec.rb
new file mode 100644
index 00000000000..170c6001eaf
--- /dev/null
+++ b/spec/models/clusters/applications/cert_manager_spec.rb
@@ -0,0 +1,79 @@
+require 'rails_helper'
+
+describe Clusters::Applications::CertManager do
+ let(:cert_manager) { create(:clusters_applications_cert_managers) }
+
+ include_examples 'cluster application core specs', :clusters_applications_cert_managers
+
+ describe '#make_installing!' do
+ before do
+ application.make_installing!
+ end
+
+ context 'application install previously errored with older version' do
+ let(:application) { create(:clusters_applications_cert_managers, :scheduled, version: 'v0.4.0') }
+
+ it 'updates the application version' do
+ expect(application.reload.version).to eq('v0.5.0')
+ end
+ end
+ end
+
+ describe '#install_command' do
+ let(:cluster_issuer_file) { { "cluster_issuer.yaml": "---\napiVersion: certmanager.k8s.io/v1alpha1\nkind: ClusterIssuer\nmetadata:\n name: letsencrypt-prod\nspec:\n acme:\n server: https://acme-v02.api.letsencrypt.org/directory\n email: admin@example.com\n privateKeySecretRef:\n name: letsencrypt-prod\n http01: {}\n" } }
+ subject { cert_manager.install_command }
+
+ it { is_expected.to be_an_instance_of(Gitlab::Kubernetes::Helm::InstallCommand) }
+
+ it 'should be initialized with cert_manager arguments' do
+ expect(subject.name).to eq('certmanager')
+ expect(subject.chart).to eq('stable/cert-manager')
+ expect(subject.version).to eq('v0.5.0')
+ expect(subject).not_to be_rbac
+ expect(subject.files).to eq(cert_manager.files.merge(cluster_issuer_file))
+ expect(subject.postinstall).to eq(['/usr/bin/kubectl create -f /data/helm/certmanager/config/cluster_issuer.yaml'])
+ end
+
+ context 'for a specific user' do
+ before do
+ cert_manager.email = 'abc@xyz.com'
+ cluster_issuer_file[:'cluster_issuer.yaml'].gsub! 'admin@example.com', 'abc@xyz.com'
+ end
+
+ it 'should use his/her email to register issuer with certificate provider' do
+ expect(subject.files).to eq(cert_manager.files.merge(cluster_issuer_file))
+ end
+ end
+
+ context 'on a rbac enabled cluster' do
+ before do
+ cert_manager.cluster.platform_kubernetes.rbac!
+ end
+
+ it { is_expected.to be_rbac }
+ end
+
+ context 'application failed to install previously' do
+ let(:cert_manager) { create(:clusters_applications_cert_managers, :errored, version: '0.0.1') }
+
+ it 'should be initialized with the locked version' do
+ expect(subject.version).to eq('v0.5.0')
+ end
+ end
+ end
+
+ describe '#files' do
+ let(:application) { cert_manager }
+ let(:values) { subject[:'values.yaml'] }
+
+ subject { application.files }
+
+ it 'should include cert_manager specific keys in the values.yaml file' do
+ expect(values).to include('ingressShim')
+ end
+ end
+
+ describe 'validations' do
+ it { is_expected.to validate_presence_of(:email) }
+ end
+end
diff --git a/spec/models/clusters/cluster_spec.rb b/spec/models/clusters/cluster_spec.rb
index 98d7e799d67..eb68ebccdcb 100644
--- a/spec/models/clusters/cluster_spec.rb
+++ b/spec/models/clusters/cluster_spec.rb
@@ -311,13 +311,14 @@ describe Clusters::Cluster do
context 'when applications are created' do
let!(:helm) { create(:clusters_applications_helm, cluster: cluster) }
let!(:ingress) { create(:clusters_applications_ingress, cluster: cluster) }
+ let!(:cert_manager) { create(:clusters_applications_cert_managers, cluster: cluster) }
let!(:prometheus) { create(:clusters_applications_prometheus, cluster: cluster) }
let!(:runner) { create(:clusters_applications_runner, cluster: cluster) }
let!(:jupyter) { create(:clusters_applications_jupyter, cluster: cluster) }
let!(:knative) { create(:clusters_applications_knative, cluster: cluster) }
it 'returns a list of created applications' do
- is_expected.to contain_exactly(helm, ingress, prometheus, runner, jupyter, knative)
+ is_expected.to contain_exactly(helm, ingress, cert_manager, prometheus, runner, jupyter, knative)
end
end
end