Only anonymize team IDs once per team

This commit is contained in:
Neale Pickett 2020-10-14 09:46:51 -06:00
parent 2d3c707205
commit 843996f2c4
4 changed files with 22 additions and 2 deletions

View File

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Multiple bugs preventing production server from working properly
- CI builds should be working now
- Team registration now correctly writes names to files
- Anonymized team names now only computed once per team
## [v4.0-rc1] - 2020-10-13
### Changed

View File

@ -196,8 +196,8 @@ func (mh *MothRequestHandler) exportStateIfRegistered(override bool) *StateExpor
} else {
exportID := strconv.Itoa(logno)
name, _ := mh.State.TeamName(awd.TeamID)
awd.TeamID = exportID
exportIDs[awd.TeamID] = awd.TeamID
awd.TeamID = exportID
export.TeamNames[exportID] = name
}
export.PointsLog[logno] = awd

View File

@ -133,5 +133,20 @@ func TestServer(t *testing.T) {
r.Close()
}
if err := handler.CheckAnswer("pategory", 2, "wat"); err != nil {
t.Error("Right answer marked wrong:", err)
}
time.Sleep(TestMaintenanceInterval)
es = anonHandler.ExportState()
if len(es.TeamNames) != 2 {
t.Error("Anonymous TeamNames is wrong:", es.TeamNames)
}
es = handler.ExportState()
if len(es.TeamNames) != 1 {
t.Error("TeamNames is wrong:", es.TeamNames)
}
// BUG(neale): We aren't currently testing the various ways to disable the server
}

View File

@ -89,6 +89,10 @@ func TestState(t *testing.T) {
t.Error("Duplicate points award didn't fail")
}
if err := s.AwardPoints(teamID, category, points+1); err != nil {
t.Error("Awarding more points:", err)
}
pl = s.PointsLog()
if len(pl) != 1 {
t.Errorf("After awarding points, points log has length %d", len(pl))
@ -104,7 +108,7 @@ func TestState(t *testing.T) {
t.Error(err)
}
s.refresh()
if len(s.PointsLog()) != 1 {
if len(s.PointsLog()) != 2 {
t.Error("Intentional parse error screws up all parsing")
}