This commit is contained in:
2026-04-25 11:59:10 +08:00
parent e246271a24
commit ba463ae38d
33 changed files with 1600 additions and 112 deletions

View File

@@ -0,0 +1,26 @@
package subordinate
import "testing"
func TestGenerateInviteTokenFormat(t *testing.T) {
raw, hash, err := GenerateInviteToken()
if err != nil {
t.Fatalf("GenerateInviteToken error: %v", err)
}
if len(raw) != inviteTokenLength {
t.Fatalf("unexpected token length: got %d, want %d", len(raw), inviteTokenLength)
}
for _, ch := range raw {
isUpper := ch >= 'A' && ch <= 'Z'
isDigit := ch >= '0' && ch <= '9'
if !isUpper && !isDigit {
t.Fatalf("token contains invalid char: %q", ch)
}
}
if hash != HashInviteToken(raw) {
t.Fatalf("hash mismatch for token")
}
}