@@ -84,6 +84,7 @@ import com.duckduckgo.sync.store.ScopedPassword
8484import com.duckduckgo.sync.store.SyncStore
8585import com.squareup.moshi.Moshi
8686import kotlinx.coroutines.test.TestScope
87+ import kotlinx.coroutines.test.runTest
8788import org.junit.Assert.assertEquals
8889import org.junit.Assert.assertFalse
8990import org.junit.Assert.assertNull
@@ -1247,7 +1248,7 @@ class AppSyncAccountRepositoryTest {
12471248 // Per-manager logic is covered in ThirdPartyCredentialManagerTest and ProtectedKeyManagerTest.
12481249
12491250 @Test
1250- fun whenCreateThirdPartyCredentialThenDelegatesToManager () {
1251+ fun whenCreateThirdPartyCredentialThenDelegatesToManager () = runTest {
12511252 whenever(thirdPartyCredentialManager.create()).thenReturn(Success (true ))
12521253
12531254 val result = syncRepo.createThirdPartyCredential()
@@ -1307,7 +1308,7 @@ class AppSyncAccountRepositoryTest {
13071308 // joinAccountFromThirdPartyRecoveryCode
13081309
13091310 @Test
1310- fun whenJoinAccountFromThirdPartyAndAllStepsSucceedThenAtomicStoreUsesDdgTokenFromSecondLogin () {
1311+ fun whenJoinAccountFromThirdPartyAndAllStepsSucceedThenAtomicStoreUsesDdgTokenFromSecondLogin () = runTest {
13111312 val pastedCode = prepareForJoinAccountFromThirdPartyRecoveryCode()
13121313
13131314 val result = syncRepo.joinAccountFromThirdPartyRecoveryCode(pastedCode)
@@ -1325,7 +1326,7 @@ class AppSyncAccountRepositoryTest {
13251326 }
13261327
13271328 @Test
1328- fun whenJoinAccountFromThirdPartyThenStep7aPostUpgradeLoginUsesUnrestrictedScope () {
1329+ fun whenJoinAccountFromThirdPartyThenStep7aPostUpgradeLoginUsesUnrestrictedScope () = runTest {
13291330 val pastedCode = prepareForJoinAccountFromThirdPartyRecoveryCode()
13301331
13311332 syncRepo.joinAccountFromThirdPartyRecoveryCode(pastedCode)
@@ -1350,7 +1351,7 @@ class AppSyncAccountRepositoryTest {
13501351 }
13511352
13521353 @Test
1353- fun whenStep7aPostUpgradeLoginReturns401ThenAbortsWithoutAtomicStore () {
1354+ fun whenStep7aPostUpgradeLoginReturns401ThenAbortsWithoutAtomicStore () = runTest {
13541355 val pastedCode = prepareForJoinAccountFromThirdPartyRecoveryCode(step7aResult = step7aLoginUnauthorized)
13551356
13561357 val result = syncRepo.joinAccountFromThirdPartyRecoveryCode(pastedCode)
@@ -1361,7 +1362,7 @@ class AppSyncAccountRepositoryTest {
13611362 }
13621363
13631364 @Test
1364- fun whenStep7aPostUpgradeLoginFailsWithNon401ThenAbortsWithoutAtomicStore () {
1365+ fun whenStep7aPostUpgradeLoginFailsWithNon401ThenAbortsWithoutAtomicStore () = runTest {
13651366 val pastedCode = prepareForJoinAccountFromThirdPartyRecoveryCode(step7aResult = step7aLoginServerError)
13661367
13671368 val result = syncRepo.joinAccountFromThirdPartyRecoveryCode(pastedCode)
@@ -1375,7 +1376,7 @@ class AppSyncAccountRepositoryTest {
13751376 }
13761377
13771378 @Test
1378- fun whenJoinAccountFromThirdPartyAndAccountAlreadyHasDdgCredentialThenAbortsBeforePost () {
1379+ fun whenJoinAccountFromThirdPartyAndAccountAlreadyHasDdgCredentialThenAbortsBeforePost () = runTest {
13791380 val pastedCode = prepareForJoinAccountFromThirdPartyRecoveryCode(accountAlreadyHasDdg = true )
13801381
13811382 val result = syncRepo.joinAccountFromThirdPartyRecoveryCode(pastedCode)
@@ -1388,7 +1389,7 @@ class AppSyncAccountRepositoryTest {
13881389 }
13891390
13901391 @Test
1391- fun whenStep7PostRateLimitedThenRetriesAndSucceeds () {
1392+ fun whenStep7PostRateLimitedThenRetriesAndSucceeds () = runTest {
13921393 val pastedCode = prepareForJoinAccountFromThirdPartyRecoveryCode()
13931394 whenever(syncApi.createAccessCredential(anyString(), eq(" ddg" ), any()))
13941395 .thenReturn(Error (code = API_CODE .TOO_MANY_REQUESTS_2 .code, reason = " rate limited" ), Success (true ))
@@ -1400,7 +1401,7 @@ class AppSyncAccountRepositoryTest {
14001401 }
14011402
14021403 @Test
1403- fun whenStep7aLoginServerErrorThenRetriesAndSucceeds () {
1404+ fun whenStep7aLoginServerErrorThenRetriesAndSucceeds () = runTest {
14041405 val pastedCode = prepareForJoinAccountFromThirdPartyRecoveryCode()
14051406 whenever(syncApi.login(eq(userId), any(), eq(deviceId), any(), any(), eq<String ?>(null )))
14061407 .thenReturn(step7aLoginServerError, step7aLoginSuccess)
@@ -1420,7 +1421,7 @@ class AppSyncAccountRepositoryTest {
14201421 }
14211422
14221423 @Test
1423- fun whenStep7aLoginTransportErrorThenRetriesAndSucceeds () {
1424+ fun whenStep7aLoginTransportErrorThenRetriesAndSucceeds () = runTest {
14241425 val pastedCode = prepareForJoinAccountFromThirdPartyRecoveryCode()
14251426 whenever(syncApi.login(eq(userId), any(), eq(deviceId), any(), any(), eq<String ?>(null )))
14261427 .thenReturn(step7aLoginTransportError, step7aLoginSuccess)
@@ -1432,7 +1433,7 @@ class AppSyncAccountRepositoryTest {
14321433 }
14331434
14341435 @Test
1435- fun whenStep7aLogin401ThenAbortsWithoutRetry () {
1436+ fun whenStep7aLogin401ThenAbortsWithoutRetry () = runTest {
14361437 val pastedCode = prepareForJoinAccountFromThirdPartyRecoveryCode(step7aResult = step7aLoginUnauthorized)
14371438
14381439 val result = syncRepo.joinAccountFromThirdPartyRecoveryCode(pastedCode)
@@ -1443,7 +1444,7 @@ class AppSyncAccountRepositoryTest {
14431444 }
14441445
14451446 @Test
1446- fun whenStep7Post409AlreadyExistsThenAbortsWithoutRetry () {
1447+ fun whenStep7Post409AlreadyExistsThenAbortsWithoutRetry () = runTest {
14471448 val pastedCode = prepareForJoinAccountFromThirdPartyRecoveryCode()
14481449 whenever(syncApi.createAccessCredential(anyString(), eq(" ddg" ), any()))
14491450 .thenReturn(Error (code = API_CODE .COUNT_LIMIT .code, reason = " already exists" ))
@@ -1456,7 +1457,7 @@ class AppSyncAccountRepositoryTest {
14561457 }
14571458
14581459 @Test
1459- fun whenStep7PostRateLimitedBeyondRetryLimitThenAbortsWithoutStore () {
1460+ fun whenStep7PostRateLimitedBeyondRetryLimitThenAbortsWithoutStore () = runTest {
14601461 val pastedCode = prepareForJoinAccountFromThirdPartyRecoveryCode()
14611462 whenever(syncApi.createAccessCredential(anyString(), eq(" ddg" ), any()))
14621463 .thenReturn(Error (code = API_CODE .TOO_MANY_REQUESTS_1 .code, reason = " rate limited" ))
@@ -1470,7 +1471,7 @@ class AppSyncAccountRepositoryTest {
14701471 }
14711472
14721473 @Test
1473- fun whenJoinAccountFromThirdPartyAndCodeIsLaterMinorVersionThenAccepted () {
1474+ fun whenJoinAccountFromThirdPartyAndCodeIsLaterMinorVersionThenAccepted () = runTest {
14741475 val pastedCode = prepareForJoinAccountFromThirdPartyRecoveryCode(version = " 2.5" )
14751476
14761477 val result = syncRepo.joinAccountFromThirdPartyRecoveryCode(pastedCode)
@@ -1479,7 +1480,7 @@ class AppSyncAccountRepositoryTest {
14791480 }
14801481
14811482 @Test
1482- fun whenJoinAccountFromThirdPartyAndCodeIsBareMajorVersionThenAccepted () {
1483+ fun whenJoinAccountFromThirdPartyAndCodeIsBareMajorVersionThenAccepted () = runTest {
14831484 // "2" is the spec's common shorthand for "2.0" (Transport TD 1214486492252757).
14841485 val pastedCode = prepareForJoinAccountFromThirdPartyRecoveryCode(version = " 2" )
14851486
@@ -1489,7 +1490,7 @@ class AppSyncAccountRepositoryTest {
14891490 }
14901491
14911492 @Test
1492- fun whenJoinAccountFromThirdPartyAndCodeIsMajorVersion3ThenRejectedWithoutNetwork () {
1493+ fun whenJoinAccountFromThirdPartyAndCodeIsMajorVersion3ThenRejectedWithoutNetwork () = runTest {
14931494 val pastedCode = prepareForJoinAccountFromThirdPartyRecoveryCode(version = " 3.0" )
14941495
14951496 val result = syncRepo.joinAccountFromThirdPartyRecoveryCode(pastedCode)
@@ -1499,7 +1500,7 @@ class AppSyncAccountRepositoryTest {
14991500 }
15001501
15011502 @Test
1502- fun whenJoinAccountFromThirdPartyAndCodeCidIsNotThirdPartyThenRejectedWithoutNetwork () {
1503+ fun whenJoinAccountFromThirdPartyAndCodeCidIsNotThirdPartyThenRejectedWithoutNetwork () = runTest {
15031504 val pastedCode = prepareForJoinAccountFromThirdPartyRecoveryCode(cid = " ddg" )
15041505
15051506 val result = syncRepo.joinAccountFromThirdPartyRecoveryCode(pastedCode)
0 commit comments