mirror of
https://github.com/bitwarden/android.git
synced 2024-11-22 17:36:01 +03:00
Expose the 'shouldTrustDevice' boolean from auth repo (#1220)
This commit is contained in:
parent
7f331a5ff2
commit
22a6825992
3 changed files with 22 additions and 0 deletions
|
@ -89,6 +89,11 @@ interface AuthRepository : AuthenticatorProvider, AuthRequestManager {
|
|||
*/
|
||||
var rememberedOrgIdentifier: String?
|
||||
|
||||
/**
|
||||
* The currently persisted state indicating whether the user has trusted this device.
|
||||
*/
|
||||
var shouldTrustDevice: Boolean
|
||||
|
||||
/**
|
||||
* Tracks whether there is an additional account that is pending login/registration in order to
|
||||
* have multiple accounts available.
|
||||
|
|
|
@ -252,6 +252,8 @@ class AuthRepositoryImpl(
|
|||
|
||||
override var rememberedOrgIdentifier: String? by authDiskSource::rememberedOrgIdentifier
|
||||
|
||||
override var shouldTrustDevice: Boolean by authDiskSource::shouldTrustDevice
|
||||
|
||||
override var hasPendingAccountAddition: Boolean
|
||||
by mutableHasPendingAccountAdditionStateFlow::value
|
||||
|
||||
|
|
|
@ -518,6 +518,21 @@ class AuthRepositoryTest {
|
|||
assertNull(repository.rememberedOrgIdentifier)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `shouldTrustDevice should directly access the authDiskSource`() {
|
||||
// AuthDiskSource and the repository start with the same default value.
|
||||
assertFalse(repository.shouldTrustDevice)
|
||||
assertFalse(fakeAuthDiskSource.shouldTrustDevice)
|
||||
|
||||
// Updating the repository updates AuthDiskSource
|
||||
repository.shouldTrustDevice = true
|
||||
assertTrue(fakeAuthDiskSource.shouldTrustDevice)
|
||||
|
||||
// Updating AuthDiskSource updates the repository
|
||||
fakeAuthDiskSource.shouldTrustDevice = false
|
||||
assertFalse(repository.shouldTrustDevice)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `passwordResetReason should pull from the user's profile in AuthDiskSource`() = runTest {
|
||||
val updatedProfile = ACCOUNT_1.profile.copy(
|
||||
|
|
Loading…
Reference in a new issue