Skip to content

Commit 40d3cc5

Browse files
committed
Change requirement for marking a previous password import as having happened
1 parent ebc6508 commit 40d3cc5

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/importing/CredentialImporter.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,8 @@ class CredentialImporterImpl @Inject constructor(
8686

8787
skippedCredentials += (importList.size - insertedIds.size)
8888

89-
// Set the flag when at least one credential was successfully imported
90-
if (insertedIds.isNotEmpty()) {
91-
autofillStore.hasEverImportedPasswords = true
92-
}
89+
// mark that the user has imported passwords at least once, regardless of the number of credentials imported
90+
autofillStore.hasEverImportedPasswords = true
9391

9492
_importStatus.emit(Finished(savedCredentials = insertedIds.size, numberSkipped = skippedCredentials))
9593
}

autofill/autofill-impl/src/test/java/com/duckduckgo/autofill/impl/importing/CredentialImporterImplTest.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import org.junit.Rule
1313
import org.junit.Test
1414
import org.mockito.kotlin.any
1515
import org.mockito.kotlin.mock
16-
import org.mockito.kotlin.never
1716
import org.mockito.kotlin.verify
1817
import org.mockito.kotlin.whenever
1918

@@ -119,17 +118,17 @@ class CredentialImporterImplTest {
119118
}
120119

121120
@Test
122-
fun whenImportingNoCredentialsThenHasEverImportedPasswordsIsNotSet() = runTest {
121+
fun whenImportingNoCredentialsThenHasEverImportedPasswordsIsStillSet() = runTest {
123122
listOf<LoginCredentials>().import()
124-
verify(autofillStore, never()).hasEverImportedPasswords = true
123+
verify(autofillStore).hasEverImportedPasswords = true
125124
}
126125

127126
@Test
128-
fun whenImportingOnlyDuplicatesThenHasEverImportedPasswordsIsNotSet() = runTest {
127+
fun whenImportingOnlyDuplicatesThenHasEverImportedPasswordsIsStillSet() = runTest {
129128
val duplicatedLogin = creds(username = "username")
130129
duplicatedLogin.treatAsDuplicate()
131130
listOf(duplicatedLogin).import()
132-
verify(autofillStore, never()).hasEverImportedPasswords = true
131+
verify(autofillStore).hasEverImportedPasswords = true
133132
}
134133

135134
private suspend fun List<LoginCredentials>.import(originalListSize: Int = this.size) {

0 commit comments

Comments
 (0)