Backed out changeset f1cb395e11d5 (bug 1752609) for causing build bustages on FuzzingFunctions.cpp. CLOSED TREE

This commit is contained in:
Marian-Vasile Laza 2022-02-04 07:24:33 +02:00
Родитель e704102060
Коммит eac85c4fd0
3 изменённых файлов: 5 добавлений и 160 удалений

Просмотреть файл

@ -350,17 +350,11 @@ class SendTab {
}
async _decrypt(ciphertext) {
let sendTabKeys = await this._getPersistedSendTabKeys();
if (!sendTabKeys) {
// If we lost the user's send tab keys for any reason,
// `generateAndPersistEncryptedSendTabKeys` will regenerate the send tab keys,
// persist them, then persist an encrypted bundle of the keys.
// It should be impossible for us to hit this for new devices
// this was added to recover users who hit Bug 1752609
await this._generateAndPersistEncryptedSendTabKey();
sendTabKeys = await this._getPersistedSendTabKeys();
}
let { privateKey, publicKey, authSecret } = sendTabKeys;
let {
privateKey,
publicKey,
authSecret,
} = await this._getPersistedSendTabKeys();
publicKey = urlsafeBase64Decode(publicKey);
authSecret = urlsafeBase64Decode(authSecret);
ciphertext = new Uint8Array(urlsafeBase64Decode(ciphertext));

Просмотреть файл

@ -487,7 +487,6 @@ class FxAccountsDevice {
try {
await currentState.updateUserAccountData({
device: null,
encryptedSendTabKeys: null,
});
} catch (error) {
await this._logErrorAndResetDeviceRegistrationVersion(
@ -523,7 +522,6 @@ class FxAccountsDevice {
id: deviceId,
registrationVersion: null,
},
encryptedSendTabKeys: null,
});
return deviceId;
}
@ -555,7 +553,6 @@ class FxAccountsDevice {
try {
await currentState.updateUserAccountData({
device: null,
encryptedSendTabKeys: null,
});
} catch (secondError) {
log.error(

Просмотреть файл

@ -575,149 +575,3 @@ add_task(
Assert.equal(accountState.data.device.lastCommandIndex, 12);
}
);
add_task(async function test_send_tab_keys_regenerated_if_lost() {
const commands = {
_invokes: [],
invoke(cmd, device, payload) {
this._invokes.push({ cmd, device, payload });
},
};
// Local state.
const accountState = {
data: {
// Since the device object has no
// sendTabKeys, when we _decrypt,
// we will attempt to regenerate the
// keys.
device: {
lastCommandIndex: 10,
},
encryptedSendTabKeys: "keys",
},
getUserAccountData() {
return this.data;
},
updateUserAccountData(data) {
this.data = data;
},
};
const fxAccounts = {
async withCurrentAccountState(cb) {
await cb(accountState);
},
async getUserAccountData(data) {
return accountState.getUserAccountData(data);
},
telemetry: new TelemetryMock(),
};
const sendTab = new SendTab(commands, fxAccounts);
sendTab._encrypt = (bytes, device) => {
return bytes;
};
let generateEncryptedKeysCalled = false;
sendTab._generateAndPersistEncryptedSendTabKey = async () => {
generateEncryptedKeysCalled = true;
};
sendTab._fxai = fxAccounts;
const tab = { title: "tab title", url: "http://example.com" };
const to = [{ id: "devid", name: "The Device" }];
const reason = "push";
await sendTab.send(to, tab);
Assert.equal(commands._invokes.length, 1);
for (let { cmd, device, payload } of commands._invokes) {
Assert.equal(cmd, COMMAND_SENDTAB);
sendTab._fxai = fxAccounts;
try {
await sendTab.handle(device.id, payload, reason);
} catch {
// The `handle` function will throw an error
// since we are not mocking the `_decrypt`
// function. This is intentional, since
// we want to capture that `_decrypt` will
// call `_generateEncryptedSendTabKeys` if
// it fails to retrieve the keys.
// Receiving a send tab is covered
// in the above test_sendtab_receive test.
}
}
Assert.ok(generateEncryptedKeysCalled);
});
add_task(async function test_send_tab_keys_are_not_regenerated_if_not_lost() {
const commands = {
_invokes: [],
invoke(cmd, device, payload) {
this._invokes.push({ cmd, device, payload });
},
};
// Local state.
const accountState = {
data: {
// Since the device object has
// sendTabKeys, when we _decrypt,
// we will not try to regenerate them
device: {
lastCommandIndex: 10,
sendTabKeys: "keys",
},
encryptedSendTabKeys: "encrypted-keys",
},
getUserAccountData() {
return this.data;
},
updateUserAccountData(data) {
this.data = data;
},
};
const fxAccounts = {
async withCurrentAccountState(cb) {
await cb(accountState);
},
async getUserAccountData(data) {
return accountState.getUserAccountData(data);
},
telemetry: new TelemetryMock(),
};
const sendTab = new SendTab(commands, fxAccounts);
sendTab._encrypt = (bytes, device) => {
return bytes;
};
let generateEncryptedKeysCalled = false;
sendTab._generateAndPersistEncryptedSendTabKey = async () => {
generateEncryptedKeysCalled = true;
};
sendTab._fxai = fxAccounts;
const tab = { title: "tab title", url: "http://example.com" };
const to = [{ id: "devid", name: "The Device" }];
const reason = "push";
await sendTab.send(to, tab);
Assert.equal(commands._invokes.length, 1);
for (let { cmd, device, payload } of commands._invokes) {
Assert.equal(cmd, COMMAND_SENDTAB);
sendTab._fxai = fxAccounts;
try {
await sendTab.handle(device.id, payload, reason);
} catch {
// The `handle` function will throw an error
// since we are not mocking the `_decrypt`
// function. This is intentional, since
// we want to capture that `_decrypt` will
// not call `_generateEncryptedSendTabKeys` if
// it succeeds to retrieve the keys.
// Receiving a send tab is covered
// in the above test_sendtab_receive test.
}
}
Assert.ok(!generateEncryptedKeysCalled);
});