diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /services/sync/tests/unit/test_service_wipeClient.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream/115.8.0esr.tar.xz firefox-esr-upstream/115.8.0esr.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'services/sync/tests/unit/test_service_wipeClient.js')
-rw-r--r-- | services/sync/tests/unit/test_service_wipeClient.js | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/services/sync/tests/unit/test_service_wipeClient.js b/services/sync/tests/unit/test_service_wipeClient.js new file mode 100644 index 0000000000..aa48868ca0 --- /dev/null +++ b/services/sync/tests/unit/test_service_wipeClient.js @@ -0,0 +1,78 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +const { Service } = ChromeUtils.importESModule( + "resource://services-sync/service.sys.mjs" +); + +function CanDecryptEngine() { + SyncEngine.call(this, "CanDecrypt", Service); +} +CanDecryptEngine.prototype = { + // Override these methods with mocks for the test + async canDecrypt() { + return true; + }, + + wasWiped: false, + async wipeClient() { + this.wasWiped = true; + }, +}; +Object.setPrototypeOf(CanDecryptEngine.prototype, SyncEngine.prototype); + +function CannotDecryptEngine() { + SyncEngine.call(this, "CannotDecrypt", Service); +} +CannotDecryptEngine.prototype = { + // Override these methods with mocks for the test + async canDecrypt() { + return false; + }, + + wasWiped: false, + async wipeClient() { + this.wasWiped = true; + }, +}; +Object.setPrototypeOf(CannotDecryptEngine.prototype, SyncEngine.prototype); + +let canDecryptEngine; +let cannotDecryptEngine; + +add_task(async function setup() { + await Service.engineManager.clear(); + + await Service.engineManager.register(CanDecryptEngine); + await Service.engineManager.register(CannotDecryptEngine); + canDecryptEngine = Service.engineManager.get("candecrypt"); + cannotDecryptEngine = Service.engineManager.get("cannotdecrypt"); +}); + +add_task(async function test_withEngineList() { + try { + _("Ensure initial scenario."); + Assert.ok(!canDecryptEngine.wasWiped); + Assert.ok(!cannotDecryptEngine.wasWiped); + + _("Wipe local engine data."); + await Service.wipeClient(["candecrypt", "cannotdecrypt"]); + + _("Ensure only the engine that can decrypt was wiped."); + Assert.ok(canDecryptEngine.wasWiped); + Assert.ok(!cannotDecryptEngine.wasWiped); + } finally { + canDecryptEngine.wasWiped = false; + cannotDecryptEngine.wasWiped = false; + await Service.startOver(); + } +}); + +add_task(async function test_startOver_clears_keys() { + syncTestLogging(); + await generateNewKeys(Service.collectionKeys); + Assert.ok(!!Service.collectionKeys.keyForCollection()); + await Service.startOver(); + syncTestLogging(); + Assert.ok(!Service.collectionKeys.keyForCollection()); +}); |