Skip to content

Change requirement for marking a previous password import as having happened #6281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ class CredentialImporterImpl @Inject constructor(

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

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

_importStatus.emit(Finished(savedCredentials = insertedIds.size, numberSkipped = skippedCredentials))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import org.junit.Rule
import org.junit.Test
import org.mockito.kotlin.any
import org.mockito.kotlin.mock
import org.mockito.kotlin.never
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever

Expand Down Expand Up @@ -119,17 +118,17 @@ class CredentialImporterImplTest {
}

@Test
fun whenImportingNoCredentialsThenHasEverImportedPasswordsIsNotSet() = runTest {
fun whenImportingNoCredentialsThenHasEverImportedPasswordsIsStillSet() = runTest {
listOf<LoginCredentials>().import()
verify(autofillStore, never()).hasEverImportedPasswords = true
verify(autofillStore).hasEverImportedPasswords = true
}

@Test
fun whenImportingOnlyDuplicatesThenHasEverImportedPasswordsIsNotSet() = runTest {
fun whenImportingOnlyDuplicatesThenHasEverImportedPasswordsIsStillSet() = runTest {
val duplicatedLogin = creds(username = "username")
duplicatedLogin.treatAsDuplicate()
listOf(duplicatedLogin).import()
verify(autofillStore, never()).hasEverImportedPasswords = true
verify(autofillStore).hasEverImportedPasswords = true
}

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