mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
test(multiplayer): harden ranked arena provider boundary
This commit is contained in:
@@ -17,6 +17,18 @@ func request() domain.AllocationRequest {
|
|||||||
return domain.AllocationRequest{AllocationID: "allocation-1", MatchID: "match-1", Region: "EU", Build: "build-1", Protocol: 1, Transport: "enet"}
|
return domain.AllocationRequest{AllocationID: "allocation-1", MatchID: "match-1", Region: "EU", Build: "build-1", Protocol: 1, Transport: "enet"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAllocateRejectsRankedRequestsWithoutRegisteredArena(t *testing.T) {
|
||||||
|
client := Client{BaseURL: "http://127.0.0.1:1", Namespace: "games"}
|
||||||
|
for _, path := range []string{"", "res://scenes/arena_01_elevated.tscn", "res://forged.tscn"} {
|
||||||
|
req := request()
|
||||||
|
req.Playlist = domain.Ranked
|
||||||
|
req.ArenaPath = path
|
||||||
|
if _, err := client.Allocate(context.Background(), req, map[string]string{"region": "EU"}, time.Unix(1000, 0)); err != domain.ErrAllocationInput {
|
||||||
|
t.Fatalf("ranked arena path %q returned %v, want ErrAllocationInput", path, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestAllocateBuildsStrictGameServerAllocationAndEndpoint(t *testing.T) {
|
func TestAllocateBuildsStrictGameServerAllocationAndEndpoint(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != http.MethodPost || r.URL.Path != "/apis/allocation.agones.dev/v1/namespaces/games/gameserverallocations" {
|
if r.Method != http.MethodPost || r.URL.Path != "/apis/allocation.agones.dev/v1/namespaces/games/gameserverallocations" {
|
||||||
|
|||||||
Reference in New Issue
Block a user