server/native_creation_test.go (22274B)
1 package main 2 3 import ( 4 "context" 5 "encoding/binary" 6 "encoding/hex" 7 "net" 8 "net/http" 9 "net/http/httptest" 10 "net/url" 11 "reflect" 12 "strings" 13 "testing" 14 "time" 15 16 "github.com/coder/websocket" 17 ) 18 19 func nativePreparationRequest(world *server, cookie *http.Cookie, name, password string) *httptest.ResponseRecorder { 20 request := httptest.NewRequest("POST", world.baseURL+"browser-create", strings.NewReader(url.Values{"name": {name}, "password": {password}}.Encode())) 21 request.Header.Set("Content-Type", "application/x-www-form-urlencoded") 22 if cookie != nil { 23 request.AddCookie(cookie) 24 } 25 response := httptest.NewRecorder() 26 world.httpHandler().ServeHTTP(response, request) 27 return response 28 } 29 30 func prepareNativeCreation(t *testing.T, world *server, cookie *http.Cookie, name, password string) { 31 t.Helper() 32 if response := nativePreparationRequest(world, cookie, name, password); response.Code != http.StatusNoContent || response.Header().Get("X-AO-Creation-Name") == "" { 33 t.Fatal("could not prepare native creation", response.Code, response.Body.String()) 34 } 35 } 36 37 func startNativeCreation(t *testing.T, world *server, cookie *http.Cookie) { 38 t.Helper() 39 request := httptest.NewRequest("POST", world.baseURL+"browser-launch?create=1", nil) 40 request.AddCookie(cookie) 41 response := httptest.NewRecorder() 42 world.httpHandler().ServeHTTP(response, request) 43 if response.Code != http.StatusOK { 44 t.Fatal("could not start native creation", response.Code, response.Body.String()) 45 } 46 } 47 48 func nativeCreationConnection(t *testing.T, world *server, cookie *http.Cookie) net.Conn { 49 t.Helper() 50 if world.world == nil || world.tasks == nil { 51 t.Fatal("start the production service before opening a native creation connection") 52 } 53 host := httptest.NewServer(world.httpHandler()) 54 t.Cleanup(host.Close) 55 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) 56 t.Cleanup(cancel) 57 socket, _, err := websocket.Dial(ctx, host.URL+world.baseURL+"browser-create", &websocket.DialOptions{ 58 HTTPHeader: http.Header{"Cookie": {cookie.String()}}, 59 }) 60 if err != nil { 61 t.Fatal(err) 62 } 63 t.Cleanup(func() { socket.CloseNow() }) 64 return websocket.NetConn(ctx, socket, websocket.MessageBinary) 65 } 66 67 func nativeCreationIdentities(t *testing.T, world *server) [2]uint32 { 68 t.Helper() 69 var result [2]uint32 70 if err := world.db.QueryRow("SELECT last_character_id,last_item_id FROM world WHERE id=1").Scan(&result[0], &result[1]); err != nil { 71 t.Fatal(err) 72 } 73 return result 74 } 75 76 func nativeCreationExchange(t *testing.T, connection net.Conn, packet []byte) []byte { 77 t.Helper() 78 if _, err := connection.Write(packet); err != nil { 79 t.Fatal(err) 80 } 81 response, err := readPacket(connection) 82 if err != nil { 83 t.Fatal(err) 84 } 85 return response[16:] 86 } 87 88 func nativeCreationAlice(t *testing.T) []byte { 89 t.Helper() 90 // Original serializers: CharacterData v4, proxy, CharacterInfo v4, name, appearance. 91 body, err := hex.DecodeString("000000040000000061" + 92 "0000c79c00000000000000000000000000009c5000000000" + 93 "00000000000000040000000000000005416c696365" + 94 "000000040000000100000009000000000000000000000000000000000000001d0000006e00000002") 95 if err != nil { 96 t.Fatal(err) 97 } 98 return systemPacket(0x0f, body) 99 } 100 101 func TestNativeCreationCapturedClientRequest(t *testing.T) { 102 for _, scenario := range []string{"native packet", "invalid area length", "invalid reason length"} { 103 t.Run(scenario, func(t *testing.T) { 104 world := newTestServer(t) 105 cookie := accountVisitor(t, world) 106 startNativeCreation(t, world, cookie) 107 startTestService(t, world) 108 connection := nativeCreationConnection(t, world, cookie) 109 prepareNativeCreation(t, world, cookie, "Nativehero", "secret") 110 // Actual creator: Atrox Enforcer, head 29, tall, heavy, area "area unknown". 111 packet, err := hex.DecodeString("dfdf00010001008300000000000000010000000f0000000400000000610000000000000000000000000000000000000000000000000000000000000004000000000000000a4e61746976656865726f000000040000000100000009000000000000000c6172656120756e6b6e6f776e00000000000000000000001d0000006e0000000215") 112 if err != nil { 113 t.Fatal(err) 114 } 115 if scenario == "invalid area length" { 116 binary.BigEndian.PutUint32(packet[95:99], 100) 117 } 118 if scenario == "invalid reason length" { 119 binary.BigEndian.PutUint32(packet[115:119], 100) 120 } 121 122 response := nativeCreationExchange(t, connection, packet) 123 124 if scenario != "native packet" { 125 if hex.EncodeToString(response) != "0000001000000009" || nativeCreationIdentities(t, world)[0] != 1 { 126 t.Fatalf("malformed native string accepted: %x", response) 127 } 128 return 129 } 130 player := testPlayerProfile(t, world, 2) 131 if hex.EncodeToString(response) != "0000001100000002" || player.Name != "Nativehero" || 132 player.Profession != 9 || player.HeadMesh != 40132 || player.Height != 110 || 133 player.Appearance != (appearanceFields{Race: 1, Breed: 4, Sex: 1, Fatness: 2}) { 134 t.Fatalf("native client request did not preserve its appearance: %x %+v", response, player) 135 } 136 }) 137 } 138 } 139 140 func TestNativeCreationPersistsAndRedirects(t *testing.T) { 141 world := newTestServer(t) 142 world.baseURL = "/share/test/" 143 world.worldPort = 7620 144 cookie := accountVisitor(t, world) 145 claimed := accountRequest(world, cookie, "claim", "Previous", "secret") 146 if claimed.Code != http.StatusNoContent { 147 t.Fatal(claimed.Body.String()) 148 } 149 cookie = claimed.Result().Cookies()[0] 150 before := world.characters[1].profile() 151 startNativeCreation(t, world, cookie) 152 shutdown := startTestService(t, world) 153 connection := nativeCreationConnection(t, world, cookie) 154 prepared := nativePreparationRequest(world, cookie, "ALICE", "new secret") 155 if prepared.Code != http.StatusNoContent || prepared.Header().Get("X-AO-Creation-Name") != "Alice" { 156 t.Fatal("naming did not return its canonical name", prepared.Code, prepared.Header()) 157 } 158 159 challenge := nativeCreationExchange(t, connection, systemPacket(0x22, nil)) 160 authenticated := nativeCreationExchange(t, connection, systemPacket(0x25, nil)) 161 suggested := nativeCreationExchange(t, connection, systemPacket(0x55, nil)) 162 created := nativeCreationExchange(t, connection, nativeCreationAlice(t)) 163 repeated := nativeCreationExchange(t, connection, nativeCreationAlice(t)) 164 redirect := nativeCreationExchange(t, connection, systemPacket(0x16, []byte{0, 0, 0, 2})) 165 var pending int 166 if err := world.accountOperation(func(coordinator *worldCoordinator) error { 167 pending = len(coordinator.browserCreations) 168 return nil 169 }); err != nil { 170 t.Fatal(err) 171 } 172 connection.Close() 173 if err := shutdown(); err != nil { 174 t.Fatal(err) 175 } 176 restored := newTestInventoryServer(t) 177 178 if binary.BigEndian.Uint32(challenge) != 0x24 || hex.EncodeToString(authenticated) != "0000000e00000000" || 179 hex.EncodeToString(suggested) != "000000560005416c696365" || pending != 0 || 180 hex.EncodeToString(created) != "0000001100000002" || !reflect.DeepEqual(created, repeated) || 181 hex.EncodeToString(redirect) != "00000017000000027f0000011dc40000000000000000" { 182 t.Fatalf("native creation replies: challenge=%x auth=%x created=%x repeat=%x redirect=%x", challenge, authenticated, created, repeated, redirect) 183 } 184 player := restored.characters[2] 185 if player.name != "Alice" || player.profession != 9 || player.headMesh != 40132 || player.height != 110 || 186 unpackAppearance(player.appearance) != (appearanceFields{Race: 1, Breed: 4, Sex: 1, Fatness: 2}) || 187 player.playfield != 4604 || player.position != [3]float32{190, 1.52, 200} || player.returnDoor != nil || len(player.inventory.Items) != 4 { 188 t.Fatalf("native creation state: %+v inventory=%+v", player.profile(), player.inventory) 189 } 190 if player.inventory.Items[0].Template != 116628 || player.inventory.Items[1].Template != 116629 || 191 player.inventory.Items[2].Template != 121564 || player.inventory.Items[3].Template != 43379 { 192 t.Fatal("native starter kit differs from existing creation grants", player.inventory.Items) 193 } 194 request := httptest.NewRequest("GET", "/", nil) 195 request.AddCookie(cookie) 196 if restored.browserCharacter(request) != player || restored.nextCharacter != 2 { 197 t.Fatal("browser ownership did not move atomically or repeated creation duplicated a character") 198 } 199 before.BrowserTokenHash = restored.characters[1].browserTokenHash 200 if before != restored.characters[1].profile() { 201 t.Fatal("creation changed the previous character") 202 } 203 restored.baseURL = "/" 204 if response := accountRequest(restored, cookie, "login", "Previous", "secret"); response.Code != http.StatusNoContent { 205 t.Fatal("the previous character's credentials were lost", response.Body.String()) 206 } 207 } 208 209 func TestNativeCreationRefusalAndFailedCommitRetainSession(t *testing.T) { 210 for _, scenario := range []string{"invalid head", "truncated", "insert failure", "ownership failure", "commit failure", "cancel"} { 211 t.Run(scenario, func(t *testing.T) { 212 world := newTestServer(t) 213 cookie := accountVisitor(t, world) 214 startNativeCreation(t, world, cookie) 215 before := world.characters[1].profile() 216 lastItem := world.nextItem 217 packet := nativeCreationAlice(t) 218 if scenario == "invalid head" { 219 binary.BigEndian.PutUint32(packet[102:106], 30) 220 } 221 if scenario == "truncated" { 222 packet = systemPacket(0x0f, []byte{0, 0, 0, 4}) 223 } 224 if scenario == "insert failure" || scenario == "ownership failure" || scenario == "commit failure" { 225 trigger := "CREATE TRIGGER reject_creation BEFORE INSERT ON item_locations BEGIN SELECT RAISE(FAIL, 'test creation failure'); END" 226 if scenario == "ownership failure" { 227 trigger = "CREATE TRIGGER reject_creation BEFORE UPDATE OF browser_token_hash ON characters WHEN OLD.id=1 BEGIN SELECT RAISE(FAIL, 'test ownership failure'); END" 228 } else if scenario == "commit failure" { 229 trigger = "CREATE TABLE pending_creation (id INTEGER REFERENCES players(id) DEFERRABLE INITIALLY DEFERRED); CREATE TRIGGER reject_creation AFTER INSERT ON players BEGIN INSERT INTO pending_creation VALUES (999999); END" 230 } 231 if _, err := world.db.Exec(trigger); err != nil { 232 t.Fatal(err) 233 } 234 } 235 startTestService(t, world) 236 connection := nativeCreationConnection(t, world, cookie) 237 prepareNativeCreation(t, world, cookie, "Alice", "secret") 238 239 nativeCreationExchange(t, connection, systemPacket(0x25, nil)) 240 var response []byte 241 if scenario != "cancel" { 242 response = nativeCreationExchange(t, connection, packet) 243 } 244 connection.Close() 245 restored := newTestInventoryServer(t) 246 247 if scenario != "cancel" { 248 want := "0000001000000009" 249 if hex.EncodeToString(response) != want { 250 t.Fatalf("refusal %x, want %s", response, want) 251 } 252 } 253 if restored.nextCharacter != 1 || restored.nextItem != lastItem || restored.characters[1].profile() != before || testPlayerProfile(t, world, 1) != before { 254 t.Fatal("failed creation changed the old character, credential, or identity counters") 255 } 256 var orphanItems int 257 if err := world.db.QueryRow("SELECT count(*) FROM items WHERE id>?", lastItem).Scan(&orphanItems); err != nil || orphanItems != 0 { 258 t.Fatal("failed creation left partial items", orphanItems, err) 259 } 260 if scenario == "commit failure" { 261 if _, err := world.db.Exec("DROP TRIGGER reject_creation"); err != nil { 262 t.Fatal(err) 263 } 264 retry := nativeCreationExchange(t, nativeCreationConnection(t, world, cookie), nativeCreationAlice(t)) 265 if hex.EncodeToString(retry) != "0000001100000002" { 266 t.Fatal("failed commit prevented retry", hex.EncodeToString(retry)) 267 } 268 } 269 }) 270 } 271 } 272 273 func TestNativeCreationCompetingConnectionCannotCreateTwice(t *testing.T) { 274 world := newTestServer(t) 275 cookie := accountVisitor(t, world) 276 startNativeCreation(t, world, cookie) 277 startTestService(t, world) 278 first := nativeCreationConnection(t, world, cookie) 279 second := nativeCreationConnection(t, world, cookie) 280 prepareNativeCreation(t, world, cookie, "Alice", "secret") 281 282 responses := make(chan []byte, 2) 283 packet := nativeCreationAlice(t) 284 for _, connection := range []net.Conn{first, second} { 285 go func() { 286 connection.Write(packet) 287 response, _ := readPacket(connection) 288 responses <- response 289 }() 290 } 291 one, two := <-responses, <-responses 292 293 if len(one) < 24 || len(two) < 24 { 294 t.Fatal("competing creation failed to return both responses", one, two) 295 } 296 if binary.BigEndian.Uint32(one[16:]) == 0x10 { 297 one, two = two, one 298 } 299 if hex.EncodeToString(one[16:]) != "0000001100000002" || hex.EncodeToString(two[16:]) != "0000001000000002" || nativeCreationIdentities(t, world)[0] != 2 { 300 t.Fatal("competing creation reused transferred ownership", hex.EncodeToString(one), hex.EncodeToString(two), nativeCreationIdentities(t, world)[0]) 301 } 302 } 303 304 func TestNativeCreationPreparedPasswordSurvivesRestart(t *testing.T) { 305 for _, password := range []string{"valid", "chosen password"} { 306 t.Run(password, func(t *testing.T) { 307 world := newTestServer(t) 308 cookie := accountVisitor(t, world) 309 startNativeCreation(t, world, cookie) 310 shutdown := startTestService(t, world) 311 connection := nativeCreationConnection(t, world, cookie) 312 prepareNativeCreation(t, world, cookie, "Alice", password) 313 nativeCreationExchange(t, connection, nativeCreationAlice(t)) 314 connection.Close() 315 if err := shutdown(); err != nil { 316 t.Fatal(err) 317 } 318 restored := newTestInventoryServer(t) 319 restored.baseURL = "/" 320 321 wrong := accountRequest(restored, cookie, "login", "Alice", "wrong password") 322 loggedIn := accountRequest(restored, cookie, "login", "Alice", password) 323 324 if wrong.Code != http.StatusUnauthorized || loggedIn.Code != http.StatusNoContent || restored.nextCharacter != 2 { 325 t.Fatal("prepared credentials did not survive creation and restart", wrong.Code, loggedIn.Code) 326 } 327 }) 328 } 329 } 330 331 func TestNativeCreationRequiresBrowserCredential(t *testing.T) { 332 world := newTestServer(t) 333 response := httptest.NewRecorder() 334 335 world.httpHandler().ServeHTTP(response, httptest.NewRequest("GET", "/browser-create", nil)) 336 337 if response.Code != http.StatusUnauthorized { 338 t.Fatal("unauthenticated browser entered character creation", response.Code) 339 } 340 } 341 342 func TestNativeCreationPreparationRejectsInvalidCredentials(t *testing.T) { 343 for _, scenario := range []string{"invalid name", "empty password", "short password", "long password", "duplicate name", "no session"} { 344 t.Run(scenario, func(t *testing.T) { 345 world := newTestServer(t) 346 cookie := accountVisitor(t, world) 347 startNativeCreation(t, world, cookie) 348 before := world.characters[1].profile() 349 startTestService(t, world) 350 connection := nativeCreationConnection(t, world, cookie) 351 name, password, want := "Alice", "secret", http.StatusBadRequest 352 switch scenario { 353 case "invalid name": 354 name = "A1" 355 case "empty password": 356 password = "" 357 case "short password": 358 password = "abcd" 359 case "long password": 360 password = strings.Repeat("x", 1025) 361 case "duplicate name": 362 name, want = strings.ToLower(before.Name), http.StatusConflict 363 case "no session": 364 cookie, want = nil, http.StatusUnauthorized 365 } 366 367 response := nativePreparationRequest(world, cookie, name, password) 368 refused := nativeCreationExchange(t, connection, nativeCreationAlice(t)) 369 370 if response.Code != want || hex.EncodeToString(refused) != "0000001000000002" || testPlayerProfile(t, world, 1) != before || nativeCreationIdentities(t, world)[0] != 1 { 371 t.Fatal("invalid preparation changed the current character", response.Code, response.Body.String()) 372 } 373 }) 374 } 375 } 376 377 func TestNativeCreationRequiresAttemptAndCredentials(t *testing.T) { 378 world := newTestServer(t) 379 cookie := accountVisitor(t, world) 380 before := world.characters[1].profile() 381 prepared := nativePreparationRequest(world, cookie, "Alice", "secret") 382 request := httptest.NewRequest("GET", "/browser-create", nil) 383 request.AddCookie(cookie) 384 response := httptest.NewRecorder() 385 world.httpHandler().ServeHTTP(response, request) 386 if prepared.Code != http.StatusConflict || response.Code != http.StatusConflict { 387 t.Fatal("creation without an attempt was accepted", prepared.Code, response.Code) 388 } 389 390 startNativeCreation(t, world, cookie) 391 startTestService(t, world) 392 connection := nativeCreationConnection(t, world, cookie) 393 refused := nativeCreationExchange(t, connection, nativeCreationAlice(t)) 394 395 if hex.EncodeToString(refused) != "0000001000000002" || testPlayerProfile(t, world, 1) != before || nativeCreationIdentities(t, world)[0] != 1 { 396 t.Fatalf("attempt without credentials created a character: %x", refused) 397 } 398 } 399 400 func TestNativeCreationCannotChangePreparedIdentity(t *testing.T) { 401 for _, scenario := range []string{"forged name", "replaced attempt"} { 402 t.Run(scenario, func(t *testing.T) { 403 world := newTestServer(t) 404 cookie := accountVisitor(t, world) 405 before := world.characters[1].profile() 406 startNativeCreation(t, world, cookie) 407 startTestService(t, world) 408 connection := nativeCreationConnection(t, world, cookie) 409 prepareNativeCreation(t, world, cookie, "Alice", "first secret") 410 packet, want := nativeCreationAlice(t), "000000100000001f" 411 if scenario == "forged name" { 412 copy(packet[69:74], "Bobby") 413 } else { 414 startNativeCreation(t, world, cookie) 415 prepareNativeCreation(t, world, cookie, "Alice", "second secret") 416 want = "0000001000000002" 417 } 418 419 response := nativeCreationExchange(t, connection, packet) 420 421 if hex.EncodeToString(response) != want || nativeCreationIdentities(t, world)[0] != 1 || testPlayerProfile(t, world, 1) != before { 422 t.Fatalf("native request changed prepared credentials: %x", response) 423 } 424 }) 425 } 426 } 427 428 func TestNativeCreationRechecksNameAtFinalization(t *testing.T) { 429 world := newTestServer(t) 430 first, second := accountVisitor(t, world), accountVisitor(t, world) 431 startNativeCreation(t, world, first) 432 startNativeCreation(t, world, second) 433 startTestService(t, world) 434 one := nativeCreationConnection(t, world, first) 435 two := nativeCreationConnection(t, world, second) 436 prepareNativeCreation(t, world, first, "Alice", "first secret") 437 prepareNativeCreation(t, world, second, "Alice", "second secret") 438 439 created := nativeCreationExchange(t, one, nativeCreationAlice(t)) 440 refused := nativeCreationExchange(t, two, nativeCreationAlice(t)) 441 442 if hex.EncodeToString(created) != "0000001100000003" || hex.EncodeToString(refused) != "000000100000001e" || nativeCreationIdentities(t, world)[0] != 3 { 443 t.Fatalf("competing prepared names created duplicate characters: %x %x", created, refused) 444 } 445 if response := accountRequest(world, second, "login", "Alice", "first secret"); response.Code != http.StatusNoContent { 446 t.Fatal("competing preparation replaced the committed password", response.Code) 447 } 448 } 449 450 func TestNativeCreationNormalLaunchCancelsUnfinishedCreation(t *testing.T) { 451 world := newTestServer(t) 452 cookie := accountVisitor(t, world) 453 before, lastItem := world.characters[1].profile(), world.nextItem 454 startNativeCreation(t, world, cookie) 455 startTestService(t, world) 456 connection := nativeCreationConnection(t, world, cookie) 457 prepareNativeCreation(t, world, cookie, "Alice", "secret") 458 request := httptest.NewRequest("POST", "/browser-launch", nil) 459 request.AddCookie(cookie) 460 launched := httptest.NewRecorder() 461 462 world.httpHandler().ServeHTTP(launched, request) 463 refused := nativeCreationExchange(t, connection, nativeCreationAlice(t)) 464 creator := httptest.NewRequest("GET", "/browser-create", nil) 465 creator.AddCookie(cookie) 466 unprepared := httptest.NewRecorder() 467 world.httpHandler().ServeHTTP(unprepared, creator) 468 469 if launched.Code != http.StatusOK || !strings.Contains(launched.Body.String(), "localtest localtest 1 ") || 470 hex.EncodeToString(refused) != "0000001000000002" || unprepared.Code != http.StatusConflict || 471 testPlayerProfile(t, world, 1) != before || nativeCreationIdentities(t, world)[0] != 1 || nativeCreationIdentities(t, world)[1] != lastItem { 472 t.Fatalf("normal launch did not cancel creation without changing the current character: %d %x %d", launched.Code, refused, unprepared.Code) 473 } 474 } 475 476 func TestNativeCreationNormalLaunchKeepsCommittedCharacter(t *testing.T) { 477 world := newTestServer(t) 478 cookie := accountVisitor(t, world) 479 startNativeCreation(t, world, cookie) 480 startTestService(t, world) 481 connection := nativeCreationConnection(t, world, cookie) 482 prepareNativeCreation(t, world, cookie, "Alice", "secret") 483 nativeCreationExchange(t, connection, nativeCreationAlice(t)) 484 before, lastItem := testPlayerProfile(t, world, 2), nativeCreationIdentities(t, world)[1] 485 486 for range 2 { 487 request := httptest.NewRequest("POST", "/browser-launch", nil) 488 request.AddCookie(cookie) 489 response := httptest.NewRecorder() 490 world.httpHandler().ServeHTTP(response, request) 491 if response.Code != http.StatusOK || !strings.Contains(response.Body.String(), "localtest localtest 2 ") || 492 testPlayerProfile(t, world, 2) != before || nativeCreationIdentities(t, world)[0] != 2 || nativeCreationIdentities(t, world)[1] != lastItem { 493 t.Fatal("refresh after creation changed or duplicated the committed character", response.Code, response.Body.String()) 494 } 495 } 496 request := httptest.NewRequest("GET", "/browser-create", nil) 497 request.AddCookie(cookie) 498 response := httptest.NewRecorder() 499 world.httpHandler().ServeHTTP(response, request) 500 if response.Code != http.StatusConflict { 501 t.Fatal("completed creation could relaunch without fresh preparation", response.Code) 502 } 503 } 504 505 func TestNativeCreationRestartCancelsUnfinishedPreparation(t *testing.T) { 506 world := newTestServer(t) 507 cookie := accountVisitor(t, world) 508 claimed := accountRequest(world, cookie, "claim", "Previous", "secret") 509 if claimed.Code != http.StatusNoContent { 510 t.Fatal(claimed.Body.String()) 511 } 512 cookie = claimed.Result().Cookies()[0] 513 startNativeCreation(t, world, cookie) 514 prepareNativeCreation(t, world, cookie, "Alice", "new secret") 515 restored := newTestInventoryServer(t) 516 restored.baseURL = "/" 517 request := httptest.NewRequest("GET", "/browser-create", nil) 518 request.AddCookie(cookie) 519 response := httptest.NewRecorder() 520 521 restored.httpHandler().ServeHTTP(response, request) 522 loggedIn := accountRequest(restored, cookie, "login", "Previous", "secret") 523 524 if response.Code != http.StatusConflict || loggedIn.Code != http.StatusNoContent || restored.nextCharacter != 1 { 525 t.Fatal("restart retained unfinished creation or lost the previous character", response.Code, loggedIn.Code) 526 } 527 }