summaryrefslogtreecommitdiff
path: root/spec/views/projects/pages_domains/show.html.haml_spec.rb
blob: da27a04bfe9c26ffe81fbb0362e3e812121cc276 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require 'spec_helper'

describe 'projects/pages_domains/show' do
  let(:project) { create(:project, :repository) }

  before do
    assign(:project, project)
    assign(:domain, domain)
  end

  context 'when auto_ssl is enabled' do
    context 'when domain is disabled' do
      let(:domain) { create(:pages_domain, :disabled, project: project, auto_ssl_enabled: true) }

      it 'shows verification warning' do
        render

        expect(rendered).to have_content("A Let's Encrypt SSL certificate can not be obtained until your domain is verified.")
      end
    end

    context 'when certificate is absent' do
      let(:domain) { create(:pages_domain, :without_key, :without_certificate, project: project, auto_ssl_enabled: true) }

      it 'shows alert about time of obtaining certificate' do
        render

        expect(rendered).to have_content("GitLab is obtaining a Let's Encrypt SSL certificate for this domain. This process can take some time. Please try again later.")
      end
    end

    context 'when certificate is present' do
      let(:domain) { create(:pages_domain, :letsencrypt, project: project) }

      it 'shows certificate info' do
        render

        # test just a random part of cert represenations(X509v3 Subject Key Identifier:)
        expect(rendered).to have_content("C6:5F:56:4B:10:69:AC:1D:33:D2:26:C9:B3:7A:D7:12:4D:3E:F7:90")
      end
    end
  end

  context 'when auto_ssl is disabled' do
    context 'when certificate is present' do
      let(:domain) { create(:pages_domain, project: project) }

      it 'shows certificate info' do
        render

        # test just a random part of cert represenations(X509v3 Subject Key Identifier:)
        expect(rendered).to have_content("C6:5F:56:4B:10:69:AC:1D:33:D2:26:C9:B3:7A:D7:12:4D:3E:F7:90")
      end
    end

    context 'when certificate is absent' do
      let(:domain) { create(:pages_domain, :without_certificate, :without_key, project: project) }

      it 'shows missing certificate' do
        render

        expect(rendered).to have_content("missing")
      end
    end
  end
end