Root sets GroupVerify's clan_tag (the scoreboard tag CS2-Tags gives verified players without a rank) next to the Steam group. Validated like the plugin (12 UTF-16 units, no quotes, ; or \), saved to gv_settings and sent as css_gv_clantag when the plugin is loaded. Only changed fields are sent. GroupVerify 0.3.0 checks players with the Steam Web API as they join, so the group list is now "Confirmed group members" with first/last confirmed dates.
63 lines
1.8 KiB
Go
63 lines
1.8 KiB
Go
package web
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.zio.sh/cs2/simpleadmin-web/internal/live"
|
|
"git.zio.sh/cs2/simpleadmin-web/internal/store"
|
|
)
|
|
|
|
func TestIsClanID(t *testing.T) {
|
|
for _, c := range []struct {
|
|
id uint64
|
|
want bool
|
|
}{
|
|
{103582791429521412, true}, // a group
|
|
{103582791429521408, false}, // account 0
|
|
{76561198012345678, false}, // a player
|
|
{0, false},
|
|
} {
|
|
if got := isClanID(c.id); got != c.want {
|
|
t.Errorf("isClanID(%d) = %v, want %v", c.id, got, c.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestValidClanTag(t *testing.T) {
|
|
for tag, want := range map[string]bool{
|
|
"": true,
|
|
"zio": true,
|
|
"zio.sh": true,
|
|
"twelve chars": true,
|
|
"thirteen char": false,
|
|
"say \"hi\"": false,
|
|
"a;quit": false,
|
|
"back\\slash": false,
|
|
"tab\there": false,
|
|
"🙂🙂🙂🙂🙂🙂": true, // 12 UTF-16 units
|
|
"🙂🙂🙂🙂🙂🙂🙂": false, // 14
|
|
} {
|
|
if got := validClanTag(tag); got != want {
|
|
t.Errorf("validClanTag(%q) = %v, want %v", tag, got, want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestVerifyShown(t *testing.T) {
|
|
on := store.VerifySettings{Enabled: true, GroupID: "103582791429521412"}
|
|
for _, c := range []struct {
|
|
info verifyInfo
|
|
want bool
|
|
}{
|
|
{verifyInfo{Tables: true, Settings: on, Plugin: live.PluginLoaded}, true},
|
|
{verifyInfo{Tables: true, Settings: on, Plugin: live.PluginUnknown}, true},
|
|
{verifyInfo{Tables: true, Settings: on, Plugin: live.PluginMissing}, false},
|
|
{verifyInfo{Tables: false, Settings: on, Plugin: live.PluginLoaded}, false},
|
|
{verifyInfo{Tables: true, Settings: store.VerifySettings{Enabled: false, GroupID: on.GroupID}, Plugin: live.PluginLoaded}, false},
|
|
{verifyInfo{Tables: true, Settings: store.VerifySettings{Enabled: true}, Plugin: live.PluginLoaded}, false},
|
|
} {
|
|
if got := c.info.Shown(); got != c.want {
|
|
t.Errorf("%+v: Shown() = %v, want %v", c.info, got, c.want)
|
|
}
|
|
}
|
|
}
|