I have a problem with test my ktor application - I cannot do a post request correctly.
My code:
object AdminAuthHandlerTest : Spek({
with(ktorTestEngine()) {
describe("A sign-in endpoint") {
lateinit var call: TestApplicationCall
beforeGroup {
call = handleRequest(HttpMethod.Post, "/api/admin/auth/sign-in") {
addHeader(HttpHeaders.Accept, ContentType.Text.Plain.contentType)
addHeader(HttpHeaders.ContentType, ContentType.Application.Json.contentType)
setBody(jsonAsString(AdminSignInRequest("admin", "admin123")))
}
}
it("should return 200") {
assertThat(call.response.status()).isEqualTo(HttpStatusCode.OK)
}
}
}
})
I get 400 (Bad Request), but my request body is correct.
Do you have any idea what is wrong?
Aucun commentaire:
Enregistrer un commentaire