Skip to content
This repository was archived by the owner on Dec 14, 2021. It is now read-only.

Commit ada2de4

Browse files
committed
add error handler to filtering (#526)
* add error handler to filtering * push user to search dialog when PSL errors * new autofillaction, IP in test data * functioning "bad" IP * rename filter to searchfallback
1 parent 180f4c4 commit ada2de4

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

app/src/androidTest/java/mozilla/lockbox/robots/FilteredItemListRobot.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import br.com.concretesolutions.kappuccino.actions.TextActions.typeText
1010
import br.com.concretesolutions.kappuccino.assertions.VisibilityAssertions.displayed
1111
import mozilla.lockbox.R
1212

13-
// Filter ItemList
13+
// SearchFallback ItemList
1414
class FilteredItemListRobot : BaseTestRobot {
1515
override fun exists() = displayed { id(R.id.filterField) }
1616

app/src/main/java/mozilla/lockbox/LockboxAutofillService.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ class LockboxAutofillService(
9595
is DataStore.State.Errored -> AutofillAction.Error(state.error)
9696
}
9797
}
98-
.subscribe(dispatcher::dispatch)
98+
.onErrorReturnItem(AutofillAction.SearchFallback)
99+
.subscribe(dispatcher::dispatch) {
100+
log.error(throwable = it)
101+
}
99102
.addTo(compositeDisposable)
100103

101104
autofillStore.autofillActions
@@ -104,6 +107,7 @@ class LockboxAutofillService(
104107
is AutofillAction.Complete -> builder.buildFilteredFillResponse(this, listOf(it.login)).asOptional()
105108
is AutofillAction.CompleteMultiple -> (builder.buildFilteredFillResponse(this, it.logins)
106109
?: builder.buildFallbackFillResponse(this)).asOptional()
110+
is AutofillAction.SearchFallback -> builder.buildFallbackFillResponse(this).asOptional()
107111
is AutofillAction.Authenticate -> builder.buildAuthenticationFillResponse(this).asOptional()
108112
is AutofillAction.Cancel -> Optional(null)
109113
is AutofillAction.Error -> {

app/src/main/java/mozilla/lockbox/action/AutofillAction.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ sealed class AutofillAction(
1515
data class Complete(val login: ServerPassword) : AutofillAction(TelemetryEventMethod.autofill_single, TelemetryEventObject.autofill)
1616
data class CompleteMultiple(val logins: List<ServerPassword>) : AutofillAction(TelemetryEventMethod.autofill_multiple, TelemetryEventObject.autofill)
1717
data class Error(val error: Throwable) : AutofillAction(TelemetryEventMethod.autofill_error, TelemetryEventObject.autofill)
18+
object SearchFallback : AutofillAction(TelemetryEventMethod.autofill_filter, TelemetryEventObject.autofill)
1819
object Authenticate : AutofillAction(TelemetryEventMethod.autofill_locked, TelemetryEventObject.autofill)
1920
object Cancel : AutofillAction(TelemetryEventMethod.autofill_cancel, TelemetryEventObject.autofill)
2021
}

app/src/main/java/mozilla/lockbox/action/TelemetryAction.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ enum class TelemetryEventMethod {
5252
autofill_single,
5353
autofill_multiple,
5454
autofill_cancel,
55-
autofill_error
55+
autofill_error,
56+
autofill_filter
5657
}
5758

5859
enum class TelemetryEventObject {

app/src/main/java/mozilla/lockbox/support/FixedDataStoreSupport.kt

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class FixedDataStoreSupport(
2121
) : DataStoreSupport {
2222
var size = getRandomInRange(40, 50)
2323
private val logins = MemoryLoginsStorage(
24-
values ?: List(size) { createDummyItem(it) })
24+
values ?: List(size) { createDummyItem(it) } + listOf(createDummyIPItem())
25+
)
2526

2627
override var encryptionKey: String = "shh-keep-it-secret"
2728

@@ -67,6 +68,29 @@ internal fun createDummyItem(idx: Int): ServerPassword {
6768
)
6869
}
6970

71+
internal fun createDummyIPItem(): ServerPassword {
72+
val random = Random()
73+
val id = UUID.randomUUID().toString()
74+
val pwd = createRandomPassword()
75+
val host = "http://10.250.7.80"
76+
val user = createUserId()
77+
val created = Date().time
78+
val used = Date(created - 86400000).time
79+
val changed = Date(used - 86400000).time
80+
81+
return ServerPassword(
82+
id = id,
83+
hostname = host,
84+
username = user,
85+
password = pwd,
86+
formSubmitURL = host,
87+
timeCreated = created,
88+
timeLastUsed = used,
89+
timePasswordChanged = changed,
90+
timesUsed = random.nextInt(100) + 1
91+
)
92+
}
93+
7094
internal fun createRandomPassword(): String {
7195
return UUID.randomUUID().toString().substring(0..20)
7296
}

0 commit comments

Comments
 (0)