Skip to content

Commit a798768

Browse files
committed
Fix FrontDoorBridge verifier test.
1 parent 4d76d3a commit a798768

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

libs/test/SalesforceSDKTest/src/com/salesforce/androidsdk/auth/LoginViewModelMockTest.kt

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ class LoginViewModelMockTest {
7373
mockCookieManager = mockk<CookieManager>(relaxed = true)
7474
every { CookieManager.getInstance() } returns mockCookieManager
7575

76+
// Mock OAuth2 and AuthenticationUtilities
77+
mockkStatic(OAuth2::class)
78+
mockkStatic("com.salesforce.androidsdk.auth.AuthenticationUtilitiesKt")
79+
7680
// Create view model after mocking
7781
viewModel = LoginViewModel(bootConfig)
7882

@@ -94,7 +98,6 @@ class LoginViewModelMockTest {
9498
@Test
9599
fun onAuthFlowComplete_CallsAuthenticationUtilities_WithCorrectParameters() = runBlocking {
96100
// Mock the AuthenticationUtilities.onAuthFlowComplete function
97-
mockkStatic("com.salesforce.androidsdk.auth.AuthenticationUtilitiesKt")
98101

99102
// Mock the function to do nothing (just capture parameters)
100103
coEvery {
@@ -163,7 +166,6 @@ class LoginViewModelMockTest {
163166
@Test
164167
fun onAuthFlowComplete_CallsAuthenticationUtilitiesSuccessfully() = runBlocking {
165168
// Mock the AuthenticationUtilities.onAuthFlowComplete function
166-
mockkStatic("com.salesforce.androidsdk.auth.AuthenticationUtilitiesKt")
167169

168170
coEvery {
169171
onAuthFlowComplete(
@@ -230,7 +232,6 @@ class LoginViewModelMockTest {
230232
@Test
231233
fun onAuthFlowComplete_ResetsAuthCodeForJwtFlow() = runBlocking {
232234
// Mock the AuthenticationUtilities.onAuthFlowComplete function
233-
mockkStatic("com.salesforce.androidsdk.auth.AuthenticationUtilitiesKt")
234235

235236
coEvery {
236237
onAuthFlowComplete(
@@ -278,7 +279,6 @@ class LoginViewModelMockTest {
278279
@Test
279280
fun onAuthFlowComplete_UsesEmptyString_WhenSelectedServerIsNull() = runBlocking {
280281
// Mock the AuthenticationUtilities.onAuthFlowComplete function
281-
mockkStatic("com.salesforce.androidsdk.auth.AuthenticationUtilitiesKt")
282282

283283
coEvery {
284284
onAuthFlowComplete(
@@ -343,17 +343,13 @@ class LoginViewModelMockTest {
343343

344344
@Test
345345
fun doCodeExchange_CallsExchangeCode_WithCorrectParameters() = runBlocking {
346-
// Mock OAuth2.exchangeCode
347-
mockkStatic(OAuth2::class)
348-
349346
val testServer = "https://test.salesforce.com"
350347
val testCode = "test_auth_code_123"
351348
val mockTokenResponse = mockk<TokenEndpointResponse>(relaxed = true)
352349
val mockOnError: (String, String?, Throwable?) -> Unit = mockk(relaxed = true)
353350
val mockOnSuccess: (UserAccount) -> Unit = mockk(relaxed = true)
354351

355352
// Mock AuthenticationUtilities.onAuthFlowComplete to prevent actual execution
356-
mockkStatic("com.salesforce.androidsdk.auth.AuthenticationUtilitiesKt")
357353
coEvery {
358354
onAuthFlowComplete(
359355
tokenResponse = any(),
@@ -408,9 +404,6 @@ class LoginViewModelMockTest {
408404

409405
@Test
410406
fun doCodeExchange_WithFrontDoorBridge_UsesCorrectServerAndVerifier() = runBlocking {
411-
// Mock OAuth2.exchangeCode
412-
mockkStatic(OAuth2::class)
413-
414407
val frontDoorServer = "https://frontdoor.salesforce.com"
415408
val frontDoorUrl = "$frontDoorServer/frontdoor.jsp?sid=test_session"
416409
val frontDoorVerifier = "frontdoor_verifier_789"
@@ -420,7 +413,6 @@ class LoginViewModelMockTest {
420413
val mockOnSuccess: (UserAccount) -> Unit = mockk(relaxed = true)
421414

422415
// Mock AuthenticationUtilities.onAuthFlowComplete
423-
mockkStatic("com.salesforce.androidsdk.auth.AuthenticationUtilitiesKt")
424416
coEvery {
425417
onAuthFlowComplete(
426418
tokenResponse = any(),
@@ -482,16 +474,12 @@ class LoginViewModelMockTest {
482474

483475
@Test
484476
fun doCodeExchange_WithNullCode_PassesNullToExchangeCode() = runBlocking {
485-
// Mock OAuth2.exchangeCode
486-
mockkStatic(OAuth2::class)
487-
488477
val testServer = "https://test.salesforce.com"
489478
val mockTokenResponse = mockk<TokenEndpointResponse>(relaxed = true)
490479
val mockOnError: (String, String?, Throwable?) -> Unit = mockk(relaxed = true)
491480
val mockOnSuccess: (UserAccount) -> Unit = mockk(relaxed = true)
492481

493482
// Mock AuthenticationUtilities.onAuthFlowComplete
494-
mockkStatic("com.salesforce.androidsdk.auth.AuthenticationUtilitiesKt")
495483
coEvery {
496484
onAuthFlowComplete(
497485
tokenResponse = any(),

0 commit comments

Comments
 (0)