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

Commit

Permalink
add error handler to filtering (#526)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sashei committed Mar 22, 2019
1 parent 180f4c4 commit ada2de4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import br.com.concretesolutions.kappuccino.actions.TextActions.typeText
import br.com.concretesolutions.kappuccino.assertions.VisibilityAssertions.displayed
import mozilla.lockbox.R

// Filter ItemList
// SearchFallback ItemList
class FilteredItemListRobot : BaseTestRobot {
override fun exists() = displayed { id(R.id.filterField) }

Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/mozilla/lockbox/LockboxAutofillService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ class LockboxAutofillService(
is DataStore.State.Errored -> AutofillAction.Error(state.error)
}
}
.subscribe(dispatcher::dispatch)
.onErrorReturnItem(AutofillAction.SearchFallback)
.subscribe(dispatcher::dispatch) {
log.error(throwable = it)
}
.addTo(compositeDisposable)

autofillStore.autofillActions
Expand All @@ -104,6 +107,7 @@ class LockboxAutofillService(
is AutofillAction.Complete -> builder.buildFilteredFillResponse(this, listOf(it.login)).asOptional()
is AutofillAction.CompleteMultiple -> (builder.buildFilteredFillResponse(this, it.logins)
?: builder.buildFallbackFillResponse(this)).asOptional()
is AutofillAction.SearchFallback -> builder.buildFallbackFillResponse(this).asOptional()
is AutofillAction.Authenticate -> builder.buildAuthenticationFillResponse(this).asOptional()
is AutofillAction.Cancel -> Optional(null)
is AutofillAction.Error -> {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/mozilla/lockbox/action/AutofillAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ sealed class AutofillAction(
data class Complete(val login: ServerPassword) : AutofillAction(TelemetryEventMethod.autofill_single, TelemetryEventObject.autofill)
data class CompleteMultiple(val logins: List<ServerPassword>) : AutofillAction(TelemetryEventMethod.autofill_multiple, TelemetryEventObject.autofill)
data class Error(val error: Throwable) : AutofillAction(TelemetryEventMethod.autofill_error, TelemetryEventObject.autofill)
object SearchFallback : AutofillAction(TelemetryEventMethod.autofill_filter, TelemetryEventObject.autofill)
object Authenticate : AutofillAction(TelemetryEventMethod.autofill_locked, TelemetryEventObject.autofill)
object Cancel : AutofillAction(TelemetryEventMethod.autofill_cancel, TelemetryEventObject.autofill)
}
3 changes: 2 additions & 1 deletion app/src/main/java/mozilla/lockbox/action/TelemetryAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ enum class TelemetryEventMethod {
autofill_single,
autofill_multiple,
autofill_cancel,
autofill_error
autofill_error,
autofill_filter
}

enum class TelemetryEventObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class FixedDataStoreSupport(
) : DataStoreSupport {
var size = getRandomInRange(40, 50)
private val logins = MemoryLoginsStorage(
values ?: List(size) { createDummyItem(it) })
values ?: List(size) { createDummyItem(it) } + listOf(createDummyIPItem())
)

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

Expand Down Expand Up @@ -67,6 +68,29 @@ internal fun createDummyItem(idx: Int): ServerPassword {
)
}

internal fun createDummyIPItem(): ServerPassword {
val random = Random()
val id = UUID.randomUUID().toString()
val pwd = createRandomPassword()
val host = "http://10.250.7.80"
val user = createUserId()
val created = Date().time
val used = Date(created - 86400000).time
val changed = Date(used - 86400000).time

return ServerPassword(
id = id,
hostname = host,
username = user,
password = pwd,
formSubmitURL = host,
timeCreated = created,
timeLastUsed = used,
timePasswordChanged = changed,
timesUsed = random.nextInt(100) + 1
)
}

internal fun createRandomPassword(): String {
return UUID.randomUUID().toString().substring(0..20)
}
Expand Down

0 comments on commit ada2de4

Please sign in to comment.