mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-27 03:23:20 +00:00
Preserve device E2EE settings during remote rebuild
This commit is contained in:
1 parent
011a8405b5
commit
b28871ab67
4 files changed
+193
-6
No files matched your search
@@ -1149,6 +1149,33 @@ describe("Red Flag Feature", () => {
|
||||
});
|
||||
|
||||
describe("Remote configuration adjustment", () => {
|
||||
it("keeps this device's E2EE settings when preparing to overwrite the remote", async () => {
|
||||
const host = createHostMock();
|
||||
Object.assign(host.mocks.setting.settings, TweakValuesShouldMatchedTemplate, {
|
||||
encrypt: true,
|
||||
passphrase: "local-encryption-passphrase",
|
||||
});
|
||||
host.mocks.tweakValue.fetchRemotePreferred.mockResolvedValueOnce(
|
||||
availableRemoteTweaks({
|
||||
...TweakValuesShouldMatchedTemplate,
|
||||
encrypt: false,
|
||||
})
|
||||
);
|
||||
|
||||
const result = await adjustSettingToRemote(
|
||||
host as any,
|
||||
createLoggerMock(),
|
||||
host.mocks.setting.currentSettings(),
|
||||
"rebuild"
|
||||
);
|
||||
|
||||
expect(result).toBe(true);
|
||||
expect(host.mocks.tweakValue.fetchRemotePreferred).toHaveBeenCalledOnce();
|
||||
expect(host.mocks.setting.currentSettings().encrypt).toBe(true);
|
||||
expect(host.mocks.setting.currentSettings().passphrase).toBe("local-encryption-passphrase");
|
||||
expect(host.mocks.setting.applyExternalSettings).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should skip remote configuration fetch when preventFetchingConfig is true", async () => {
|
||||
const host = createHostMock();
|
||||
const config = { preventFetchingConfig: true } as any;
|
||||
@@ -1855,8 +1882,15 @@ describe("Red Flag Feature", () => {
|
||||
it("should handle rebuildAll flag with flagHandlerToEventHandler", async () => {
|
||||
const host = createHostMock();
|
||||
const log = createLoggerMock();
|
||||
Object.assign(host.mocks.setting.settings, TweakValuesShouldMatchedTemplate, {
|
||||
encrypt: true,
|
||||
passphrase: "local-encryption-passphrase",
|
||||
});
|
||||
host.mocks.tweakValue.fetchRemotePreferred.mockResolvedValueOnce(
|
||||
availableRemoteTweaks({ customChunkSize: 1 })
|
||||
availableRemoteTweaks({
|
||||
...TweakValuesShouldMatchedTemplate,
|
||||
encrypt: false,
|
||||
})
|
||||
);
|
||||
|
||||
host.mocks.storageAccess.files.add(FlagFilesOriginal.REBUILD_ALL);
|
||||
@@ -1868,6 +1902,8 @@ describe("Red Flag Feature", () => {
|
||||
await Promise.resolve(eventHandler());
|
||||
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
expect(host.mocks.rebuilder.$rebuildEverything).toHaveBeenCalled();
|
||||
expect(host.mocks.setting.currentSettings().encrypt).toBe(true);
|
||||
expect(host.mocks.setting.applyExternalSettings).not.toHaveBeenCalled();
|
||||
|
||||
expect(host.mocks.ui.dialogManager.openWithExplicitCancel).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user