-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4239 from element-hq/feature/bma/fixNightlyReports2
Fix nightly reports - next step
- Loading branch information
Showing
4 changed files
with
149 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
.../src/test/kotlin/io/element/android/features/lockscreen/impl/unlock/PinUnlockStateTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright 2025 New Vector Ltd. | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial | ||
* Please see LICENSE files in the repository root for full details. | ||
*/ | ||
|
||
package io.element.android.features.lockscreen.impl.unlock | ||
|
||
import androidx.biometric.BiometricPrompt | ||
import com.google.common.truth.Truth.assertThat | ||
import io.element.android.features.lockscreen.impl.biometric.BiometricAuthenticator | ||
import io.element.android.features.lockscreen.impl.biometric.BiometricUnlockError | ||
import io.element.android.libraries.architecture.AsyncData | ||
import org.junit.Test | ||
|
||
class PinUnlockStateTest { | ||
@Test | ||
fun `isSignOutPromptCancellable should have expected values`() { | ||
assertThat(aPinUnlockState(remainingAttempts = AsyncData.Uninitialized).isSignOutPromptCancellable).isTrue() | ||
assertThat(aPinUnlockState(remainingAttempts = AsyncData.Success(1)).isSignOutPromptCancellable).isTrue() | ||
assertThat(aPinUnlockState(remainingAttempts = AsyncData.Success(0)).isSignOutPromptCancellable).isFalse() | ||
} | ||
|
||
@Test | ||
fun `biometricUnlockErrorMessage and showBiometricUnlockError should have expected values`() { | ||
listOf( | ||
null, | ||
BiometricAuthenticator.AuthenticationResult.Failure(), | ||
BiometricAuthenticator.AuthenticationResult.Success, | ||
).forEach { biometricUnlockResult -> | ||
aPinUnlockState( | ||
biometricUnlockResult = biometricUnlockResult, | ||
).let { | ||
assertThat(it.biometricUnlockErrorMessage).isNull() | ||
assertThat(it.showBiometricUnlockError).isFalse() | ||
} | ||
} | ||
listOf( | ||
BiometricPrompt.ERROR_HW_UNAVAILABLE, | ||
BiometricPrompt.ERROR_UNABLE_TO_PROCESS, | ||
BiometricPrompt.ERROR_TIMEOUT, | ||
BiometricPrompt.ERROR_NO_SPACE, | ||
BiometricPrompt.ERROR_CANCELED, | ||
BiometricPrompt.ERROR_VENDOR, | ||
BiometricPrompt.ERROR_USER_CANCELED, | ||
BiometricPrompt.ERROR_NO_BIOMETRICS, | ||
BiometricPrompt.ERROR_HW_NOT_PRESENT, | ||
BiometricPrompt.ERROR_NEGATIVE_BUTTON, | ||
BiometricPrompt.ERROR_NO_DEVICE_CREDENTIAL, | ||
BiometricPrompt.ERROR_SECURITY_UPDATE_REQUIRED, | ||
).forEach { code -> | ||
aPinUnlockState( | ||
biometricUnlockResult = BiometricAuthenticator.AuthenticationResult.Failure( | ||
error = BiometricUnlockError(code, "Error message") | ||
), | ||
).let { | ||
assertThat(it.biometricUnlockErrorMessage).isNull() | ||
assertThat(it.showBiometricUnlockError).isFalse() | ||
} | ||
} | ||
listOf( | ||
BiometricPrompt.ERROR_LOCKOUT, | ||
BiometricPrompt.ERROR_LOCKOUT_PERMANENT, | ||
).forEach { code -> | ||
aPinUnlockState( | ||
biometricUnlockResult = BiometricAuthenticator.AuthenticationResult.Failure( | ||
error = BiometricUnlockError(code, "Error message") | ||
), | ||
).let { | ||
assertThat(it.biometricUnlockErrorMessage).isEqualTo("Error message") | ||
assertThat(it.showBiometricUnlockError).isTrue() | ||
} | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...st/kotlin/io/element/android/features/securebackup/impl/root/SecureBackupRootStateTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright 2025 New Vector Ltd. | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial | ||
* Please see LICENSE files in the repository root for full details. | ||
*/ | ||
|
||
package io.element.android.features.securebackup.impl.root | ||
|
||
import com.google.common.truth.Truth.assertThat | ||
import io.element.android.libraries.architecture.AsyncData | ||
import io.element.android.libraries.matrix.api.encryption.BackupState | ||
import io.element.android.libraries.matrix.test.AN_EXCEPTION | ||
import org.junit.Test | ||
|
||
class SecureBackupRootStateTest { | ||
@Test | ||
fun `isKeyStorageEnabled should be true for all these backup states`() { | ||
listOf( | ||
BackupState.CREATING, | ||
BackupState.ENABLING, | ||
BackupState.RESUMING, | ||
BackupState.DOWNLOADING, | ||
BackupState.ENABLED, | ||
).forEach { backupState -> | ||
assertThat(aSecureBackupRootState(backupState = backupState).isKeyStorageEnabled).isTrue() | ||
} | ||
} | ||
|
||
@Test | ||
fun `isKeyStorageEnabled should be false for all these backup states`() { | ||
listOf( | ||
BackupState.WAITING_FOR_SYNC, | ||
BackupState.DISABLING, | ||
).forEach { backupState -> | ||
assertThat(aSecureBackupRootState(backupState = backupState).isKeyStorageEnabled).isFalse() | ||
} | ||
} | ||
|
||
@Test | ||
fun `isKeyStorageEnabled should have value depending on doesBackupExistOnServer when state is UNKNOWN`() { | ||
assertThat( | ||
aSecureBackupRootState( | ||
backupState = BackupState.UNKNOWN, | ||
doesBackupExistOnServer = AsyncData.Success(true), | ||
).isKeyStorageEnabled | ||
).isTrue() | ||
|
||
listOf( | ||
AsyncData.Uninitialized, | ||
AsyncData.Loading(), | ||
AsyncData.Failure(AN_EXCEPTION), | ||
AsyncData.Success(false), | ||
).forEach { doesBackupExistOnServer -> | ||
assertThat( | ||
aSecureBackupRootState( | ||
backupState = BackupState.UNKNOWN, | ||
doesBackupExistOnServer = doesBackupExistOnServer, | ||
).isKeyStorageEnabled | ||
).isFalse() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters