906 B · text History 4b6fe3b
defmodule OhMyExOhIrcd.TLSModeTest do
  @moduledoc """
  Sanity checks for the `:tls_mode` compile-time flag.
  """

  use ExUnit.Case, async: true

  test "endpoint exposes its compile-time tls_mode" do
    assert OhMyExOhIrcdWeb.Endpoint.__tls_mode__() in [:standalone, :kubernetes]
  end

  test "SiteEncrypt callbacks exist iff in standalone mode" do
    standalone? = OhMyExOhIrcdWeb.Endpoint.__tls_mode__() == :standalone

    assert function_exported?(OhMyExOhIrcdWeb.Endpoint, :certification, 0) == standalone?
    assert function_exported?(OhMyExOhIrcdWeb.Endpoint, :handle_new_cert, 0) == standalone?
  end

  test "standalone build returns a valid certification config" do
    if OhMyExOhIrcdWeb.Endpoint.__tls_mode__() == :standalone do
      cfg = OhMyExOhIrcdWeb.Endpoint.certification()
      assert is_map(cfg)
      assert cfg.domains != []
      assert cfg.emails != []
    end
  end
end