File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
main/kotlin/com/ctrlhub/core/auth
test/kotlin/com/ctrlhub/core/auth Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import io.ktor.client.call.*
13
13
import io.ktor.client.plugins.*
14
14
import io.ktor.client.request.delete
15
15
import io.ktor.client.request.get
16
+ import io.ktor.client.request.header
16
17
import io.ktor.client.request.post
17
18
import io.ktor.client.request.setBody
18
19
import io.ktor.http.*
@@ -30,9 +31,13 @@ class AuthRouter(httpClient: HttpClient) : Router(httpClient = httpClient) {
30
31
}
31
32
}
32
33
33
- suspend fun refresh (): AuthFlowResponse {
34
+ suspend fun refresh (sessionToken : String ): AuthFlowResponse {
34
35
return try {
35
- httpClient.get(" ${Config .authBaseUrl} /self-service/login/api?refresh=true" ).body()
36
+ httpClient.get(" ${Config .authBaseUrl} /self-service/login/api?refresh=true" ) {
37
+ headers {
38
+ header(" X-Session-Token" , sessionToken)
39
+ }
40
+ }.body()
36
41
} catch (e: ClientRequestException ) {
37
42
throw ApiClientException (" Failed to initiate auth" , e.response, e)
38
43
} catch (e: Exception ) {
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ class AuthRouterTest {
105
105
106
106
runBlocking {
107
107
assertFailsWith<ApiException > {
108
- authRouter.refresh()
108
+ authRouter.refresh(" sess-123 " )
109
109
}
110
110
}
111
111
}
@@ -123,7 +123,7 @@ class AuthRouterTest {
123
123
val authRouter = AuthRouter (httpClient = HttpClient (mockEngine).configureForTest())
124
124
125
125
runBlocking {
126
- val response = authRouter.refresh()
126
+ val response = authRouter.refresh(" sess-123 " )
127
127
assertEquals(" test-123" , response.id)
128
128
}
129
129
}
You can’t perform that action at this time.
0 commit comments