Commit b8ff11ba authored by Vladimir Shushlin's avatar Vladimir Shushlin

Save auto_ssl_failed if acme order is invalid

parent b6b8ee4e
...@@ -36,8 +36,8 @@ module PagesDomains ...@@ -36,8 +36,8 @@ module PagesDomains
when 'valid' when 'valid'
save_certificate(acme_order.private_key, api_order) save_certificate(acme_order.private_key, api_order)
acme_order.destroy! acme_order.destroy!
# when 'invalid' when 'invalid'
# TODO: implement error handling save_order_error(acme_order)
end end
end end
...@@ -47,5 +47,12 @@ module PagesDomains ...@@ -47,5 +47,12 @@ module PagesDomains
certificate = api_order.certificate certificate = api_order.certificate
pages_domain.update!(gitlab_provided_key: private_key, gitlab_provided_certificate: certificate) pages_domain.update!(gitlab_provided_key: private_key, gitlab_provided_certificate: certificate)
end end
def save_order_error(acme_order)
return unless Feature.enabled?(:pages_letsencrypt_errors, pages_domain.project)
acme_order.pages_domain.update_column(:auto_ssl_failed, true)
acme_order.destroy!
end
end end
end end
...@@ -163,4 +163,22 @@ describe PagesDomains::ObtainLetsEncryptCertificateService do ...@@ -163,4 +163,22 @@ describe PagesDomains::ObtainLetsEncryptCertificateService do
expect(PagesDomainAcmeOrder.find_by_id(existing_order.id)).to be_nil expect(PagesDomainAcmeOrder.find_by_id(existing_order.id)).to be_nil
end end
end end
context 'when order is invalid' do
let(:existing_order) do
create(:pages_domain_acme_order, pages_domain: pages_domain)
end
let!(:api_order) do
stub_lets_encrypt_order(existing_order.url, 'invalid')
end
it 'saves error to domain and deletes acme order' do
expect do
service.execute
end.to change { pages_domain.reload.auto_ssl_failed }.from(false).to(true)
expect(PagesDomainAcmeOrder.find_by_id(existing_order.id)).to be_nil
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment