9bb4b09a04
CI / Lint + build + test (push) Has been cancelled
Post-repair hardware validation pipeline for Proxmox cluster hosts. Go orchestrator + in-image agent + mkosi live image + bundled dnsmasq PXE + SQLite + HTMX/SSE UI + notify registry + janitor + full docs.
39 lines
900 B
Go
39 lines
900 B
Go
package orchestrator
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestIssueRunTokenRoundTrip(t *testing.T) {
|
|
plain, hash, err := IssueRunToken()
|
|
if err != nil {
|
|
t.Fatalf("IssueRunToken: %v", err)
|
|
}
|
|
if len(plain) != 64 {
|
|
t.Fatalf("plaintext should be 64 hex chars, got %d", len(plain))
|
|
}
|
|
if len(hash) != 64 {
|
|
t.Fatalf("hash should be 64 hex chars, got %d", len(hash))
|
|
}
|
|
if HashRunToken(plain) != hash {
|
|
t.Fatalf("HashRunToken(plain) != hash")
|
|
}
|
|
// Ensure high entropy: two consecutive issues differ.
|
|
plain2, _, _ := IssueRunToken()
|
|
if plain == plain2 {
|
|
t.Fatalf("expected distinct tokens on consecutive calls")
|
|
}
|
|
}
|
|
|
|
func TestHashRunTokenDeterministic(t *testing.T) {
|
|
h1 := HashRunToken("abc")
|
|
h2 := HashRunToken("abc")
|
|
if h1 != h2 {
|
|
t.Fatalf("hash not deterministic")
|
|
}
|
|
if strings.EqualFold(h1, HashRunToken("abd")) {
|
|
t.Fatalf("hash should differ for distinct inputs")
|
|
}
|
|
}
|