зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1553831 - Minor cleanups in Remote Settings client r=glasserc
Differential Revision: https://phabricator.services.mozilla.com/D32768 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
df4dbd4b02
Коммит
921d7af3d5
|
@ -235,7 +235,8 @@ class RemoteSettingsClient extends EventEmitter {
|
||||||
|
|
||||||
if (verifySignature) {
|
if (verifySignature) {
|
||||||
console.debug("Verify signature of local data");
|
console.debug("Verify signature of local data");
|
||||||
const localRecords = data.map(r => kintoCollection.cleanLocalFields(r));
|
const { data: allData } = await kintoCollection.list({ order: "" });
|
||||||
|
const localRecords = allData.map(r => kintoCollection.cleanLocalFields(r));
|
||||||
const timestamp = await kintoCollection.db.getLastModified();
|
const timestamp = await kintoCollection.db.getLastModified();
|
||||||
const metadata = await kintoCollection.metadata();
|
const metadata = await kintoCollection.metadata();
|
||||||
await this._validateCollectionSignature([],
|
await this._validateCollectionSignature([],
|
||||||
|
@ -325,10 +326,10 @@ class RemoteSettingsClient extends EventEmitter {
|
||||||
if (this.verifySignature) {
|
if (this.verifySignature) {
|
||||||
kintoCollection.hooks["incoming-changes"] = [async (payload, collection) => {
|
kintoCollection.hooks["incoming-changes"] = [async (payload, collection) => {
|
||||||
const { changes: remoteRecords, lastModified: timestamp } = payload;
|
const { changes: remoteRecords, lastModified: timestamp } = payload;
|
||||||
const { data } = await kintoCollection.list({ order: "" }); // no need to sort.
|
const { data } = await collection.list({ order: "" }); // no need to sort.
|
||||||
const metadata = await collection.metadata();
|
const metadata = await collection.metadata();
|
||||||
// Local fields are stripped to compute the collection signature (server does not have them).
|
// Local fields are stripped to compute the collection signature (server does not have them).
|
||||||
const localRecords = data.map(r => kintoCollection.cleanLocalFields(r));
|
const localRecords = data.map(r => collection.cleanLocalFields(r));
|
||||||
await this._validateCollectionSignature(remoteRecords,
|
await this._validateCollectionSignature(remoteRecords,
|
||||||
timestamp,
|
timestamp,
|
||||||
metadata,
|
metadata,
|
||||||
|
|
|
@ -20,6 +20,9 @@ let client;
|
||||||
let clientWithDump;
|
let clientWithDump;
|
||||||
|
|
||||||
async function clear_state() {
|
async function clear_state() {
|
||||||
|
client.verifySignature = false;
|
||||||
|
clientWithDump.verifySignature = false;
|
||||||
|
|
||||||
// Clear local DB.
|
// Clear local DB.
|
||||||
const collection = await client.openCollection();
|
const collection = await client.openCollection();
|
||||||
await collection.clear();
|
await collection.clear();
|
||||||
|
@ -45,11 +48,10 @@ function run_test() {
|
||||||
Services.prefs.setCharPref("services.settings.server",
|
Services.prefs.setCharPref("services.settings.server",
|
||||||
`http://localhost:${server.identity.primaryPort}/v1`);
|
`http://localhost:${server.identity.primaryPort}/v1`);
|
||||||
|
|
||||||
client = RemoteSettings("password-fields");
|
Services.prefs.setCharPref("services.settings.loglevel", "debug");
|
||||||
client.verifySignature = false;
|
|
||||||
|
|
||||||
|
client = RemoteSettings("password-fields");
|
||||||
clientWithDump = RemoteSettings("language-dictionaries");
|
clientWithDump = RemoteSettings("language-dictionaries");
|
||||||
clientWithDump.verifySignature = false;
|
|
||||||
|
|
||||||
server.registerPathHandler("/v1/", handleResponse);
|
server.registerPathHandler("/v1/", handleResponse);
|
||||||
server.registerPathHandler("/v1/buckets/monitor/collections/changes/records", handleResponse);
|
server.registerPathHandler("/v1/buckets/monitor/collections/changes/records", handleResponse);
|
||||||
|
@ -65,6 +67,7 @@ function run_test() {
|
||||||
server.stop(() => { });
|
server.stop(() => { });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
add_task(clear_state);
|
||||||
|
|
||||||
add_task(async function test_records_obtained_from_server_are_stored_in_db() {
|
add_task(async function test_records_obtained_from_server_are_stored_in_db() {
|
||||||
// Test an empty db populates
|
// Test an empty db populates
|
||||||
|
@ -599,7 +602,7 @@ function getSampleResponse(req, port) {
|
||||||
},
|
},
|
||||||
"GET:/fake-x5u": {
|
"GET:/fake-x5u": {
|
||||||
"sampleHeaders": [
|
"sampleHeaders": [
|
||||||
"Content-Type: /octet-stream",
|
"Content-Type: application/octet-stream",
|
||||||
],
|
],
|
||||||
"status": { status: 200, statusText: "OK" },
|
"status": { status: 200, statusText: "OK" },
|
||||||
"responseBody": `-----BEGIN CERTIFICATE-----
|
"responseBody": `-----BEGIN CERTIFICATE-----
|
||||||
|
|
Загрузка…
Ссылка в новой задаче