mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 15:55:36 +00:00
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:
parent
dd78e48f34
commit
13c9f8aeb9
@ -235,7 +235,8 @@ class RemoteSettingsClient extends EventEmitter {
|
||||
|
||||
if (verifySignature) {
|
||||
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 metadata = await kintoCollection.metadata();
|
||||
await this._validateCollectionSignature([],
|
||||
@ -325,10 +326,10 @@ class RemoteSettingsClient extends EventEmitter {
|
||||
if (this.verifySignature) {
|
||||
kintoCollection.hooks["incoming-changes"] = [async (payload, collection) => {
|
||||
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();
|
||||
// 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,
|
||||
timestamp,
|
||||
metadata,
|
||||
|
@ -20,6 +20,9 @@ let client;
|
||||
let clientWithDump;
|
||||
|
||||
async function clear_state() {
|
||||
client.verifySignature = false;
|
||||
clientWithDump.verifySignature = false;
|
||||
|
||||
// Clear local DB.
|
||||
const collection = await client.openCollection();
|
||||
await collection.clear();
|
||||
@ -45,11 +48,10 @@ function run_test() {
|
||||
Services.prefs.setCharPref("services.settings.server",
|
||||
`http://localhost:${server.identity.primaryPort}/v1`);
|
||||
|
||||
client = RemoteSettings("password-fields");
|
||||
client.verifySignature = false;
|
||||
Services.prefs.setCharPref("services.settings.loglevel", "debug");
|
||||
|
||||
client = RemoteSettings("password-fields");
|
||||
clientWithDump = RemoteSettings("language-dictionaries");
|
||||
clientWithDump.verifySignature = false;
|
||||
|
||||
server.registerPathHandler("/v1/", handleResponse);
|
||||
server.registerPathHandler("/v1/buckets/monitor/collections/changes/records", handleResponse);
|
||||
@ -65,6 +67,7 @@ function run_test() {
|
||||
server.stop(() => { });
|
||||
});
|
||||
}
|
||||
add_task(clear_state);
|
||||
|
||||
add_task(async function test_records_obtained_from_server_are_stored_in_db() {
|
||||
// Test an empty db populates
|
||||
@ -599,7 +602,7 @@ function getSampleResponse(req, port) {
|
||||
},
|
||||
"GET:/fake-x5u": {
|
||||
"sampleHeaders": [
|
||||
"Content-Type: /octet-stream",
|
||||
"Content-Type: application/octet-stream",
|
||||
],
|
||||
"status": { status: 200, statusText: "OK" },
|
||||
"responseBody": `-----BEGIN CERTIFICATE-----
|
||||
|
Loading…
Reference in New Issue
Block a user