This commit is contained in:
2026-08-17 21:20:45 +02:00
parent 321f11e817
commit 6fcdc74843
157 changed files with 2895 additions and 7544 deletions
@@ -2,6 +2,7 @@ package company
import (
"encoding/json"
"strings"
"testing"
)
@@ -101,3 +102,32 @@ func TestLocalizedContentRoundTrip(t *testing.T) {
t.Fatalf("got %#v", f)
}
}
func TestLocalizedContentPublicOmitsEnhanceHash(t *testing.T) {
t.Parallel()
c := LocalizedContent{
"sl": {
ProcessedName: "Naslov",
ProcessedDescription: "Opis",
MetaTitle: "Meta",
EnhanceInputHash: "deadbeef",
},
}
pub := c.Public()
if pub["sl"].EnhanceInputHash != "" {
t.Fatalf("public hash leaked: %#v", pub["sl"])
}
if pub["sl"].ProcessedName != "Naslov" || pub["sl"].MetaTitle != "Meta" {
t.Fatalf("public stripped too much: %#v", pub["sl"])
}
if c["sl"].EnhanceInputHash != "deadbeef" {
t.Fatalf("Public must not mutate storage copy: %#v", c["sl"])
}
b, err := json.Marshal(pub)
if err != nil {
t.Fatal(err)
}
if strings.Contains(string(b), "enhance_input_hash") || strings.Contains(string(b), "deadbeef") {
t.Fatalf("hash in JSON: %s", b)
}
}