1 /* Any copyright is dedicated to the Public Domain.
2 * https://creativecommons.org/publicdomain/zero/1.0/ */
6 function test_known_config() {
7 let ohttp
= Cc
["@mozilla.org/network/oblivious-http;1"].getService(
10 let encodedConfig
= hexStringToBytes(
11 "0100209403aafe76dfd4568481e04e44b42d744287eae4070b50e48baa7a91a4e80d5600080001000100010003"
13 let request
= hexStringToBytes(
14 "00034745540568747470730b6578616d706c652e636f6d012f"
16 let ohttpRequest
= ohttp
.encapsulateRequest(encodedConfig
, request
);
20 function test_with_server() {
21 let ohttp
= Cc
["@mozilla.org/network/oblivious-http;1"].getService(
24 let server
= ohttp
.server();
25 ok(server
.encodedConfig
);
26 let request
= hexStringToBytes(
27 "00034745540568747470730b6578616d706c652e636f6d012f"
29 let ohttpRequest
= ohttp
.encapsulateRequest(server
.encodedConfig
, request
);
30 let ohttpResponse
= server
.decapsulate(ohttpRequest
.encRequest
);
32 deepEqual(ohttpResponse
.request
, request
);
33 let response
= hexStringToBytes("0140c8");
34 let encResponse
= ohttpResponse
.encapsulate(response
);
35 deepEqual(ohttpRequest
.response
.decapsulate(encResponse
), response
);