summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/models/cluster_application_helm_cert_examples.rb
blob: d87b3181e80bfaa4ec2d0ea612b7bde1a5b79e76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
shared_examples 'cluster application helm specs' do |application_name|
  let(:application) { create(application_name) }

  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

      it 'should not include cert files when there is no ca_cert entry' do
        expect(subject).not_to include(:'ca.pem', :'cert.pem', :'key.pem')
      end
    end

    it 'should include cert files when there is a ca_cert entry' do
      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