From 9cffb9c4b6cf67398778ca823d48b50800ef0154 Mon Sep 17 00:00:00 2001 From: Sina <65910646+SinaSeylani@users.noreply.github.com> Date: Thu, 10 Oct 2024 12:43:00 -0600 Subject: [PATCH 1/2] settoken added to refresh token func --- passage/src/main/java/id/passage/android/PassageTokenStore.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/passage/src/main/java/id/passage/android/PassageTokenStore.kt b/passage/src/main/java/id/passage/android/PassageTokenStore.kt index 3268399..b16ee3b 100644 --- a/passage/src/main/java/id/passage/android/PassageTokenStore.kt +++ b/passage/src/main/java/id/passage/android/PassageTokenStore.kt @@ -93,6 +93,7 @@ class PassageTokenStore( } catch (e: Exception) { throw PassageTokenException.convert(e) } + setTokens(apiAuthResult) return apiAuthResult } From f623b5d1df946a570ee15317f8471982051cc3ca Mon Sep 17 00:00:00 2001 From: Sina <65910646+SinaSeylani@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:26:32 -0600 Subject: [PATCH 2/2] Test added --- .../java/id/passage/android/TokenStoreTests.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/passage/src/androidTest/java/id/passage/android/TokenStoreTests.kt b/passage/src/androidTest/java/id/passage/android/TokenStoreTests.kt index e431ac9..6560572 100644 --- a/passage/src/androidTest/java/id/passage/android/TokenStoreTests.kt +++ b/passage/src/androidTest/java/id/passage/android/TokenStoreTests.kt @@ -17,6 +17,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.runTest import org.junit.After +import org.junit.Assert.assertNotSame import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Rule @@ -167,4 +168,18 @@ internal class TokenStoreTests { assertThat(e is PassageTokenException) } } + + @Test + fun refreshWithValidToken(): Unit = + runBlocking { + try { + val currentRefreshToken = refreshToken + val authResult = passage.tokenStore.refreshAuthToken(currentRefreshToken) + val newStoredRefreshToken = passage.tokenStore.refreshToken + assertNotNull(authResult) + assertNotSame(currentRefreshToken, newStoredRefreshToken) + } catch (e: Exception) { + assertThat(e is PassageTokenException) + } + } }