70 lines
2.1 KiB
Go
70 lines
2.1 KiB
Go
package pdfcert
|
|
|
|
import (
|
|
"bytes"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestBuildBrandedRegistration(t *testing.T) {
|
|
b, err := Build(Input{
|
|
DocumentName: "Contract.pdf",
|
|
SHA256: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
|
|
ReceiptID: "QmTestReceipt123",
|
|
CreatedAt: "2026-10-03T12:00:00Z",
|
|
Merkle: "113198",
|
|
Scope: "global",
|
|
ByteLength: 4096,
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !bytes.HasPrefix(b, []byte("%PDF")) {
|
|
t.Fatal("not a pdf")
|
|
}
|
|
if len(b) < 5000 {
|
|
t.Fatalf("pdf too small (%d) — logo/qr missing?", len(b))
|
|
}
|
|
s := string(b)
|
|
if strings.Contains(s, "mcp.verae.ai") {
|
|
t.Fatal("must not mention mcp.verae.ai")
|
|
}
|
|
if strings.Contains(s, "via MCP") {
|
|
t.Fatal("must not say via MCP")
|
|
}
|
|
if !strings.Contains(s, "Verae Timestamp Registration Document") {
|
|
t.Fatal("missing title")
|
|
}
|
|
if !strings.Contains(s, "only the digest was submitted") {
|
|
t.Fatal("missing digests-only disclaimer")
|
|
}
|
|
if !strings.Contains(s, "explorer.verae.ai") {
|
|
t.Fatal("expected explorer lookup")
|
|
}
|
|
// Clickable link annotations (jsPDF textWithLink / link, or gofpdf LinkString)
|
|
if !strings.Contains(s, "/URI") && !strings.Contains(s, "/URI(") {
|
|
if !strings.Contains(s, "URI") || !strings.Contains(s, "explorer.verae.ai/time") {
|
|
t.Fatal("expected clickable URI annotation for public lookup URL")
|
|
}
|
|
}
|
|
if !strings.Contains(s, "/time?") || !strings.Contains(s, "QmTestReceipt123") {
|
|
t.Fatal("expected /time? deep link with receipt in PDF")
|
|
}
|
|
}
|
|
|
|
func TestLookupURLNoMCP(t *testing.T) {
|
|
u := LookupURL("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", "QmTestReceipt123")
|
|
if strings.Contains(u, "mcp.verae.ai") {
|
|
t.Fatal(u)
|
|
}
|
|
if !strings.HasPrefix(u, "https://explorer.verae.ai/time?") {
|
|
t.Fatalf("want /time? deep link, got %s", u)
|
|
}
|
|
if !strings.Contains(u, "receipt=QmTestReceipt123") || !strings.Contains(u, "sha256=0123456789abcdef") {
|
|
t.Fatal(u)
|
|
}
|
|
// Must not use the old root query form that the scan bar does not honor
|
|
if strings.Contains(u, "explorer.verae.ai/?sha256=") {
|
|
t.Fatalf("old root URL form: %s", u)
|
|
}
|
|
}
|