Skip to content

Commit 120ff73

Browse files
committed
test(s024): mode-aware expectations for the fips leg; the peer assertion names the owner
Run 35542450360: the fips leg selects P-384 and the signer, boot and chain tests named Ed25519 (the earlier edit never landed); the peer assertion found a TLS connection on the runners this machine does not open and said nothing about its owner. Signed-off-by: Ayla Croft <aylacroft@proton.me>
1 parent a0ef284 commit 120ff73

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

‎test/trinity/effects/boot_receipt_test.exs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ defmodule Trinity.Effects.BootReceiptTest do
1818

1919
assert is_binary(sig)
2020
assert r.subject["authority"] == "Trinity.Authority.Local"
21-
assert r.subject["signer"]["algorithm"] == "ed25519"
22-
assert r.subject["signer"]["key_id"] == Receipts.KeyCustody.selected().key_id
23-
assert r.subject["fips"] == "not_supported"
21+
selected = Receipts.KeyCustody.selected()
22+
assert r.subject["signer"]["algorithm"] == Atom.to_string(selected.algorithm)
23+
assert r.subject["signer"]["key_id"] == selected.key_id
24+
assert r.subject["fips"] == Atom.to_string(:crypto.info_fips())
2425
assert r.meta["core_policy_hash"] == CorePolicy.hash()
2526
assert r.meta["canonicalization_version"] == 1
2627
body = JSON.decode!(r.signed_payload)

‎test/trinity/receipts/signer_test.exs‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ defmodule Trinity.Receipts.SignerTest do
5858
end
5959

6060
describe "selection" do
61-
test "outside FIPS mode the default is Ed25519, and in FIPS mode it would be P-384" do
62-
assert :crypto.info_fips() != :enabled
63-
assert {:ok, :ed25519} = KeyCustody.select()
61+
test "outside FIPS mode the default is Ed25519; in FIPS mode (the fips leg) it is P-384" do
62+
expected = if :crypto.info_fips() == :enabled, do: :p384, else: :ed25519
63+
assert {:ok, ^expected} = KeyCustody.select()
6464
end
6565

6666
test "a configured ML-DSA-87 is refused where the runtime lacks it, naming the algorithm" do
@@ -77,13 +77,17 @@ defmodule Trinity.Receipts.SignerTest do
7777
describe "custody" do
7878
test "boot generates the key once (0600), appends its registry row, and a second boot reuses it",
7979
%{dir: dir} do
80-
assert {:ok, %{algorithm: :ed25519, key_id: key_id, key_path: path}} = KeyCustody.boot!(dir)
80+
{:ok, expected} = KeyCustody.select()
81+
82+
assert {:ok, %{algorithm: ^expected, key_id: key_id, key_path: path}} =
83+
KeyCustody.boot!(dir)
84+
8185
assert File.exists?(path)
8286
assert File.stat!(path).mode |> Bitwise.band(0o777) == 0o600
8387
assert {:ok, [row]} = KeyRegistry.read(dir)
8488
assert row["key_id"] == key_id
85-
assert row["algorithm"] == "ed25519"
86-
assert row["scheme"] == "receipt_v2_ed25519"
89+
assert row["algorithm"] == Atom.to_string(expected)
90+
assert row["scheme"] == Signer.impl(expected).scheme()
8791
assert row["kid_scheme"] == "rfc7638"
8892
assert row["status"] == "active"
8993
assert key_id == Signer.thumbprint(row["jwk"])

0 commit comments

Comments
 (0)