mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-14 18:02:38 +00:00
fix: bind reconnects to verified Steam identity
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
func testRoster(now time.Time) []JoinAuthorisation {
|
||||
roster := make([]JoinAuthorisation, 6)
|
||||
for i := range roster {
|
||||
roster[i] = JoinAuthorisation{MatchID: "match-1", ServerID: "server-1", Protocol: "v1", PlayerID: string(rune('a' + i)), Slot: i, Team: i % 2, Generation: 1, ExpiresAt: now.Add(time.Hour)}
|
||||
roster[i] = JoinAuthorisation{MatchID: "match-1", ServerID: "server-1", Protocol: "v1", PlayerID: string(rune('a' + i)), SteamID: string(rune('A' + i)), Slot: i, Team: i % 2, Generation: 1, ExpiresAt: now.Add(time.Hour)}
|
||||
}
|
||||
return roster
|
||||
}
|
||||
@@ -52,6 +52,11 @@ func TestRankedReconnectRejectsWrongBindingAndExpiredGrace(t *testing.T) {
|
||||
if _, err := r.Admit(bad, now); !errors.Is(err, ErrJoinAuthorisation) {
|
||||
t.Fatalf("wrong server accepted: %v", err)
|
||||
}
|
||||
wrongIdentity := testRoster(now)[0]
|
||||
wrongIdentity.SteamID = "steam-attacker"
|
||||
if _, err := r.Admit(wrongIdentity, now); !errors.Is(err, ErrJoinAuthorisation) {
|
||||
t.Fatalf("wrong SteamID accepted: %v", err)
|
||||
}
|
||||
if err := r.Disconnect("a", 1, now); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -60,6 +65,15 @@ func TestRankedReconnectRejectsWrongBindingAndExpiredGrace(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRankedRosterRejectsDuplicateSlots(t *testing.T) {
|
||||
now := time.Unix(1000, 0)
|
||||
roster := testRoster(now)
|
||||
roster[1].Slot = roster[0].Slot
|
||||
if _, err := NewRankedConnections("match-1", "server-1", "v1", roster); !errors.Is(err, ErrJoinAuthorisation) {
|
||||
t.Fatalf("duplicate slot accepted: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRankedAbandonCooldownUsesRollingSevenDayLadder(t *testing.T) {
|
||||
now := time.Unix(1000, 0)
|
||||
r, err := NewRankedConnections("match-1", "server-1", "v1", testRoster(now))
|
||||
|
||||
Reference in New Issue
Block a user