-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplicationTest.kt
More file actions
49 lines (43 loc) · 1.28 KB
/
ApplicationTest.kt
File metadata and controls
49 lines (43 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package cv.mcdonnell
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
import io.ktor.server.testing.*
import kotlin.test.Test
import kotlin.test.assertEquals
class ApplicationTest {
@Test
fun testUnauthenticatedEndpoint() = testApplication {
application {
module()
}
client.get("/unauthenticated").apply {
assertEquals(HttpStatusCode.OK, status)
assertEquals("Hello World!", bodyAsText())
}
}
@Test
fun testAuthenticatedEndpointWithoutHeaders() = testApplication {
application {
module()
}
client.get("/authenticated").apply {
assertEquals(HttpStatusCode.Unauthorized, status)
}
}
@Test
fun testAuthenticatedEndpointWithAppEngineHeaders() = testApplication {
application {
module()
}
client.get("/authenticated") {
headers {
append("X-AppEngine-QueueName", "QueueName")
append("X-AppEngine-TaskName", "TaskName")
}
}.apply {
assertEquals(HttpStatusCode.OK, status)
assertEquals("Successfully authenticated with queueName=QueueName and taskName=TaskName", bodyAsText())
}
}
}