Add override for Core val in test
parent
6e907b1106
commit
d85ed27a3d
|
@ -21,7 +21,7 @@ class Components(private val context: Context) {
|
||||||
core.historyStorage,
|
core.historyStorage,
|
||||||
core.bookmarksStorage,
|
core.bookmarksStorage,
|
||||||
core.passwordsStorage,
|
core.passwordsStorage,
|
||||||
core.secureAbove22Preferences
|
core.getSecureAbove22Preferences()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val services by lazy { Services(context, backgroundServices.accountManager) }
|
val services by lazy { Services(context, backgroundServices.accountManager) }
|
||||||
|
|
|
@ -191,19 +191,17 @@ class Core(private val context: Context) {
|
||||||
* Shared Preferences that encrypt/decrypt using Android KeyStore and lib-dataprotect for 23+
|
* Shared Preferences that encrypt/decrypt using Android KeyStore and lib-dataprotect for 23+
|
||||||
* otherwise simply stored
|
* otherwise simply stored
|
||||||
*/
|
*/
|
||||||
val secureAbove22Preferences by lazy {
|
fun getSecureAbove22Preferences() = SecureAbove22Preferences(context, KEY_STORAGE_NAME)
|
||||||
SecureAbove22Preferences(context, KEY_STORAGE_NAME)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val passwordsEncryptionKey =
|
private val passwordsEncryptionKey: String =
|
||||||
secureAbove22Preferences.getString(PASSWORDS_KEY)
|
getSecureAbove22Preferences().getString(PASSWORDS_KEY)
|
||||||
?: generateEncryptionKey(KEY_STRENGTH).also {
|
?: generateEncryptionKey(KEY_STRENGTH).also {
|
||||||
if (context.settings().passwordsEncryptionKeyGenerated) {
|
if (context.settings().passwordsEncryptionKeyGenerated) {
|
||||||
// We already had previously generated an encryption key, but we have lost it
|
// We already had previously generated an encryption key, but we have lost it
|
||||||
Sentry.capture("Passwords encryption key for passwords storage was lost and we generated a new one")
|
Sentry.capture("Passwords encryption key for passwords storage was lost and we generated a new one")
|
||||||
}
|
}
|
||||||
context.settings().recordPasswordsEncryptionKeyGenerated()
|
context.settings().recordPasswordsEncryptionKeyGenerated()
|
||||||
secureAbove22Preferences.putString(PASSWORDS_KEY, it)
|
getSecureAbove22Preferences().putString(PASSWORDS_KEY, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,6 +10,7 @@ import mozilla.components.browser.engine.gecko.GeckoEngine
|
||||||
import mozilla.components.browser.session.SessionManager
|
import mozilla.components.browser.session.SessionManager
|
||||||
import mozilla.components.browser.state.store.BrowserStore
|
import mozilla.components.browser.state.store.BrowserStore
|
||||||
import mozilla.components.feature.pwa.WebAppShortcutManager
|
import mozilla.components.feature.pwa.WebAppShortcutManager
|
||||||
|
import mozilla.components.lib.dataprotect.SecureAbove22Preferences
|
||||||
|
|
||||||
class TestCore(context: Context) : Core(context) {
|
class TestCore(context: Context) : Core(context) {
|
||||||
|
|
||||||
|
@ -17,4 +18,5 @@ class TestCore(context: Context) : Core(context) {
|
||||||
override val sessionManager = SessionManager(engine)
|
override val sessionManager = SessionManager(engine)
|
||||||
override val store = mockk<BrowserStore>()
|
override val store = mockk<BrowserStore>()
|
||||||
override val webAppShortcutManager = mockk<WebAppShortcutManager>()
|
override val webAppShortcutManager = mockk<WebAppShortcutManager>()
|
||||||
|
override fun getSecureAbove22Preferences() = mockk<SecureAbove22Preferences>(relaxed = true)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue