Commit b79c4c8e authored by Vladimir Shushlin's avatar Vladimir Shushlin

Add failed auto ssl mailer notification

Also refactor specs a bit
parent 0f9003c7
......@@ -41,5 +41,16 @@ module Emails
subject: subject("ACTION REQUIRED: Verification failed for GitLab Pages domain '#{domain.domain}'")
)
end
def pages_domain_auto_ssl_failed_email(domain, recipient)
@domain = domain
@project = domain.project
subject_text = _("ACTION REQUIRED: Something went wrong while obtaining Let's Encrypt certificate for GitLab Pages domain '%{domain}'") % { domain: domain.domain }
mail(
to: recipient.notification_email_for(@project.group),
subject: subject(subject_text)
)
end
end
end
%p
= _("Something went wrong while obtaining the Let's Encrypt certificate.")
%p
#{_('Project')}: #{link_to @project.human_name, project_url(@project)}
%p
#{_('Domain')}: #{link_to @domain.domain, project_pages_domain_url(@project, @domain)}
%p
- docs_url = help_page_url('user/project/pages/custom_domains_ssl_tls_certification/lets_encrypt_integration.md', anchor: 'troubleshooting')
- link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: docs_url }
- link_end = '</a>'.html_safe
= _("Please follow the %{link_start}Let\'s Encrypt troubleshooting instructions%{link_end} to re-obtain your Let's Encrypt certificate.").html_safe % { link_start: link_start, link_end: link_end }
= _("Something went wrong while obtaining the Let's Encrypt certificate.")
#{_('Project')}: #{link_to @project.human_name, project_url(@project)}
#{_('Domain')}: #{link_to @domain.domain, project_pages_domain_url(@project, @domain)}
- docs_url = help_page_url('user/project/pages/custom_domains_ssl_tls_certification/lets_encrypt_integration.md', anchor: 'troubleshooting')
- link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: docs_url }
- link_end = '</a>'.html_safe
= _("Please follow the %{link_start}Let\'s Encrypt troubleshooting instructions%{link_end} to re-obtain your Let's Encrypt certificate.").html_safe % { link_start: link_start, link_end: link_end }
......@@ -23,13 +23,20 @@ describe Emails::PagesDomains do
is_expected.to have_subject(email_subject)
is_expected.to have_body_text(project.human_name)
is_expected.to have_body_text(domain.domain)
is_expected.to have_body_text domain.url
is_expected.to have_body_text project_pages_domain_url(project, domain)
is_expected.to have_body_text help_page_url('user/project/pages/custom_domains_ssl_tls_certification/index.md', anchor: link_anchor)
end
end
end
shared_examples 'a pages domain verification email' do
it_behaves_like 'a pages domain email'
it 'has the expected content' do
is_expected.to have_body_text domain.url
is_expected.to have_body_text help_page_url('user/project/pages/custom_domains_ssl_tls_certification/index.md', anchor: link_anchor)
end
end
shared_examples 'notification about upcoming domain removal' do
context 'when domain is not scheduled for removal' do
it 'asks user to remove it' do
......@@ -56,7 +63,7 @@ describe Emails::PagesDomains do
subject { Notify.pages_domain_enabled_email(domain, user) }
it_behaves_like 'a pages domain email'
it_behaves_like 'a pages domain verification email'
it { is_expected.to have_body_text 'has been enabled' }
end
......@@ -67,7 +74,7 @@ describe Emails::PagesDomains do
subject { Notify.pages_domain_disabled_email(domain, user) }
it_behaves_like 'a pages domain email'
it_behaves_like 'a pages domain verification email'
it_behaves_like 'notification about upcoming domain removal'
......@@ -80,7 +87,7 @@ describe Emails::PagesDomains do
subject { Notify.pages_domain_verification_succeeded_email(domain, user) }
it_behaves_like 'a pages domain email'
it_behaves_like 'a pages domain verification email'
it { is_expected.to have_body_text 'successfully verified' }
end
......@@ -94,10 +101,18 @@ describe Emails::PagesDomains do
it_behaves_like 'a pages domain email'
it_behaves_like 'notification about upcoming domain removal'
end
describe '#pages_domain_auto_ssl_failed_email' do
let(:email_subject) { "#{project.path} | ACTION REQUIRED: Something went wrong while obtaining Let's Encrypt certificate for GitLab Pages domain '#{domain.domain}'" }
subject { Notify.pages_domain_auto_ssl_failed_email(domain, user) }
it_behaves_like 'a pages domain email'
it 'says verification has failed and when the domain is enabled until' do
is_expected.to have_body_text 'Verification has failed'
is_expected.to have_body_text domain.enabled_until.strftime('%F %T')
it 'says that we failed to obtain certificate' do
is_expected.to have_body_text "Something went wrong while obtaining the Let's Encrypt certificate."
is_expected.to have_body_text help_page_url('user/project/pages/custom_domains_ssl_tls_certification/lets_encrypt_integration.md', anchor: 'troubleshooting')
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