fix: accept POST form posts on every Subsonic endpoint
Clients that use the formPost extension (Feishin, Symfonium) send requests as application/x-www-form-urlencoded POSTs, not only GET. Register both methods for every route and cover it in the smoke test.
This commit is contained in:
1 parent
4d313a2846
commit
1571ec65ff
9 files changed
+168
-113
No files matched your search
@@ -2,10 +2,14 @@ package win.taptap.musicmanager.subsonic
|
||||
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.client.request.header
|
||||
import io.ktor.client.request.post
|
||||
import io.ktor.client.request.setBody
|
||||
import io.ktor.client.statement.bodyAsBytes
|
||||
import io.ktor.client.statement.bodyAsText
|
||||
import io.ktor.http.ContentType
|
||||
import io.ktor.http.HttpHeaders
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.http.contentType
|
||||
import io.ktor.serialization.kotlinx.json.json
|
||||
import io.ktor.server.application.install
|
||||
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
|
||||
@@ -335,6 +339,25 @@ class BrowsingRoutesTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `form posts are accepted for client compatibility`() {
|
||||
seededContext().use { seed ->
|
||||
testApplication {
|
||||
setupApp(seed)
|
||||
|
||||
val response = client.post("/rest/getAlbumList2.view") {
|
||||
contentType(ContentType.Application.FormUrlEncoded)
|
||||
setBody("${credentials("alice", "alice-pw")}&type=alphabeticalByName&size=10")
|
||||
}
|
||||
|
||||
assertEquals(HttpStatusCode.OK, response.status)
|
||||
val albums = parseBody(response.bodyAsText())["albumList2"]!!
|
||||
.jsonObject["album"]!!.jsonArray
|
||||
assertEquals(seed.aliceAlbumId, albums[0].jsonObject["id"]!!.jsonPrimitive.content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `music directory and play queue expose folders albums and songs`() {
|
||||
seededContext().use { seed ->
|
||||
|
||||
Reference in new issue
Block a user