mirror of
https://github.com/element-hq/element-desktop
synced 2025-04-21 09:03:56 +02:00
Iterate
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
c2e6f80efb
commit
bb314423bf
@ -7,6 +7,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { platform } from "node:os";
|
||||
import keytar from "keytar-forked";
|
||||
|
||||
import { test, expect } from "../../element-desktop-test.js";
|
||||
|
||||
@ -19,6 +20,7 @@ declare global {
|
||||
supportsEventIndexing(): Promise<boolean>;
|
||||
}
|
||||
| undefined;
|
||||
getPickleKey(userId: string, deviceId: string): Promise<string | null>;
|
||||
createPickleKey(userId: string, deviceId: string): Promise<string | null>;
|
||||
};
|
||||
};
|
||||
@ -46,17 +48,33 @@ test.describe("App launch", () => {
|
||||
).resolves.toBeTruthy();
|
||||
});
|
||||
|
||||
test("should launch and render the welcome view successfully and support safeStorage", async ({ page }) => {
|
||||
// test.skip(platform() === "linux", "This test does not yet support Linux");
|
||||
test.describe("safeStorage", () => {
|
||||
test.skip(platform() === "linux", "The linux runner has no compatible wallet/keychain");
|
||||
test.skip(platform() === "darwin", "The macOS runner's keychain is not available");
|
||||
|
||||
const userId = "@user:server";
|
||||
const deviceId = "ABCDEF";
|
||||
|
||||
test("should be supported", async ({ page }) => {
|
||||
await expect(
|
||||
page.evaluate<string | null>(async () => {
|
||||
return await window.mxPlatformPeg.get().createPickleKey("@user:server", "ABCDEF");
|
||||
}),
|
||||
page.evaluate(() => window.mxPlatformPeg.get().createPickleKey(userId, deviceId)),
|
||||
).resolves.not.toBeNull();
|
||||
});
|
||||
|
||||
// TODO test keytar migration
|
||||
test.describe("migrate from keytar", () => {
|
||||
const pickleKey = "DEADBEEF1234";
|
||||
|
||||
test.beforeEach(async () => {
|
||||
await keytar.setPassword("element.io", `${userId}|${deviceId}`, pickleKey);
|
||||
});
|
||||
|
||||
test("should migrate successfully", async ({ page }) => {
|
||||
await expect(
|
||||
page.evaluate(() => window.mxPlatformPeg.get().getPickleKey(userId, deviceId)),
|
||||
).resolves.toBe(pickleKey);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("--no-update", () => {
|
||||
test.use({
|
||||
|
@ -89,10 +89,10 @@ export class Store extends ElectronStore<{
|
||||
* @throws if safeStorage is not available.
|
||||
*/
|
||||
public async migrate(): Promise<void> {
|
||||
console.log("Store migration: started");
|
||||
if (this.has("safeStorage")) return;
|
||||
console.info("Store migration: started");
|
||||
if (!safeStorage.isEncryptionAvailable()) {
|
||||
console.log("Store migration: safeStorage is not available");
|
||||
console.error("Store migration: safeStorage is not available");
|
||||
throw new Error("safeStorage is not available");
|
||||
}
|
||||
|
||||
@ -100,11 +100,11 @@ export class Store extends ElectronStore<{
|
||||
...(await keytar.findCredentials(LEGACY_KEYTAR_SERVICE)),
|
||||
...(await keytar.findCredentials(KEYTAR_SERVICE)),
|
||||
];
|
||||
console.log("Store migration:", credentials);
|
||||
for (const cred of credentials) {
|
||||
await this.deleteSecret(cred.account); // delete from keytar & keytar legacy
|
||||
await this.setSecret(cred.account, cred.password); // write to safeStorage & keytar for downgrade compatibility
|
||||
}
|
||||
console.info(`Store migration done: found ${credentials.length} credentials`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user