simpleadmin-web 0.1.0: web panel for CS2-SimpleAdmin

This commit is contained in:
Astra 2026-09-25 20:08:14 +01:00
commit 4f38daf0e6
31 changed files with 6870 additions and 0 deletions

View file

@ -0,0 +1,35 @@
package steam
import (
"testing"
"time"
)
func TestValidID(t *testing.T) {
for id, want := range map[string]bool{
"76561198012345601": true,
"76561197960265728": false, // account 0
"7656119801234560": false,
"76561198012345601 ": false,
"86561198012345601": false,
"7656119801234560a": false,
} {
if got := ValidID(id); got != want {
t.Errorf("ValidID(%q) = %v", id, got)
}
}
}
func TestNonce(t *testing.T) {
fresh := time.Now().UTC().Format(time.RFC3339) + "abc"
if err := checkNonce(fresh); err != nil {
t.Fatal(err)
}
old := time.Now().Add(-10*time.Minute).UTC().Format(time.RFC3339) + "abc"
if checkNonce(old) == nil {
t.Fatal("old nonce accepted")
}
if !seen.claim(fresh) || seen.claim(fresh) {
t.Fatal("nonce replay not caught")
}
}