forked from mirrors/gecko-dev
Bug 1864934 - Rename OHTTPConfigManager to HPKEConfigManager. r=Gijs,necko-reviewers
This simple cache is generally applicable to protocols that need to fetch an HPKE key over TLS that doesn't change and would benefit from caching. Subsequent patches will use this for the DAPTelemetrySender. Differential Revision: https://phabricator.services.mozilla.com/D193696
This commit is contained in:
parent
c6a97aae49
commit
dcccd900a3
5 changed files with 17 additions and 17 deletions
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
let knownConfigs = new Map();
|
||||
|
||||
export class OHTTPConfigManager {
|
||||
export class HPKEConfigManager {
|
||||
static async get(aURL, aOptions = {}) {
|
||||
try {
|
||||
let config = await this.#getInternal(aURL, aOptions);
|
||||
|
|
@ -32,7 +32,7 @@ export class OHTTPConfigManager {
|
|||
let resp = await fetch(aURL);
|
||||
if (!resp?.ok) {
|
||||
throw new Error(
|
||||
`Fetching OHTTP config from ${aURL} failed with error ${resp.status}`
|
||||
`Fetching HPKE config from ${aURL} failed with error ${resp.status}`
|
||||
);
|
||||
}
|
||||
let config = await resp.blob().then(b => b.arrayBuffer());
|
||||
|
|
@ -208,7 +208,7 @@ if CONFIG["MOZ_AUTH_EXTENSION"]:
|
|||
]
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
"OHTTPConfigManager.sys.mjs",
|
||||
"HPKEConfigManager.sys.mjs",
|
||||
"WellKnownOpportunisticUtils.sys.mjs",
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ http://creativecommons.org/publicdomain/zero/1.0/ */
|
|||
|
||||
"use strict";
|
||||
|
||||
let { OHTTPConfigManager } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/OHTTPConfigManager.sys.mjs"
|
||||
let { HPKEConfigManager } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/HPKEConfigManager.sys.mjs"
|
||||
);
|
||||
|
||||
const { HttpServer } = ChromeUtils.importESModule(
|
||||
|
|
@ -45,25 +45,25 @@ function getLocalURL(path) {
|
|||
}
|
||||
|
||||
add_task(async function test_broken_url_returns_null() {
|
||||
Assert.equal(await OHTTPConfigManager.get(getLocalURL("invalid")), null);
|
||||
Assert.equal(await HPKEConfigManager.get(getLocalURL("invalid")), null);
|
||||
});
|
||||
|
||||
add_task(async function test_working_url_returns_data() {
|
||||
Assert.deepEqual(
|
||||
await OHTTPConfigManager.get(getLocalURL("valid")),
|
||||
await HPKEConfigManager.get(getLocalURL("valid")),
|
||||
new TextEncoder().encode("1234")
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function test_we_only_request_once() {
|
||||
Assert.deepEqual(
|
||||
await OHTTPConfigManager.get(getLocalURL("valid")),
|
||||
await HPKEConfigManager.get(getLocalURL("valid")),
|
||||
new TextEncoder().encode("1234")
|
||||
);
|
||||
let oldRequestCount = gValidRequestCount;
|
||||
|
||||
Assert.deepEqual(
|
||||
await OHTTPConfigManager.get(getLocalURL("valid")),
|
||||
await HPKEConfigManager.get(getLocalURL("valid")),
|
||||
new TextEncoder().encode("1234")
|
||||
);
|
||||
Assert.equal(
|
||||
|
|
@ -75,13 +75,13 @@ add_task(async function test_we_only_request_once() {
|
|||
|
||||
add_task(async function test_maxAge_forces_refresh() {
|
||||
Assert.deepEqual(
|
||||
await OHTTPConfigManager.get(getLocalURL("valid")),
|
||||
await HPKEConfigManager.get(getLocalURL("valid")),
|
||||
new TextEncoder().encode("1234")
|
||||
);
|
||||
let oldRequestCount = gValidRequestCount;
|
||||
|
||||
Assert.deepEqual(
|
||||
await OHTTPConfigManager.get(getLocalURL("valid"), { maxAge: 0 }),
|
||||
await HPKEConfigManager.get(getLocalURL("valid"), { maxAge: 0 }),
|
||||
new TextEncoder().encode("1234")
|
||||
);
|
||||
Assert.equal(
|
||||
|
|
@ -93,19 +93,19 @@ add_task(async function test_maxAge_forces_refresh() {
|
|||
|
||||
add_task(async function test_maxAge_handling_of_invalid_requests() {
|
||||
Assert.deepEqual(
|
||||
await OHTTPConfigManager.get(getLocalURL("fickle")),
|
||||
await HPKEConfigManager.get(getLocalURL("fickle")),
|
||||
new TextEncoder().encode("1234")
|
||||
);
|
||||
|
||||
gFickleIsWorking = false;
|
||||
|
||||
Assert.deepEqual(
|
||||
await OHTTPConfigManager.get(getLocalURL("fickle"), { maxAge: 0 }),
|
||||
await HPKEConfigManager.get(getLocalURL("fickle"), { maxAge: 0 }),
|
||||
null
|
||||
);
|
||||
|
||||
Assert.deepEqual(
|
||||
await OHTTPConfigManager.get(getLocalURL("fickle")),
|
||||
await HPKEConfigManager.get(getLocalURL("fickle")),
|
||||
new TextEncoder().encode("1234"),
|
||||
"Should still have the cached config if no max age is passed."
|
||||
);
|
||||
|
|
@ -750,7 +750,7 @@ run-sequentially = http3server
|
|||
[test_bhttp.js]
|
||||
[test_oblivious_http.js]
|
||||
[test_ohttp.js]
|
||||
[test_ohttp_config_manager.js]
|
||||
[test_hpke_config_manager.js]
|
||||
skip-if = !nightly_build # OHTTP Config manager not currently shipped to release.
|
||||
[test_websocket_500k.js]
|
||||
skip-if = verify
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ let { XPCOMUtils } = ChromeUtils.importESModule(
|
|||
|
||||
const lazy = {};
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
OHTTPConfigManager: "resource://gre/modules/OHTTPConfigManager.sys.mjs",
|
||||
HPKEConfigManager: "resource://gre/modules/HPKEConfigManager.sys.mjs",
|
||||
ProductValidator: "chrome://global/content/shopping/ProductValidator.sys.mjs",
|
||||
setTimeout: "resource://gre/modules/Timer.sys.mjs",
|
||||
});
|
||||
|
|
@ -455,7 +455,7 @@ export class ShoppingProduct {
|
|||
* The config bytes.
|
||||
*/
|
||||
static async getOHTTPConfig(gatewayConfigURL) {
|
||||
return lazy.OHTTPConfigManager.get(gatewayConfigURL);
|
||||
return lazy.HPKEConfigManager.get(gatewayConfigURL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue