Implements macOS v0: verae-print stamp + install-macos PDF menu items.
Saves {name}.pdf, {name}-verae-timestamp-{RECEIPTID}.pdf, and .verae.json.
Channels: verae (api.veraetime.net JWT) and zapier (zap.verae.ai xVerae- + attachPdf).
37 lines
819 B
Go
37 lines
819 B
Go
package hash
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestFileSHA256(t *testing.T) {
|
|
dir := t.TempDir()
|
|
p := filepath.Join(dir, "a.pdf")
|
|
if err := os.WriteFile(p, []byte("%PDF-1.4 test"), 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
got, err := FileSHA256(p)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(got) != 64 {
|
|
t.Fatalf("len=%d", len(got))
|
|
}
|
|
again, err := FileSHA256(p)
|
|
if err != nil || again != got {
|
|
t.Fatalf("not deterministic: %v %s vs %s", err, got, again)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeDigest(t *testing.T) {
|
|
const hex64 = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
|
|
got, err := NormalizeDigest("SHA256:" + hex64)
|
|
if err != nil || got != hex64 {
|
|
t.Fatalf("got %q err %v", got, err)
|
|
}
|
|
if _, err := NormalizeDigest("short"); err == nil {
|
|
t.Fatal("expected error")
|
|
}
|
|
}
|