Files
Privatae e4c9b69b46
ci / personal-data (push) Successful in 5s
ci / test (push) Successful in 3m4s
ci / fuzz (push) Successful in 3m45s
bastion 0.53.2
2026-10-20 04:42:14 +00:00

23 lines
616 B
Go

package main
import "testing"
func TestValidHostName(t *testing.T) {
good := []string{"entity-9001.host.example", "entity-9002.host.example", "a.b.c"}
for _, h := range good {
if !validHostName(h) {
t.Errorf("validHostName(%q) = false, want true", h)
}
}
// Traversal / clobber attempts a hostile redeem response could send.
bad := []string{
"", "../../evil", "pairings/../pairings/entity-9001.host.example",
"a/b", "..", ".hidden", "trailing.", "has space", "semi;colon",
}
for _, h := range bad {
if validHostName(h) {
t.Errorf("validHostName(%q) = true, want false (unsafe)", h)
}
}
}