tka,ipn: reduce boilerplate in Tailnet Lock tests

The `CreateStateForTest` helper reduces boilerplate in cases where the test
only cares about the trusted keys and not the disablement values (and makes
it more obvious where the disablement values are meaningful).

The `setupChonkStorage` helper reduces the boilerplate when creating on-disk
TKA storage in tests.

The `fakeLocalBackend` helper reduces the boilerplate when setting up a
`LocalBackend` instance in the IPN tests.

Updates #cleanup

Change-Id: Iacfba1be5f7fab208eec11e4369d63c7d7519da5
Signed-off-by: Alex Chan <alexc@tailscale.com>
This commit is contained in:
Alex Chan
2026-04-30 12:32:22 +01:00
committed by Alex Chan
parent 495d3acc7b
commit d6ffc0d986
8 changed files with 126 additions and 273 deletions
+2 -5
View File
@@ -22,15 +22,12 @@ func TestHandleC2NDebugTKA(t *testing.T) {
return nil, nil
}
disablementSecret := bytes.Repeat([]byte{0xa5}, 32)
signerKey := key.NewNLPrivate()
key1 := tka.Key{Kind: tka.Key25519, Public: signerKey.Public().Verifier(), Votes: 2}
state := tka.CreateStateForTest(key1)
chonk := tka.ChonkMem()
authority, _, err := tka.Create(chonk, tka.State{
Keys: []tka.Key{key1},
DisablementValues: [][]byte{tka.DisablementKDF(disablementSecret)},
}, signerKey)
authority, _, err := tka.Create(chonk, state, signerKey)
if err != nil {
t.Fatalf("tka.Create() failed: %v", err)
}