View Source SiteEncrypt.Phoenix.Test (site_encrypt v0.6.0)
Helper for testing the certification.
Usage
defmodule MyEndpoint.CertificationTest do
use ExUnit.Case, async: false
import SiteEncrypt.Phoenix.Test
test "certification" do
clean_restart(MyEndpoint)
cert = get_cert(MyEndpoint)
assert cert.domains == ~w/mysite.com www.mysite.com/
end
end
For this to work, you need to use the internal ACME server during tests.
Refer to SiteEncrypt.configure/1
for details.
Also note that this test will restart the endpoint. In addition, it will configure Phoenix to serve the traffic. Therefore, make sure you pick a different set of ports in test, if you want to be able to run the tests while the system is started.
Due to endpoint being restarted, the test case has to be marked as async: false
.
Summary
Functions
Restarts the endpoint, removing all site_encrypt folders in the process.
Obtains the certificate for the given endpoint.
Functions
@spec clean_restart(module()) :: :ok
Restarts the endpoint, removing all site_encrypt folders in the process.
After the restart, the new certificate will be obtained.
Obtains the certificate for the given endpoint.
The certificate is obtained by establishing an SSL connection. Therefore, for this function to
work, the endpoint has to be serving traffic. This will happen if you previously invoked
clean_restart/1
.