mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 13:46:44 -04:00
Convert HTTP 302 responses to more-accurate 303.
This commit is contained in:
@@ -122,7 +122,7 @@ func (web *Web) matchPlayLoadHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
currentMatchType = web.arena.CurrentMatch.Type
|
||||
|
||||
http.Redirect(w, r, "/match_play", 302)
|
||||
http.Redirect(w, r, "/match_play", 303)
|
||||
}
|
||||
|
||||
// Loads the results for the given match into the display buffer.
|
||||
@@ -155,7 +155,7 @@ func (web *Web) matchPlayShowResultHandler(w http.ResponseWriter, r *http.Reques
|
||||
web.arena.SavedMatchResult = matchResult
|
||||
web.arena.ScorePostedNotifier.Notify(nil)
|
||||
|
||||
http.Redirect(w, r, "/match_play", 302)
|
||||
http.Redirect(w, r, "/match_play", 303)
|
||||
}
|
||||
|
||||
// The websocket endpoint for the match play client to send control commands and receive status updates.
|
||||
|
||||
@@ -66,7 +66,7 @@ func TestMatchPlayLoad(t *testing.T) {
|
||||
|
||||
// Load the match and check for the team numbers again.
|
||||
recorder = web.getHttpResponse(fmt.Sprintf("/match_play/%d/load", match.Id))
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.getHttpResponse("/match_play")
|
||||
assert.Equal(t, 200, recorder.Code)
|
||||
assert.Contains(t, recorder.Body.String(), "101")
|
||||
@@ -78,7 +78,7 @@ func TestMatchPlayLoad(t *testing.T) {
|
||||
|
||||
// Load a test match.
|
||||
recorder = web.getHttpResponse("/match_play/0/load")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.getHttpResponse("/match_play")
|
||||
assert.Equal(t, 200, recorder.Code)
|
||||
assert.NotContains(t, recorder.Body.String(), "101")
|
||||
@@ -102,7 +102,7 @@ func TestMatchPlayShowResult(t *testing.T) {
|
||||
assert.Contains(t, recorder.Body.String(), "No result found")
|
||||
web.arena.Database.CreateMatchResult(&model.MatchResult{MatchId: match.Id})
|
||||
recorder = web.getHttpResponse(fmt.Sprintf("/match_play/%d/show_result", match.Id))
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
assert.Equal(t, match.Id, web.arena.SavedMatch.Id)
|
||||
assert.Equal(t, match.Id, web.arena.SavedMatchResult.MatchId)
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ func (web *Web) matchReviewEditPostHandler(w http.ResponseWriter, r *http.Reques
|
||||
web.arena.RedRealtimeScore.Cards = matchResult.RedCards
|
||||
web.arena.BlueRealtimeScore.Cards = matchResult.BlueCards
|
||||
|
||||
http.Redirect(w, r, "/match_play", 302)
|
||||
http.Redirect(w, r, "/match_play", 303)
|
||||
} else {
|
||||
err = web.commitMatchScore(match, matchResult, false)
|
||||
if err != nil {
|
||||
@@ -142,7 +142,7 @@ func (web *Web) matchReviewEditPostHandler(w http.ResponseWriter, r *http.Reques
|
||||
return
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/match_review", 302)
|
||||
http.Redirect(w, r, "/match_review", 303)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ func TestMatchReviewEditExistingResult(t *testing.T) {
|
||||
postBody := "redScoreJson={\"AutoMobility\":3}&blueScoreJson={\"Rotors\":3," +
|
||||
"\"Fouls\":[{\"TeamId\":973,\"Rule\":\"G22\"}]}&redCardsJson={\"105\":\"yellow\"}&blueCardsJson={}"
|
||||
recorder = web.postHttpResponse(fmt.Sprintf("/match_review/%d/edit", match.Id), postBody)
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
|
||||
// Check for the updated scores back on the match list page.
|
||||
recorder = web.getHttpResponse("/match_review")
|
||||
@@ -97,7 +97,7 @@ func TestMatchReviewCreateNewResult(t *testing.T) {
|
||||
postBody := "redScoreJson={\"AutoRotors\":1}&blueScoreJson={\"FuelHigh\":30," +
|
||||
"\"Fouls\":[{\"TeamId\":973,\"Rule\":\"G22\"}]}&redCardsJson={\"105\":\"yellow\"}&blueCardsJson={}"
|
||||
recorder = web.postHttpResponse(fmt.Sprintf("/match_review/%d/edit", match.Id), postBody)
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
|
||||
// Check for the updated scores back on the match list page.
|
||||
recorder = web.getHttpResponse("/match_review")
|
||||
|
||||
@@ -30,6 +30,6 @@ func TestPitDisplayWebsocket(t *testing.T) {
|
||||
|
||||
// Check forced reloading as that is the only purpose the pit websocket serves.
|
||||
recorder := web.getHttpResponse("/setup/field/reload_displays")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
readWebsocketType(t, ws, "reload")
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ func (web *Web) allianceSelectionPostHandler(w http.ResponseWriter, r *http.Requ
|
||||
cachedRankedTeams = newRankedTeams
|
||||
|
||||
web.arena.AllianceSelectionNotifier.Notify(nil)
|
||||
http.Redirect(w, r, "/setup/alliance_selection", 302)
|
||||
http.Redirect(w, r, "/setup/alliance_selection", 303)
|
||||
}
|
||||
|
||||
// Sets up the empty alliances and populates the ranked team list.
|
||||
@@ -128,7 +128,7 @@ func (web *Web) allianceSelectionStartHandler(w http.ResponseWriter, r *http.Req
|
||||
}
|
||||
|
||||
web.arena.AllianceSelectionNotifier.Notify(nil)
|
||||
http.Redirect(w, r, "/setup/alliance_selection", 302)
|
||||
http.Redirect(w, r, "/setup/alliance_selection", 303)
|
||||
}
|
||||
|
||||
// Resets the alliance selection process back to the starting point.
|
||||
@@ -145,7 +145,7 @@ func (web *Web) allianceSelectionResetHandler(w http.ResponseWriter, r *http.Req
|
||||
cachedAlliances = [][]*model.AllianceTeam{}
|
||||
cachedRankedTeams = []*RankedTeam{}
|
||||
web.arena.AllianceSelectionNotifier.Notify(nil)
|
||||
http.Redirect(w, r, "/setup/alliance_selection", 302)
|
||||
http.Redirect(w, r, "/setup/alliance_selection", 303)
|
||||
}
|
||||
|
||||
// Saves the selected alliances to the database and generates the first round of elimination matches.
|
||||
@@ -222,7 +222,7 @@ func (web *Web) allianceSelectionFinalizeHandler(w http.ResponseWriter, r *http.
|
||||
}
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/setup/alliance_selection", 302)
|
||||
http.Redirect(w, r, "/setup/alliance_selection", 303)
|
||||
}
|
||||
|
||||
func (web *Web) renderAllianceSelection(w http.ResponseWriter, r *http.Request, errorMessage string) {
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestSetupAllianceSelection(t *testing.T) {
|
||||
|
||||
// Start the alliance selection.
|
||||
recorder = web.postHttpResponse("/setup/alliance_selection/start", "")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
if assert.Equal(t, 15, len(cachedAlliances)) {
|
||||
assert.Equal(t, 4, len(cachedAlliances[0]))
|
||||
}
|
||||
@@ -39,20 +39,20 @@ func TestSetupAllianceSelection(t *testing.T) {
|
||||
|
||||
// Reset the alliance selection.
|
||||
recorder = web.postHttpResponse("/setup/alliance_selection/reset", "")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
assert.NotContains(t, recorder.Body.String(), "Captain")
|
||||
assert.NotContains(t, recorder.Body.String(), ">110<")
|
||||
web.arena.EventSettings.NumElimAlliances = 3
|
||||
web.arena.EventSettings.SelectionRound3Order = ""
|
||||
recorder = web.postHttpResponse("/setup/alliance_selection/start", "")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
if assert.Equal(t, 3, len(cachedAlliances)) {
|
||||
assert.Equal(t, 3, len(cachedAlliances[0]))
|
||||
}
|
||||
|
||||
// Update one team at a time.
|
||||
recorder = web.postHttpResponse("/setup/alliance_selection", "selection0_0=110")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
assert.Equal(t, 110, cachedAlliances[0][0].TeamId)
|
||||
recorder = web.getHttpResponse("/setup/alliance_selection")
|
||||
assert.Contains(t, recorder.Body.String(), "\"110\"")
|
||||
@@ -60,7 +60,7 @@ func TestSetupAllianceSelection(t *testing.T) {
|
||||
|
||||
// Update multiple teams at a time.
|
||||
recorder = web.postHttpResponse("/setup/alliance_selection", "selection0_0=101&selection0_1=102&selection1_0=103")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
assert.Equal(t, 101, cachedAlliances[0][0].TeamId)
|
||||
assert.Equal(t, 102, cachedAlliances[0][1].TeamId)
|
||||
assert.Equal(t, 103, cachedAlliances[1][0].TeamId)
|
||||
@@ -71,14 +71,14 @@ func TestSetupAllianceSelection(t *testing.T) {
|
||||
recorder = web.postHttpResponse("/setup/alliance_selection", "selection0_0=101&selection0_1=102&"+
|
||||
"selection0_2=103&selection1_0=104&selection1_1=105&selection1_2=106&selection2_0=107&selection2_1=108&"+
|
||||
"selection2_2=109")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.getHttpResponse("/setup/alliance_selection")
|
||||
assert.Contains(t, recorder.Body.String(), ">110<")
|
||||
|
||||
// Finalize alliance selection.
|
||||
web.arena.Database.CreateTeam(&model.Team{Id: 254, YellowCard: true})
|
||||
recorder = web.postHttpResponse("/setup/alliance_selection/finalize", "startTime=2014-01-01 01:00:00 PM")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
alliances, err := web.arena.Database.GetAllAlliances()
|
||||
assert.Nil(t, err)
|
||||
if assert.Equal(t, 3, len(alliances)) {
|
||||
@@ -105,7 +105,7 @@ func TestSetupAllianceSelectionErrors(t *testing.T) {
|
||||
|
||||
// Start an alliance selection that is already underway.
|
||||
recorder := web.postHttpResponse("/setup/alliance_selection/start", "")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.postHttpResponse("/setup/alliance_selection/start", "")
|
||||
assert.Equal(t, 200, recorder.Code)
|
||||
assert.Contains(t, recorder.Body.String(), "already in progress")
|
||||
@@ -128,7 +128,7 @@ func TestSetupAllianceSelectionErrors(t *testing.T) {
|
||||
assert.Contains(t, recorder.Body.String(), "until all spots have been filled")
|
||||
recorder = web.postHttpResponse("/setup/alliance_selection", "selection0_0=101&selection0_1=102&"+
|
||||
"selection0_2=103&selection1_0=104&selection1_1=105&selection1_2=106")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.postHttpResponse("/setup/alliance_selection/finalize", "startTime=asdf")
|
||||
assert.Equal(t, 200, recorder.Code)
|
||||
assert.Contains(t, recorder.Body.String(), "valid start time")
|
||||
@@ -168,7 +168,7 @@ func TestSetupAllianceSelectionAutofocus(t *testing.T) {
|
||||
web.arena.EventSettings.SelectionRound2Order = "F"
|
||||
web.arena.EventSettings.SelectionRound3Order = "F"
|
||||
recorder := web.postHttpResponse("/setup/alliance_selection/start", "")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
i, j := web.determineNextCell()
|
||||
assert.Equal(t, 0, i)
|
||||
assert.Equal(t, 0, j)
|
||||
@@ -209,9 +209,9 @@ func TestSetupAllianceSelectionAutofocus(t *testing.T) {
|
||||
web.arena.EventSettings.SelectionRound2Order = "L"
|
||||
web.arena.EventSettings.SelectionRound3Order = "L"
|
||||
recorder = web.postHttpResponse("/setup/alliance_selection/reset", "")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.postHttpResponse("/setup/alliance_selection/start", "")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
i, j = web.determineNextCell()
|
||||
assert.Equal(t, 0, i)
|
||||
assert.Equal(t, 0, j)
|
||||
|
||||
@@ -42,7 +42,7 @@ func (web *Web) fieldPostHandler(w http.ResponseWriter, r *http.Request) {
|
||||
allianceStation := r.PostFormValue("allianceStation")
|
||||
web.arena.AllianceStationDisplays[displayId] = allianceStation
|
||||
web.arena.MatchLoadTeamsNotifier.Notify(nil)
|
||||
http.Redirect(w, r, "/setup/field", 302)
|
||||
http.Redirect(w, r, "/setup/field", 303)
|
||||
}
|
||||
|
||||
// Force-reloads all the websocket-connected displays.
|
||||
@@ -52,5 +52,5 @@ func (web *Web) fieldReloadDisplaysHandler(w http.ResponseWriter, r *http.Reques
|
||||
}
|
||||
|
||||
web.arena.ReloadDisplaysNotifier.Notify(nil)
|
||||
http.Redirect(w, r, "/setup/field", 302)
|
||||
http.Redirect(w, r, "/setup/field", 303)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ func TestSetupField(t *testing.T) {
|
||||
assert.NotContains(t, recorder.Body.String(), "selected")
|
||||
|
||||
recorder = web.postHttpResponse("/setup/field", "displayId=12345&allianceStation=B1")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.getHttpResponse("/setup/field")
|
||||
assert.Contains(t, recorder.Body.String(), "12345")
|
||||
assert.Contains(t, recorder.Body.String(), "selected")
|
||||
@@ -26,7 +26,7 @@ func TestSetupField(t *testing.T) {
|
||||
// TODO(patrick): Replace with PLC mode.
|
||||
/*
|
||||
recorder = web.postHttpResponse("/setup/field/lights", "mode=strobe")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
assert.Equal(t, "strobe", web.arena.Lights.currentMode)
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ func (web *Web) scheduleGeneratePostHandler(w http.ResponseWriter, r *http.Reque
|
||||
}
|
||||
cachedTeamFirstMatches = teamFirstMatches
|
||||
|
||||
http.Redirect(w, r, "/setup/schedule", 302)
|
||||
http.Redirect(w, r, "/setup/schedule", 303)
|
||||
}
|
||||
|
||||
// Publishes the schedule in the database to TBA
|
||||
@@ -114,7 +114,7 @@ func (web *Web) scheduleRepublishPostHandler(w http.ResponseWriter, r *http.Requ
|
||||
return
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/setup/schedule", 302)
|
||||
http.Redirect(w, r, "/setup/schedule", 303)
|
||||
}
|
||||
|
||||
// Saves the generated schedule to the database.
|
||||
@@ -163,7 +163,7 @@ func (web *Web) scheduleSavePostHandler(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/setup/schedule", 302)
|
||||
http.Redirect(w, r, "/setup/schedule", 303)
|
||||
}
|
||||
|
||||
func (web *Web) renderSchedule(w http.ResponseWriter, r *http.Request, errorMessage string) {
|
||||
|
||||
@@ -27,7 +27,7 @@ func TestSetupSchedule(t *testing.T) {
|
||||
"startTime1=2014-01-02 09:56:00 AM&numMatches1=17&matchSpacingSec1=420&startTime2=2014-01-03 01:00:00 PM&" +
|
||||
"numMatches2=40&matchSpacingSec2=360&matchType=qualification"
|
||||
recorder = web.postHttpResponse("/setup/schedule/generate", postData)
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.getHttpResponse("/setup/schedule")
|
||||
assert.Contains(t, recorder.Body.String(), "2014-01-01 09:48:00") // Last match of first block.
|
||||
assert.Contains(t, recorder.Body.String(), "2014-01-02 11:48:00") // Last match of second block.
|
||||
@@ -91,7 +91,7 @@ func TestSetupScheduleErrors(t *testing.T) {
|
||||
postData = "numScheduleBlocks=1&startTime0=2014-01-01 09:00:00 AM&numMatches0=64&matchSpacingSec0=480&" +
|
||||
"matchType=practice"
|
||||
recorder = web.postHttpResponse("/setup/schedule/generate", postData)
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.postHttpResponse("/setup/schedule/save", postData)
|
||||
assert.Equal(t, 200, recorder.Code)
|
||||
assert.Contains(t, recorder.Body.String(), "schedule of 2 practice matches already exists")
|
||||
|
||||
@@ -80,7 +80,7 @@ func (web *Web) settingsPostHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/setup/settings", 302)
|
||||
http.Redirect(w, r, "/setup/settings", 303)
|
||||
}
|
||||
|
||||
// Sends a copy of the event database file to the client as a download.
|
||||
@@ -166,7 +166,7 @@ func (web *Web) restoreDbHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/setup/settings", 302)
|
||||
http.Redirect(w, r, "/setup/settings", 303)
|
||||
}
|
||||
|
||||
// Deletes all data except for the team list.
|
||||
@@ -202,7 +202,7 @@ func (web *Web) clearDbHandler(w http.ResponseWriter, r *http.Request) {
|
||||
handleWebErr(w, err)
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, "/setup/settings", 302)
|
||||
http.Redirect(w, r, "/setup/settings", 303)
|
||||
}
|
||||
|
||||
func (web *Web) renderSettings(w http.ResponseWriter, r *http.Request, errorMessage string) {
|
||||
|
||||
@@ -30,7 +30,7 @@ func TestSetupSettings(t *testing.T) {
|
||||
// Change the settings and check the response.
|
||||
recorder = web.postHttpResponse("/setup/settings", "name=Chezy Champs&code=CC&displayBackgroundColor=#ff00ff&"+
|
||||
"numElimAlliances=16&tbaPublishingEnabled=on&tbaEventCode=2014cc&tbaSecretId=secretId&tbaSecret=tbasec")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.getHttpResponse("/setup/settings")
|
||||
assert.Contains(t, recorder.Body.String(), "Chezy Champs")
|
||||
assert.Contains(t, recorder.Body.String(), "#ff00ff")
|
||||
@@ -62,7 +62,7 @@ func TestSetupSettingsClearDb(t *testing.T) {
|
||||
web.arena.Database.CreateRanking(new(game.Ranking))
|
||||
web.arena.Database.CreateAllianceTeam(new(model.AllianceTeam))
|
||||
recorder := web.postHttpResponse("/setup/db/clear", "")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
|
||||
teams, _ := web.arena.Database.GetAllTeams()
|
||||
assert.NotEmpty(t, teams)
|
||||
|
||||
@@ -77,5 +77,5 @@ func (web *Web) sponsorSlidesPostHandler(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/setup/sponsor_slides", 302)
|
||||
http.Redirect(w, r, "/setup/sponsor_slides", 303)
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ func TestSetupSponsorSlides(t *testing.T) {
|
||||
assert.Contains(t, recorder.Body.String(), "Image.gif")
|
||||
|
||||
recorder = web.postHttpResponse("/setup/sponsor_slides", "action=delete&id=1")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.getHttpResponse("/setup/sponsor_slides")
|
||||
assert.Equal(t, 200, recorder.Code)
|
||||
assert.NotContains(t, recorder.Body.String(), "Sponsor Line 1")
|
||||
assert.Contains(t, recorder.Body.String(), "Image.gif")
|
||||
|
||||
recorder = web.postHttpResponse("/setup/sponsor_slides", "action=save&line2=Sponsor Line 2 revised")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.getHttpResponse("/setup/sponsor_slides")
|
||||
assert.Equal(t, 200, recorder.Code)
|
||||
assert.Contains(t, recorder.Body.String(), "Sponsor Line 2 revised")
|
||||
@@ -36,7 +36,7 @@ func TestSetupSponsorSlides(t *testing.T) {
|
||||
assert.NotNil(t, sponsorSlide)
|
||||
|
||||
recorder = web.postHttpResponse("/setup/sponsor_slides", "action=save&image=Image2.gif&id=2")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.getHttpResponse("/setup/sponsor_slides")
|
||||
assert.Equal(t, 200, recorder.Code)
|
||||
assert.NotContains(t, recorder.Body.String(), "Image.gif")
|
||||
|
||||
@@ -59,7 +59,7 @@ func (web *Web) teamsPostHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
}
|
||||
http.Redirect(w, r, "/setup/teams", 302)
|
||||
http.Redirect(w, r, "/setup/teams", 303)
|
||||
}
|
||||
|
||||
// Clears the team list.
|
||||
@@ -78,7 +78,7 @@ func (web *Web) teamsClearHandler(w http.ResponseWriter, r *http.Request) {
|
||||
handleWebErr(w, err)
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, "/setup/teams", 302)
|
||||
http.Redirect(w, r, "/setup/teams", 303)
|
||||
}
|
||||
|
||||
// Shows the page to edit a team's fields.
|
||||
@@ -153,7 +153,7 @@ func (web *Web) teamEditPostHandler(w http.ResponseWriter, r *http.Request) {
|
||||
handleWebErr(w, err)
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, "/setup/teams", 302)
|
||||
http.Redirect(w, r, "/setup/teams", 303)
|
||||
}
|
||||
|
||||
// Removes a team from the team list.
|
||||
@@ -183,7 +183,7 @@ func (web *Web) teamDeletePostHandler(w http.ResponseWriter, r *http.Request) {
|
||||
handleWebErr(w, err)
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, "/setup/teams", 302)
|
||||
http.Redirect(w, r, "/setup/teams", 303)
|
||||
}
|
||||
|
||||
// Publishes the team list to the web.
|
||||
@@ -197,7 +197,7 @@ func (web *Web) teamsPublishHandler(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "Failed to publish teams: "+err.Error(), 500)
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, "/setup/teams", 302)
|
||||
http.Redirect(w, r, "/setup/teams", 303)
|
||||
}
|
||||
|
||||
// Generates random WPA keys and saves them to the team models.
|
||||
@@ -223,7 +223,7 @@ func (web *Web) teamsGenerateWpaKeysHandler(w http.ResponseWriter, r *http.Reque
|
||||
}
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/setup/teams", 302)
|
||||
http.Redirect(w, r, "/setup/teams", 303)
|
||||
}
|
||||
|
||||
func (web *Web) renderTeams(w http.ResponseWriter, r *http.Request, showErrorMessage bool) {
|
||||
|
||||
@@ -85,7 +85,7 @@ func TestSetupTeams(t *testing.T) {
|
||||
|
||||
// Add some teams.
|
||||
recorder = web.postHttpResponse("/setup/teams", "teamNumbers=254\r\nnotateam\r\n1114\r\n")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.getHttpResponse("/setup/teams")
|
||||
assert.Contains(t, recorder.Body.String(), "2 teams")
|
||||
assert.Contains(t, recorder.Body.String(), "The Cheesy Poofs")
|
||||
@@ -93,7 +93,7 @@ func TestSetupTeams(t *testing.T) {
|
||||
|
||||
// Add another team.
|
||||
recorder = web.postHttpResponse("/setup/teams", "teamNumbers=33")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.getHttpResponse("/setup/teams")
|
||||
assert.Contains(t, recorder.Body.String(), "3 teams")
|
||||
assert.Contains(t, recorder.Body.String(), "33")
|
||||
@@ -103,19 +103,19 @@ func TestSetupTeams(t *testing.T) {
|
||||
assert.Equal(t, 200, recorder.Code)
|
||||
assert.Contains(t, recorder.Body.String(), "The Cheesy Poofs")
|
||||
recorder = web.postHttpResponse("/setup/teams/254/edit", "nickname=Teh Chezy Pofs")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.getHttpResponse("/setup/teams")
|
||||
assert.Contains(t, recorder.Body.String(), "Teh Chezy Pofs")
|
||||
|
||||
// Delete a team.
|
||||
recorder = web.postHttpResponse("/setup/teams/1114/delete", "")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.getHttpResponse("/setup/teams")
|
||||
assert.Contains(t, recorder.Body.String(), "2 teams")
|
||||
|
||||
// Test clearing all teams.
|
||||
recorder = web.postHttpResponse("/setup/teams/clear", "")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.getHttpResponse("/setup/teams")
|
||||
assert.Contains(t, recorder.Body.String(), "0 teams")
|
||||
}
|
||||
@@ -146,7 +146,7 @@ func TestSetupTeamsDisallowModification(t *testing.T) {
|
||||
|
||||
// Allow editing a team.
|
||||
recorder = web.postHttpResponse("/setup/teams/254/edit", "nickname=Teh Chezy Pofs")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
recorder = web.getHttpResponse("/setup/teams")
|
||||
assert.NotContains(t, recorder.Body.String(), "can't modify")
|
||||
assert.Contains(t, recorder.Body.String(), "1 teams")
|
||||
@@ -178,14 +178,14 @@ func TestSetupTeamsWpaKeys(t *testing.T) {
|
||||
web.arena.Database.CreateTeam(team2)
|
||||
|
||||
recorder := web.getHttpResponse("/setup/teams/generate_wpa_keys?all=false")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
team1, _ = web.arena.Database.GetTeamById(254)
|
||||
team2, _ = web.arena.Database.GetTeamById(1114)
|
||||
assert.Equal(t, "aaaaaaaa", team1.WpaKey)
|
||||
assert.Equal(t, 8, len(team2.WpaKey))
|
||||
|
||||
recorder = web.getHttpResponse("/setup/teams/generate_wpa_keys?all=true")
|
||||
assert.Equal(t, 302, recorder.Code)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
team1, _ = web.arena.Database.GetTeamById(254)
|
||||
team3, _ := web.arena.Database.GetTeamById(1114)
|
||||
assert.NotEqual(t, "aaaaaaaa", team1.WpaKey)
|
||||
|
||||
Reference in New Issue
Block a user