Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
51
gaia/apps/sharedtest/test/unit/sync/sync-engine/fxsyncwebcrypto-mock.js
Executable file
51
gaia/apps/sharedtest/test/unit/sync/sync-engine/fxsyncwebcrypto-mock.js
Executable file
|
|
@ -0,0 +1,51 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
'use strict';
|
||||
|
||||
/* global SynctoServerFixture */
|
||||
/* exported FxSyncWebCrypto */
|
||||
|
||||
requireApp('sharedtest/test/unit/sync/fixtures/synctoserver.js');
|
||||
|
||||
var FxSyncWebCrypto = function() {};
|
||||
FxSyncWebCrypto.prototype = {
|
||||
setKeys: function(kB, cryptoKeys) {
|
||||
this.shouldWork = true;
|
||||
if (kB !== SynctoServerFixture.syncEngineOptions.kB) {
|
||||
this.shouldWork = false;
|
||||
}
|
||||
var correctCryptoKeys = JSON.parse(
|
||||
SynctoServerFixture.remoteData.crypto.payload);
|
||||
if (cryptoKeys.ciphertext !== correctCryptoKeys.ciphertext ||
|
||||
cryptoKeys.IV !== correctCryptoKeys.IV ||
|
||||
cryptoKeys.hmac !== correctCryptoKeys.hmac) {
|
||||
this.shouldWork = false;
|
||||
}
|
||||
if (this.shouldWork) {
|
||||
this.bulkKeyBundle = true;
|
||||
return Promise.resolve();
|
||||
}
|
||||
return Promise.reject(`SyncKeys hmac could not be verified with current mai\
|
||||
n key`);
|
||||
},
|
||||
encrypt: function(payload) {
|
||||
if (this.shouldWork) {
|
||||
return Promise.resolve({ mockEncrypted: JSON.stringify(payload) });
|
||||
}
|
||||
return Promise.reject();
|
||||
},
|
||||
decrypt: function(record) {
|
||||
var decryptablePayload = JSON.parse(
|
||||
SynctoServerFixture.remoteData.history.payload);
|
||||
if (this.shouldWork &&
|
||||
record.ciphertext === decryptablePayload.ciphertext &&
|
||||
record.IV === decryptablePayload.IV &&
|
||||
record.hmac === decryptablePayload.hmac) {
|
||||
return Promise.resolve(
|
||||
SynctoServerFixture.historyEntryDec.payload);
|
||||
}
|
||||
return Promise.reject(new Error(
|
||||
'payload.ciphertext is not a Base64 string'));
|
||||
}
|
||||
};
|
||||
Loading…
Reference in a new issue