File tree Expand file tree Collapse file tree
libs/test/SalesforceSDKTest/src/com/salesforce/androidsdk/auth Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -433,6 +433,43 @@ class NativeLoginManagerTest {
433433 }
434434 }
435435
436+ @OptIn(ExperimentalCoroutinesApi ::class )
437+ @Test
438+ fun nativeLoginManager_login_togglesAttestationWhenNullOrPresent () = runTest {
439+ // Branch 1: attestationValue is null
440+ val restClientNullAttestation = createRestClientStubbingFailedLoginResponse()
441+ mgr = createNativeLoginManagerForTest(restClient = restClientNullAttestation)
442+
443+ mgr.login(TEST_USERNAME , TEST_PASSWORD )
444+ advanceUntilIdle()
445+
446+ // Verify URL does NOT contain attestation parameter (elvis branch)
447+ verify(exactly = 1 ) {
448+ restClientNullAttestation.sendAsync(match {
449+ it.path == " $TEST_LOGIN_URL$OAUTH_AUTH_PATH " && ! it.path.contains(" attestation=" )
450+ }, any())
451+ }
452+
453+ // Clean up
454+ tearDown()
455+ setUp()
456+
457+ // Branch 2: attestationValue is not null (let block with Uri.encode)
458+ installAppAttestationClient(attestation = TEST_APP_ATTESTATION )
459+ val restClientWithAttestation = createRestClientStubbingFailedLoginResponse()
460+ mgr = createNativeLoginManagerForTest(restClient = restClientWithAttestation)
461+
462+ mgr.login(TEST_USERNAME , TEST_PASSWORD )
463+ advanceUntilIdle()
464+
465+ // Verify URL DOES contain encoded attestation parameter (let branch)
466+ verify(exactly = 1 ) {
467+ restClientWithAttestation.sendAsync(match {
468+ it.path.contains(" ?attestation=" ) && it.path.contains(TEST_APP_ATTESTATION )
469+ }, any())
470+ }
471+ }
472+
436473 // region Helpers used by attestation tests
437474
438475 private fun installAppAttestationClient (attestation : String? ) {
You can’t perform that action at this time.
0 commit comments