commit ca00a4a2ee4a06395f9df2d9359952f6d90081cc
parent 8b29269fc25f38980264d3da395ebf2d6cc8c7cb
Author: Antoine A <>
Date: Mon, 22 Jul 2024 21:04:57 +0200
nexus: WIP WSS test auth
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/nexus/src/test/kotlin/WsTest.kt b/nexus/src/test/kotlin/WsTest.kt
@@ -17,6 +17,7 @@
* <http://www.gnu.org/licenses/>
*/
+import io.ktor.http.HttpHeaders
import io.ktor.serialization.kotlinx.*
import io.ktor.server.application.*
import io.ktor.server.routing.*
@@ -45,6 +46,8 @@ class WsTest {
"USERID": "USER4711"
}
"""
+ // Authorization header example from the spec
+ val AUTH_EXAMPLE = "Basic SzEyMzQ1NjdfVVNFUjQ3MTE6NTUwZTg0MDAtZTI5Yi0xMWQ0LWE3MTYtNDQ2NjU1NDQwMDAw"
// Notifications examples from the spec
val NOTIFICATION_EXAMPLES = sequenceOf(
"""
@@ -141,7 +144,6 @@ class WsTest {
/** Test our implementation works with spec examples */
@Test
fun wss() {
- println(kotlinx.serialization.serializer<WssNotification>())
val params: WssParams = Json.decodeFromString(PARAMS_EXAMPLE)
testApplication {
@@ -152,7 +154,8 @@ class WsTest {
}
routing {
webSocket("/") {
- // Send all examples and read them back
+ assertEquals(AUTH_EXAMPLE, call.request.headers[HttpHeaders.Authorization])
+ // Send all examples
for (example in NOTIFICATION_EXAMPLES) {
send(example)
}
@@ -165,6 +168,7 @@ class WsTest {
try {
params.connect(client) { msg ->
count++
+ // Check message number and type
assert(count <= 3)
if (count == 3) {
assertIs<WssGeneralInfo>(msg)