diff options
author | Vladimir Shushlin <vshushlin@gitlab.com> | 2019-06-24 23:35:12 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-06-24 23:35:12 +0300 |
commit | a7764d0e845db524f2913b6c11c88dfd121ec522 (patch) | |
tree | 8e84742f692e05e56102b7cfd7d20462ba1c8305 /spec/workers | |
parent | bf8f5b8f446c504ca13ef2a8cf28cc3faeaf3253 (diff) |
Renew Let's Encrypt certificates
Add index for pages domain ssl auto renewal
Add PagesDomain.needs_ssl_renewal scope
Add cron worker for ssl renewal
Add worker for ssl renewal
Add pages ssl renewal worker queues settings
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb | 59 | ||||
-rw-r--r-- | spec/workers/pages_domain_ssl_renewal_worker_spec.rb | 35 |
2 files changed, 94 insertions, 0 deletions
diff --git a/spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb b/spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb new file mode 100644 index 00000000000..2ae4872f51d --- /dev/null +++ b/spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe PagesDomainSslRenewalCronWorker do + include LetsEncryptHelpers + + subject(:worker) { described_class.new } + + before do + stub_lets_encrypt_settings + end + + describe '#perform' do + let!(:domain) { create(:pages_domain) } + let!(:domain_with_enabled_auto_ssl) { create(:pages_domain, auto_ssl_enabled: true) } + let!(:domain_with_obtained_letsencrypt) { create(:pages_domain, :letsencrypt, auto_ssl_enabled: true) } + let!(:domain_without_auto_certificate) do + create(:pages_domain, :without_certificate, :without_key, auto_ssl_enabled: true) + end + + let!(:domain_with_expired_auto_ssl) do + create(:pages_domain, :letsencrypt, :with_expired_certificate) + end + + it 'enqueues a PagesDomainSslRenewalWorker for domains needing renewal' do + [domain_without_auto_certificate, + domain_with_enabled_auto_ssl, + domain_with_expired_auto_ssl].each do |domain| + expect(PagesDomainSslRenewalWorker).to receive(:perform_async).with(domain.id) + end + + [domain, + domain_with_obtained_letsencrypt].each do |domain| + expect(PagesDomainVerificationWorker).not_to receive(:perform_async).with(domain.id) + end + + worker.perform + end + + shared_examples 'does nothing' do + it 'does nothing' do + expect(PagesDomainSslRenewalWorker).not_to receive(:perform_async) + + worker.perform + end + end + + context 'when letsencrypt integration is disabled' do + before do + stub_application_setting( + lets_encrypt_terms_of_service_accepted: false + ) + end + + include_examples 'does nothing' + end + end +end diff --git a/spec/workers/pages_domain_ssl_renewal_worker_spec.rb b/spec/workers/pages_domain_ssl_renewal_worker_spec.rb new file mode 100644 index 00000000000..a3d33de1b40 --- /dev/null +++ b/spec/workers/pages_domain_ssl_renewal_worker_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe PagesDomainSslRenewalWorker do + include LetsEncryptHelpers + + subject(:worker) { described_class.new } + + let(:domain) { create(:pages_domain) } + + before do + stub_lets_encrypt_settings + end + + describe '#perform' do + it 'delegates to ObtainLetsEncryptCertificateService' do + service = double(:service) + expect(::PagesDomains::ObtainLetsEncryptCertificateService).to receive(:new).with(domain).and_return(service) + expect(service).to receive(:execute) + + worker.perform(domain.id) + end + + context 'when domain was deleted' do + before do + domain.destroy! + end + + it 'does nothing' do + expect(::PagesDomains::ObtainLetsEncryptCertificateService).not_to receive(:new) + end + end + end +end |