@@ -17,7 +17,6 @@ package io.getstream.android.core.internal.http.interceptor
1717
1818import io.getstream.android.core.api.authentication.StreamTokenManager
1919import io.getstream.android.core.api.model.exceptions.StreamEndpointErrorData
20- import io.getstream.android.core.api.model.exceptions.StreamEndpointException
2120import io.getstream.android.core.api.model.value.StreamToken
2221import io.getstream.android.core.api.serialization.StreamJsonSerialization
2322import io.mockk.MockKAnnotations
@@ -28,7 +27,6 @@ import io.mockk.impl.annotations.MockK
2827import io.mockk.verify
2928import java.util.concurrent.TimeUnit
3029import kotlin.test.assertEquals
31- import kotlin.test.assertFailsWith
3230import kotlin.test.assertTrue
3331import okhttp3.Interceptor
3432import okhttp3.OkHttpClient
@@ -196,7 +194,7 @@ class StreamAuthInterceptorTest {
196194 // Proper token error code handled by this interceptor
197195 val tokenError = tokenErrorData(40 )
198196 every { json.fromJson(any(), StreamEndpointErrorData ::class .java) } returns
199- Result .success(tokenError)
197+ Result .success(tokenError)
200198
201199 val interceptor = StreamAuthInterceptor (tokenManager, json, authType = " jwt" )
202200 val client = client(interceptor)
@@ -205,15 +203,18 @@ class StreamAuthInterceptorTest {
205203
206204 val url = server.url(" /v1/protected" )
207205
208- client.newCall(
209- Request .Builder ()
210- .url(url)
211- .header(" x-stream-retried-on-auth" , " present" ) // simulate already retried
212- .build()
213- ).execute().use { resp ->
214- assertFalse(resp.isSuccessful) // pass-through, no exception here
215- assertEquals(401 , resp.code)
216- }
206+ client
207+ .newCall(
208+ Request .Builder ()
209+ .url(url)
210+ .header(" x-stream-retried-on-auth" , " present" ) // simulate already retried
211+ .build()
212+ )
213+ .execute()
214+ .use { resp ->
215+ assertFalse(resp.isSuccessful) // pass-through, no exception here
216+ assertEquals(401 , resp.code)
217+ }
217218
218219 val first = server.takeRequest(2 , TimeUnit .SECONDS )
219220 kotlin.test.assertNotNull(first)
@@ -225,9 +226,7 @@ class StreamAuthInterceptorTest {
225226 coVerify(exactly = 0 ) { tokenManager.refresh() }
226227 }
227228
228- /* *
229- * Non-token error codes are NOT handled here; pass response through without retry.
230- */
229+ /* * Non-token error codes are NOT handled here; pass response through without retry. */
231230 @Test
232231 fun `non-token error passes through without retry` () {
233232 val token = streamToken(" t1" )
@@ -236,7 +235,7 @@ class StreamAuthInterceptorTest {
236235 // e.g., business error code that is not 40/41/42
237236 val nonTokenError = tokenErrorData(13 )
238237 every { json.fromJson(any(), StreamEndpointErrorData ::class .java) } returns
239- Result .success(nonTokenError)
238+ Result .success(nonTokenError)
240239
241240 val interceptor = StreamAuthInterceptor (tokenManager, json, authType = " jwt" )
242241 val client = client(interceptor)
@@ -258,16 +257,14 @@ class StreamAuthInterceptorTest {
258257 coVerify(exactly = 0 ) { tokenManager.refresh() }
259258 }
260259
261- /* *
262- * If the error body cannot be parsed into StreamEndpointErrorData, pass through.
263- */
260+ /* * If the error body cannot be parsed into StreamEndpointErrorData, pass through. */
264261 @Test
265262 fun `unparsable error body passes through without retry` () {
266263 val token = streamToken(" t1" )
267264 coEvery { tokenManager.loadIfAbsent() } returns Result .success(token)
268265
269266 every { json.fromJson(any(), StreamEndpointErrorData ::class .java) } returns
270- Result .failure(IllegalStateException (" bad json" ))
267+ Result .failure(IllegalStateException (" bad json" ))
271268
272269 val interceptor = StreamAuthInterceptor (tokenManager, json, authType = " jwt" )
273270 val client = client(interceptor)
@@ -291,7 +288,6 @@ class StreamAuthInterceptorTest {
291288 coVerify(exactly = 0 ) { tokenManager.refresh() }
292289 }
293290
294-
295291 // ----------------- Helpers -----------------
296292
297293 private fun client (interceptor : Interceptor ): OkHttpClient =
0 commit comments