Files
HackBrowserData/internal/masterkey/keyfile_test.go
T
Roger 2e7ee3c69f test: tidy misplaced, stale, and redundant tests (#691)
Tests now sit beside the code they cover; ones a golden or another test already pins are gone, and core tests gain the assertions a real regression would trip.
2026-11-09 17:25:37 +08:00

26 lines
741 B
Go

package masterkey
import (
"bytes"
"testing"
)
func TestReadKeyFile_RejectsMissingVersion(t *testing.T) {
input := bytes.NewBufferString(`{"created_at":"2026-05-16T00:00:00Z","host":{"os":"linux","arch":"amd64"},"vaults":[]}`)
_, err := ReadKeyFile(input)
if err == nil {
t.Fatal("ReadKeyFile should reject empty version, got nil error")
}
}
func TestReadKeyFile_AcceptsUnknownKeyVersions(t *testing.T) {
input := bytes.NewBufferString(`{"version":"2","vaults":[{"browser":"chrome","keys":{"v10":"EA==","v99":"AQ=="}}]}`)
keyFile, err := ReadKeyFile(input)
if err != nil {
t.Fatalf("ReadKeyFile: %v", err)
}
if got := keyFile.Vaults[0].Keys[V10]; !bytes.Equal(got, []byte{0x10}) {
t.Errorf("v10 = %x, want 10", got)
}
}