Files
felhom.eu/hub/internal/configgen/passphrase_test.go
T
admin 1f05f9f866 hub: use Hungarian word passphrases for retrieval passwords
Replace 64-char hex retrieval passwords with 5-word Hungarian
passphrases (e.g. áldás-plazmid-palánta-süvítve-pócgém) for
better UX in disaster recovery scenarios. Embed 29K+ word list
via go:embed. API keys remain hex.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 14:31:39 +01:00

53 lines
1.0 KiB
Go

package configgen
import (
"fmt"
"strings"
"testing"
)
func TestWordListNoDuplicates(t *testing.T) {
seen := make(map[string]bool, len(wordList))
for i, w := range wordList {
if seen[w] {
t.Errorf("duplicate word %q at index %d", w, i)
}
seen[w] = true
}
t.Logf("Total unique words: %d", len(seen))
}
func TestWordListSize(t *testing.T) {
if len(wordList) < 10000 {
t.Errorf("word list too small: %d (want >= 10000)", len(wordList))
}
t.Logf("Word list size: %d", len(wordList))
}
func TestRandomPassphrase(t *testing.T) {
p, err := RandomPassphrase(5)
if err != nil {
t.Fatal(err)
}
parts := strings.Split(p, "-")
if len(parts) != 5 {
t.Errorf("expected 5 words, got %d: %s", len(parts), p)
}
for _, word := range parts {
if word == "" {
t.Error("empty word in passphrase")
}
}
t.Logf("Sample passphrase: %s", p)
}
func TestRandomPassphraseSamples(t *testing.T) {
for i := 0; i < 5; i++ {
p, err := RandomPassphrase(5)
if err != nil {
t.Fatal(err)
}
fmt.Printf(" Sample %d: %s\n", i+1, p)
}
}