This repository has been archived by the owner on Dec 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into OWP-37_biometrics
- Loading branch information
Showing
19 changed files
with
191 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
android/src/main/kotlin/com/onegini/mobile/sdk/flutter/useCases/GetIdTokenUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.onegini.mobile.sdk.flutter.useCases | ||
|
||
import com.onegini.mobile.sdk.flutter.OneWelcomeWrapperErrors.ID_TOKEN_NOT_AVAILABLE | ||
import com.onegini.mobile.sdk.flutter.OneginiSDK | ||
import com.onegini.mobile.sdk.flutter.helpers.SdkError | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class GetIdTokenUseCase @Inject constructor(private val oneginiSDK: OneginiSDK) { | ||
operator fun invoke(): Result<String> { | ||
oneginiSDK.oneginiClient.userClient.idToken?.let { idtoken -> | ||
return Result.success(idtoken) | ||
} | ||
return Result.failure(SdkError(ID_TOKEN_NOT_AVAILABLE).pigeonError()) | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
android/src/test/java/com/onegini/mobile/sdk/GetIdTokenUseCaseTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.onegini.mobile.sdk | ||
|
||
import com.onegini.mobile.sdk.flutter.OneWelcomeWrapperErrors.* | ||
import com.onegini.mobile.sdk.flutter.OneginiSDK | ||
import com.onegini.mobile.sdk.flutter.SdkErrorAssert | ||
import com.onegini.mobile.sdk.flutter.useCases.GetIdTokenUseCase | ||
import org.junit.Assert | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.mockito.Answers | ||
import org.mockito.Mock | ||
import org.mockito.junit.MockitoJUnitRunner | ||
import org.mockito.kotlin.whenever | ||
|
||
@RunWith(MockitoJUnitRunner::class) | ||
class GetIdTokenUseCaseTests { | ||
@Mock(answer = Answers.RETURNS_DEEP_STUBS) | ||
lateinit var oneginiSdk: OneginiSDK | ||
|
||
private lateinit var getIdTokenUseCase: GetIdTokenUseCase | ||
|
||
@Before | ||
fun attach() { | ||
getIdTokenUseCase = GetIdTokenUseCase(oneginiSdk) | ||
} | ||
|
||
@Test | ||
fun `When the idToken is null, Then should return error as ID_TOKEN_NOT_AVAILABLE`() { | ||
whenever(oneginiSdk.oneginiClient.userClient.idToken).thenReturn(null) | ||
|
||
val result = getIdTokenUseCase().exceptionOrNull() | ||
SdkErrorAssert.assertEquals(ID_TOKEN_NOT_AVAILABLE, result) | ||
} | ||
|
||
@Test | ||
fun `When the idToken exists, Then should return the idToken`() { | ||
whenever(oneginiSdk.oneginiClient.userClient.idToken).thenReturn("test id token") | ||
|
||
val result = getIdTokenUseCase() | ||
|
||
Assert.assertEquals(result.getOrNull(), "test id token") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.