Refactor tests
This commit is contained in:
parent
c1c46707ba
commit
d278cfa353
|
@ -8,6 +8,7 @@ defmodule Chronoscope.NTS.CertificateTest do
|
|||
|
||||
setup :verify_on_exit!
|
||||
|
||||
describe "Chronoscope.NTS.Certificate.expiration_date()" do
|
||||
test "parses the expiration date of a certificate" do
|
||||
{:ok, expiration, _} =
|
||||
:secp256r1
|
||||
|
@ -19,7 +20,9 @@ defmodule Chronoscope.NTS.CertificateTest do
|
|||
|
||||
assert DateTime.diff(expiration, DateTime.utc_now(), :day) == 12
|
||||
end
|
||||
end
|
||||
|
||||
describe "Chronoscope.NTS.Certificate.cert_time_to_iso8601()" do
|
||||
test "converts certificate datetime to iso8601" do
|
||||
DateTimeMock
|
||||
|> expect(:utc_now, fn -> ~U[2024-03-31 01:23:45Z] end)
|
||||
|
@ -41,3 +44,4 @@ defmodule Chronoscope.NTS.CertificateTest do
|
|||
assert cert_time_to_iso8601("010326110000Z") == "3001-03-26T11:00:00Z"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,8 +3,10 @@ defmodule Chronoscope.NTS.KeyEstablishmentRequestTest do
|
|||
|
||||
import Chronoscope.NTS.KeyEstablishmentRequest
|
||||
|
||||
describe "Chronoscope.NTS.KeyEstablishmentRequest.create()" do
|
||||
test "builds request" do
|
||||
assert create() ==
|
||||
<<0x80, 0x01, 0x00, 0x02, 0x00, 0x00, 0x80, 0x04, 0x00, 0x04, 0x00, 0x1E, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x00>>
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,7 @@ defmodule Chronoscope.NTS.KeyEstablishmentResponseTest do
|
|||
|
||||
import Chronoscope.NTS.KeyEstablishmentResponse
|
||||
|
||||
describe "Chronoscope.NTS.KeyEstablishmentResponse.parse()" do
|
||||
test "handles empty response" do
|
||||
assert parse([]) == {:ok, %{}}
|
||||
end
|
||||
|
@ -142,3 +143,4 @@ defmodule Chronoscope.NTS.KeyEstablishmentResponseTest do
|
|||
}}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
defmodule ChronoscopeWeb.API.V1.HealthControllerTest do
|
||||
use ChronoscopeWeb.ConnCase, async: true
|
||||
|
||||
test "indicates health", %{conn: conn} do
|
||||
describe "GET /api/v1/health" do
|
||||
test "is healthy", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> get(~p"/api/v1/health")
|
||||
|
@ -10,3 +11,4 @@ defmodule ChronoscopeWeb.API.V1.HealthControllerTest do
|
|||
assert %{"healthy" => true} == response
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ defmodule ChronoscopeWeb.API.V1.NTS.KeyEstablishmentControllerTest do
|
|||
|
||||
setup :verify_on_exit!
|
||||
|
||||
describe "/api/v1/nts/key-establishment" do
|
||||
describe "GET /api/v1/nts/key-establishment" do
|
||||
test "requires a host name", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|
|
Loading…
Reference in New Issue