mirror of https://github.com/hykilpikonna/AquaDX
[+] Wacca test (incomplete)
parent
a55d503faa
commit
50ae04bb4e
|
@ -50,7 +50,7 @@ class WaccaServer(val rp: WaccaRepos) {
|
||||||
/** Handle all requests */
|
/** Handle all requests */
|
||||||
@API("/api/**")
|
@API("/api/**")
|
||||||
fun handle(req: HttpServletRequest, @RB body: String): Any {
|
fun handle(req: HttpServletRequest, @RB body: String): Any {
|
||||||
val path = req.requestURI.removePrefix("/g/wacca").removePrefix("/api").lowercase()
|
val path = req.requestURI.removePrefix("/g/wacca").removePrefix("/api").removePrefix("/").lowercase()
|
||||||
if (path in cacheMap) return resp(cacheMap[path]!!)
|
if (path in cacheMap) return resp(cacheMap[path]!!)
|
||||||
if (path !in handlerMap) return resp("[]", 1, "Not Found")
|
if (path !in handlerMap) return resp("[]", 1, "Not Found")
|
||||||
|
|
||||||
|
@ -61,20 +61,20 @@ class WaccaServer(val rp: WaccaRepos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun WaccaServer.api() {
|
fun WaccaServer.api() {
|
||||||
"/housing/get" cached { ls("housingId" - 39, "isNewCab" - 0) }
|
"housing/get" cached { ls("housingId" - 39, "isNewCab" - 0) }
|
||||||
"/housing/start" cached { ls("regionId" - 1, "recommendSongList" - ls(1269, 1007, 1270, 1002, 1020, 1003, 1008,
|
"housing/start" cached { ls("regionId" - 1, "recommendSongList" - ls(1269, 1007, 1270, 1002, 1020, 1003, 1008,
|
||||||
1211, 1018, 1092, 1056, 32, 1260, 1230, 1258, 1251, 2212, 1264, 1125, 1037, 2001, 1272, 1126, 1119, 1104, 1070,
|
1211, 1018, 1092, 1056, 32, 1260, 1230, 1258, 1251, 2212, 1264, 1125, 1037, 2001, 1272, 1126, 1119, 1104, 1070,
|
||||||
1047, 1044, 1027, 1004, 1001, 24, 2068, 2062, 2021, 1275, 1249, 1207, 1203, 1107, 1021, 1009, 9, 4, 3, 23, 22,
|
1047, 1044, 1027, 1004, 1001, 24, 2068, 2062, 2021, 1275, 1249, 1207, 1203, 1107, 1021, 1009, 9, 4, 3, 23, 22,
|
||||||
2014, 13, 1276, 1247, 1240, 1237, 1128, 1114, 1110, 1109, 1102, 1045, 1043, 1036, 1035, 1030, 1023, 1015))
|
2014, 13, 1276, 1247, 1240, 1237, 1128, 1114, 1110, 1109, 1102, 1045, 1043, 1036, 1035, 1030, 1023, 1015))
|
||||||
}
|
}
|
||||||
"/advertise/GetRanking" cached { empty }
|
"advertise/GetRanking" cached { empty }
|
||||||
"/advertise/GetNews" cached { ls("notices" - empty, "copyright" - empty, empty, empty, empty, empty, empty, empty, empty) }
|
"advertise/GetNews" cached { ls("notices" - empty, "copyright" - empty, empty, empty, empty, empty, empty, empty, empty) }
|
||||||
"/user/info/GetMyRoom" cached { ls(0, 0, 0, 0, 0, empty, 0, 0, 0) }
|
"user/info/GetMyRoom" cached { ls(0, 0, 0, 0, 0, empty, 0, 0, 0) }
|
||||||
"/user/status/Logout" cached { empty }
|
"user/status/Logout" cached { empty }
|
||||||
"/user/info/GetRanking" cached { ls("totalScore#" - 0, "highScoreBySong#" - 0, "cumulativeScore#" - 0,
|
"user/info/GetRanking" cached { ls("totalScore#" - 0, "highScoreBySong#" - 0, "cumulativeScore#" - 0,
|
||||||
"stateUpScore#" - 0, "otherScore#" - 0, "waccaPoints#" - 0) }
|
"stateUpScore#" - 0, "otherScore#" - 0, "waccaPoints#" - 0) }
|
||||||
|
|
||||||
"/user/status/get" { req, (uid) ->
|
"user/status/get" { req, (uid) ->
|
||||||
val ru = rp.user.findById(uid as Long)()
|
val ru = rp.user.findById(uid as Long)()
|
||||||
val u = ru ?: WaccaUser()
|
val u = ru ?: WaccaUser()
|
||||||
val o = options(u)
|
val o = options(u)
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package test
|
||||||
|
|
||||||
|
import ext.*
|
||||||
|
import io.kotest.core.spec.style.StringSpec
|
||||||
|
import io.kotest.matchers.shouldBe
|
||||||
|
import io.ktor.client.request.*
|
||||||
|
import io.ktor.client.statement.*
|
||||||
|
import io.ktor.http.*
|
||||||
|
|
||||||
|
class WaccaTest : StringSpec({
|
||||||
|
val version = "3.07.01.JPN.26935.S"
|
||||||
|
var uid = 0L
|
||||||
|
var requestNo = 10000
|
||||||
|
|
||||||
|
data class PostResp(val resp: HttpResponse, val res: List<Any>)
|
||||||
|
suspend fun post(url: String, par: String): PostResp {
|
||||||
|
requestNo++
|
||||||
|
val resp = HTTP.post("$HOST/gs/$CLIENT_ID/wacca/api/$url") {
|
||||||
|
contentType(ContentType.Application.Json)
|
||||||
|
setBody("""{"requestNo": ${requestNo++},"appVersion": "$version","boardId": "$BOARD_ID","chipId": "$FULL_CLIENT_ID","params": $par}""")
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(resp.status.isSuccess()) { "Failed to post to $url: ${resp.status} - ${resp.bodyAsText()}" }
|
||||||
|
val res = resp.bodyAsText().jsonMap()
|
||||||
|
res["status"] shouldBe 0
|
||||||
|
res.keys shouldBe setOf("status", "message", "serverTime", "maintNoticeTime", "maintNotPlayableTime", "maintStartTime", "params")
|
||||||
|
|
||||||
|
return PostResp(resp, res["params"] as List<Any>)
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeTest {
|
||||||
|
if (uid == 0L) uid = registerUser()
|
||||||
|
}
|
||||||
|
|
||||||
|
"housing/get" {
|
||||||
|
post("housing/get", "[]").res shouldBe "[39, 0]".jsonArray()
|
||||||
|
}
|
||||||
|
})
|
Loading…
Reference in New Issue