diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/PlayerHandler.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/PlayerHandler.kt index 7454eae..e6e01c3 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/PlayerHandler.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/PlayerHandler.kt @@ -43,9 +43,11 @@ object PlayerHandler: PairgothApiHandler { } val leavingRounds = updated.skip.toSet().minus(player.skip.toSet()) leavingRounds.forEach { round -> - val playing = tournament.games(round).values.flatMap { listOf(it.black, it.white) } - if (playing.contains(id)) { - throw badRequest("player is playing in round #$round") + if (round <= tournament.lastRound()) { + val playing = tournament.games(round).values.flatMap { listOf(it.black, it.white) } + if (playing.contains(id)) { + throw badRequest("player is playing in round #$round") + } } } tournament.players[id] = updated diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/store/Store.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/store/Store.kt index 18bf547..8bb3dde 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/store/Store.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/store/Store.kt @@ -25,12 +25,14 @@ interface Store { fun deleteTournament(tournament: Tournament<*>) } +private val memoryStore: Store = MemoryStore() + fun getStore(request: HttpServletRequest): Store { val storeType = WebappManager.getMandatoryProperty("store") return when (val auth = WebappManager.getMandatoryProperty("auth")) { "none", "sesame" -> when (storeType) { - "memory" -> MemoryStore() + "memory" -> memoryStore "file" -> { val filePath = WebappManager.properties.getProperty("store.file.path") ?: "." FileStore(filePath) diff --git a/api-webapp/src/test/kotlin/BasicTests.kt b/api-webapp/src/test/kotlin/BasicTests.kt index 8484246..0a097f1 100644 --- a/api-webapp/src/test/kotlin/BasicTests.kt +++ b/api-webapp/src/test/kotlin/BasicTests.kt @@ -23,6 +23,7 @@ class BasicTests: TestBase() { "shortName" to "mon-tournoi", "startDate" to "2023-05-10", "endDate" to "2023-05-12", + "director" to "Nestor Burma", "country" to "FR", "location" to "Marseille", "online" to false, diff --git a/api-webapp/src/test/kotlin/TestUtils.kt b/api-webapp/src/test/kotlin/TestUtils.kt index 95dafcd..7ff309f 100644 --- a/api-webapp/src/test/kotlin/TestUtils.kt +++ b/api-webapp/src/test/kotlin/TestUtils.kt @@ -27,6 +27,7 @@ object TestAPI { private fun testRequest(reqMethod: String, uri: String, accept: String = "application/json", payload: T? = null): String { WebappManager.properties["auth"] = "none" + WebappManager.properties["store"] = "memory" WebappManager.properties["webapp.env"] = "test" // mock request