Expose the 'shouldTrustDevice' boolean from auth repo (#1220)

This commit is contained in:
David Perez 2024-04-03 15:47:33 -05:00 committed by Álison Fernandes
parent 7f331a5ff2
commit 22a6825992
3 changed files with 22 additions and 0 deletions

View file

@ -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.

View file

@ -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

View file

@ -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(