@@ -109,7 +109,11 @@ class NativeLoginManagerTest {
109109 assertEquals(" key1=value1" , buffer.readUtf8())
110110 }
111111
112- // TODO: This test will need additional review. ECJ20260416
112+ /* *
113+ * Tests that native login uses the app attestation during login. This test
114+ * can be removed when a comprehensive test of native login is created so
115+ * long as that test covers the inclusion of the attestation parameter.
116+ */
113117 @OptIn(ExperimentalCoroutinesApi ::class )
114118 @Test
115119 fun nativeLoginManager_login_collectsAppAttestation () = runTest {
@@ -153,6 +157,49 @@ class NativeLoginManagerTest {
153157 }
154158 }
155159
160+ /* *
161+ * Tests that native login does not include app attestation during login
162+ * when it is not applicable. This test can be removed when a comprehensive
163+ * test of native login is created so long as that test covers the exclusion
164+ * of the attestation parameter.
165+ */
166+ @OptIn(ExperimentalCoroutinesApi ::class )
167+ @Test
168+ fun nativeLoginManager_login_doesNotCollectAppAttestationWhenAppAttestationClientIsNotSet () = runTest {
169+
170+ val restClient = mockk<RestClient >(relaxed = true )
171+ val mockResponse = mockk<RestResponse >(relaxed = true )
172+ every { mockResponse.isSuccess } returns false
173+ every {
174+ restClient.sendAsync(any(), any())
175+ } answers {
176+ val callback = secondArg<RestClient .AsyncRequestCallback >()
177+ callback.onSuccess(firstArg(), mockResponse)
178+ mockk<Call >(relaxed = true )
179+ }
180+
181+ mgr = NativeLoginManager (
182+ clientId = " clientId" ,
183+ redirectUri = " redirect" ,
184+ loginUrl = " loginUrl" ,
185+ restClient = restClient,
186+ )
187+
188+ mgr.login(" TestUser@Example.com" , " test123456" )
189+
190+ advanceUntilIdle()
191+
192+ verify(exactly = 1 ) {
193+ restClient.sendAsync(match {
194+ runCatching {
195+ val buffer = okio.Buffer ()
196+ it.requestBody?.writeTo(buffer)
197+ ! buffer.readUtf8().contains(" attestation=" )
198+ }.getOrDefault(false )
199+ }, any())
200+ }
201+ }
202+
156203 private fun addUserAccount () {
157204 UserAccountManager .getInstance().createAccount(UserAccountTest .createTestAccount())
158205 }
0 commit comments