File tree Expand file tree Collapse file tree
SalesforceSDK/src/com/salesforce/androidsdk/auth
test/SalesforceSDKTest/src/com/salesforce/androidsdk/auth Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -145,6 +145,7 @@ internal class NativeLoginManager(
145145 CONTENT_TYPE_HEADER_NAME to CONTENT_TYPE_VALUE_HTTP_POST ,
146146 AUTHORIZATION to " $AUTH_AUTHORIZATION_VALUE_BASIC $encodedCreds " ,
147147 )
148+ // TODO: Needs Coverage. ECJ20260416
148149 val attestationValue = getInstance().appAttestationClient?.createSalesforceOAuthAuthorizationAppAttestation()
149150 val authRequestBody = createRequestBody(
150151 ATTESTATION to attestationValue,
@@ -242,9 +243,10 @@ internal class NativeLoginManager(
242243 }
243244 }
244245
245- private fun createRequestBody (vararg kvPairs : Pair <String , String ?>): RequestBody {
246- kvPairs.filter { it.second != null }
247- val requestBodyString = kvPairs.joinToString(" &" ) { (key, value) -> " $key =$value " }
246+ @VisibleForTesting
247+ internal fun createRequestBody (vararg kvPairs : Pair <String , String ?>): RequestBody {
248+ // TODO: Needs Coverage. ECJ20260416
249+ val requestBodyString = kvPairs.filter { it.second != null }.joinToString(" &" ) { (key, value) -> " $key =$value " }
248250 val mediaType = CONTENT_TYPE_VALUE_HTTP_POST .toMediaTypeOrNull()
249251 return requestBodyString.toRequestBody(mediaType)
250252 }
Original file line number Diff line number Diff line change @@ -8,12 +8,11 @@ import com.salesforce.androidsdk.app.SalesforceSDKManager
88import com.salesforce.androidsdk.security.BiometricAuthenticationManager
99import org.junit.After
1010import org.junit.Assert
11+ import org.junit.Assert.assertEquals
1112import org.junit.Before
12- import org.junit.Ignore
1313import org.junit.Test
1414import org.junit.runner.RunWith
1515
16- @Ignore
1716@RunWith(AndroidJUnit4 ::class )
1817@SmallTest
1918class NativeLoginManagerTest {
@@ -90,8 +89,17 @@ class NativeLoginManagerTest {
9089 Assert .assertEquals(" Should return username." , " test_username" , mgr.biometricAuthenticationUsername)
9190 }
9291
92+ @Test
93+ fun nativeLoginManager_createRequestBody_filtersNullValues () {
94+
95+ val result = mgr.createRequestBody(" key1" to " value1" , " key2" to null )
96+
97+ val buffer = okio.Buffer ()
98+ result.writeTo(buffer)
99+ assertEquals(" key1=value1" , buffer.readUtf8())
100+ }
93101
94102 private fun addUserAccount () {
95- UserAccountManager .getInstance().createAccount(UserAccountTest .createTestAccount());
103+ UserAccountManager .getInstance().createAccount(UserAccountTest .createTestAccount())
96104 }
97105}
You can’t perform that action at this time.
0 commit comments