(cherry picked from commit 4bd8eeb17a)
Co-authored-by: Hubert Chathi <hubert@uhoreg.ca>
This commit is contained in:
@@ -438,7 +438,10 @@ export default class DeviceListener {
|
|||||||
// said we are OK with that.
|
// said we are OK with that.
|
||||||
const keyBackupIsOk = keyBackupUploadActive || backupDisabled;
|
const keyBackupIsOk = keyBackupUploadActive || backupDisabled;
|
||||||
|
|
||||||
const backupKeyCached = (await crypto.getSessionBackupPrivateKey()) !== null;
|
// If key backup is active and not disabled: do we have the backup key
|
||||||
|
// cached locally?
|
||||||
|
const backupKeyCached =
|
||||||
|
!keyBackupUploadActive || backupDisabled || (await crypto.getSessionBackupPrivateKey()) !== null;
|
||||||
|
|
||||||
const allSystemsReady =
|
const allSystemsReady =
|
||||||
isCurrentDeviceTrusted && allCrossSigningSecretsCached && keyBackupIsOk && recoveryIsOk && backupKeyCached;
|
isCurrentDeviceTrusted && allCrossSigningSecretsCached && keyBackupIsOk && recoveryIsOk && backupKeyCached;
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ describe("DeviceListener", () => {
|
|||||||
expect(SetupEncryptionToast.hideToast).toHaveBeenCalled();
|
expect(SetupEncryptionToast.hideToast).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows an out-of-sync toast when one of the secrets is missing locally", async () => {
|
it("shows an out-of-sync toast when one of the cross-signing secrets is missing locally", async () => {
|
||||||
mockCrypto!.getCrossSigningStatus.mockResolvedValue({
|
mockCrypto!.getCrossSigningStatus.mockResolvedValue({
|
||||||
publicKeysOnDevice: true,
|
publicKeysOnDevice: true,
|
||||||
privateKeysInSecretStorage: true,
|
privateKeysInSecretStorage: true,
|
||||||
@@ -385,6 +385,30 @@ describe("DeviceListener", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("shows an out-of-sync toast when the backup key is missing locally", async () => {
|
||||||
|
mockCrypto!.getSecretStorageStatus.mockResolvedValue(readySecretStorageStatus);
|
||||||
|
mockCrypto!.getActiveSessionBackupVersion.mockResolvedValue("1");
|
||||||
|
mockCrypto!.getSessionBackupPrivateKey.mockResolvedValue(null);
|
||||||
|
|
||||||
|
await createAndStart();
|
||||||
|
|
||||||
|
expect(SetupEncryptionToast.showToast).toHaveBeenCalledWith(
|
||||||
|
SetupEncryptionToast.Kind.KEY_STORAGE_OUT_OF_SYNC,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not show an out-of-sync toast when the backup key is missing locally but backup is purposely disabled", async () => {
|
||||||
|
mockCrypto!.getSecretStorageStatus.mockResolvedValue(readySecretStorageStatus);
|
||||||
|
mockCrypto!.getSessionBackupPrivateKey.mockResolvedValue(null);
|
||||||
|
mockClient.getAccountDataFromServer.mockImplementation((eventType) =>
|
||||||
|
eventType === BACKUP_DISABLED_ACCOUNT_DATA_KEY ? ({ disabled: true } as any) : null,
|
||||||
|
);
|
||||||
|
|
||||||
|
await createAndStart();
|
||||||
|
|
||||||
|
expect(SetupEncryptionToast.hideToast).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
it("hides the out-of-sync toast after we receive the missing secrets", async () => {
|
it("hides the out-of-sync toast after we receive the missing secrets", async () => {
|
||||||
mockCrypto!.getSecretStorageStatus.mockResolvedValue(readySecretStorageStatus);
|
mockCrypto!.getSecretStorageStatus.mockResolvedValue(readySecretStorageStatus);
|
||||||
mockCrypto!.getActiveSessionBackupVersion.mockResolvedValue("1");
|
mockCrypto!.getActiveSessionBackupVersion.mockResolvedValue("1");
|
||||||
|
|||||||
Reference in New Issue
Block a user