Skip to content

Commit 10be87b

Browse files
author
Oleksandr Dzhychko
committed
fix(model-server): restore WebSocket endpoint /json/{repositoryId}/ws
The WebSocket was accidentally moved to /{repositoryId}/ws while refactoring in 672d329.
1 parent d8363c1 commit 10be87b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

model-server/src/main/kotlin/org/modelix/model/server/handlers/DeprecatedLightModelServer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class DeprecatedLightModelServer(val client: LocalModelClient) {
163163
val oldVersion = CLVersion.loadFromHash(versionHash, getStore())
164164
respondVersion(version, oldVersion)
165165
}
166-
webSocket("/{repositoryId}/ws") {
166+
webSocket("/json/{repositoryId}/ws") {
167167
val repositoryId = RepositoryId(call.parameters["repositoryId"]!!)
168168
val userId = call.getUserName()
169169

model-server/src/test/kotlin/org/modelix/model/server/JsonAPITest.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package org.modelix.model.server
1616

17+
import io.ktor.client.plugins.websocket.webSocketSession
1718
import io.ktor.client.request.get
1819
import io.ktor.client.request.post
1920
import io.ktor.client.request.setBody
@@ -40,6 +41,7 @@ import org.modelix.model.server.store.LocalModelClient
4041
import kotlin.test.Test
4142
import kotlin.test.assertEquals
4243
import kotlin.test.assertNotNull
44+
import kotlin.test.fail
4345

4446
class JsonAPITest {
4547
private fun runTest(block: suspend ApplicationTestBuilder.() -> Unit) = testApplication {
@@ -61,6 +63,18 @@ class JsonAPITest {
6163
assertEmptyVersion(JSONObject(response.bodyAsText()))
6264
}
6365

66+
@Test
67+
fun connectToWebsocket() = runTest {
68+
val client = createClient {
69+
install(io.ktor.client.plugins.websocket.WebSockets)
70+
}
71+
try {
72+
client.webSocketSession("ws://localhost/json/$repoId/ws")
73+
} catch (e: Exception) {
74+
fail("Could not connect to WebSocket", e)
75+
}
76+
}
77+
6478
private fun assertEmptyVersion(json: JSONObject) {
6579
assertEquals(json.getJSONObject("root").getString("nodeId").toLong(), 1L)
6680
assertEquals(json.getString("repositoryId"), repoId)

0 commit comments

Comments
 (0)