/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
if (mozinfo.socketprocess_networking) {
Services.dns; // Needed to trigger socket process.
await TestUtils.waitForCondition(() => Services.io.socketProcessLaunched);
}
});
add_task(async function testHTTPSSVC() { // Initialize FOG before the DNS lookup so that server knobs (which enable // metrics disabled by default in non-Firefox builds) are applied before the // metric recording runs. if (!inChildProcess()) {
Services.fog.initializeFOG();
}
// use the h2 server as DOH provider
await setTRRURI("https://foo.example.com:" + h2Port + "/doh?httpssvc=1");
// The HTTPS RR was resolved over DoH/TRR, so https_rr_lookup_time should // have a sample under the "doh" key. if (!inChildProcess()) {
let doh = Glean.dns.httpsRrLookupTime.doh.testGetValue(); Assert.ok(doh, "https_rr_lookup_time(doh) was recorded");
}
});
add_task(async function test_aliasform() {
await setTRRURI(`https://foo.example.com:${trrServer.port()}/dns-query`);
await clearCache();
// Make sure that HTTPS AliasForm is only treated as a CNAME for HTTPS requests
await trrServer.registerDoHAnswers("test1.com", "A", {
answers: [
{
name: "test1.com",
ttl: 55,
type: "HTTPS",
flush: false,
data: {
priority: 0,
name: "something1.com",
values: [],
},
},
],
});
await trrServer.registerDoHAnswers("something1.com", "A", {
answers: [
{
name: "something1.com",
ttl: 55,
type: "A",
flush: false,
data: "1.2.3.4",
},
],
});
{
let { inStatus } = await new TRRDNSListener("test1.com", {
expectedSuccess: false,
}); Assert.ok(
!Components.isSuccessCode(inStatus),
`${inStatus} should be an error code`
);
}
({ inStatus } = await new TRRDNSListener("no-ip-host.com", {
expectedSuccess: false,
})); Assert.ok(
!Components.isSuccessCode(inStatus),
`${inStatus} should be an error code`
);
// Make sure these are the first requests Assert.equal(await trrServer.requestCount("loop.com", "HTTPS"), 0); Assert.equal(await trrServer.requestCount("loop2.com", "HTTPS"), 0);
({ inStatus } = await new TRRDNSListener("loop.com", {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
expectedSuccess: false,
})); Assert.ok(
!Components.isSuccessCode(inStatus),
`${inStatus} should be an error code`
); // Make sure the error was actually triggered by a loop. Assert.greater(await trrServer.requestCount("loop.com", "HTTPS"), 2); Assert.greater(await trrServer.requestCount("loop2.com", "HTTPS"), 2);
// Alias form for .
await trrServer.registerDoHAnswers("empty.com", "A", {
answers: [
{
name: "empty.com",
ttl: 55,
type: "HTTPS",
flush: false,
data: {
priority: 0,
name: "", // This is not allowed
values: [],
},
},
],
});
({ inStatus } = await new TRRDNSListener("empty.com", {
expectedSuccess: false,
})); Assert.ok(
!Components.isSuccessCode(inStatus),
`${inStatus} should be an error code`
);
let { inStatus: inStatus2 } = await new TRRDNSListener("multi.com", {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
expectedSuccess: false,
}); Assert.ok(
!Components.isSuccessCode(inStatus2),
`${inStatus2} should be an error code`
);
add_task(async function testNegativeResponse() {
await setTRRURI(`https://foo.example.com:${trrServer.port()}/dns-query`);
let { inStatus } = await new TRRDNSListener("negative_test.com", {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
expectedSuccess: false,
}); Assert.ok(
!Components.isSuccessCode(inStatus),
`${inStatus} should be an error code`
);
// Should still be failed because a negative response is from DNS cache.
({ inStatus } = await new TRRDNSListener("negative_test.com", {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
expectedSuccess: false,
})); Assert.ok(
!Components.isSuccessCode(inStatus),
`${inStatus} should be an error code`
);
await clearCache();
let inRecord;
({ inRecord, inStatus } = await new TRRDNSListener("negative_test.com", {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
})); Assert.ok(Components.isSuccessCode(inStatus), `${inStatus} should work`);
let answer = inRecord.QueryInterface(Ci.nsIDNSHTTPSSVCRecord).records; Assert.equal(answer[0].priority, 1); Assert.equal(answer[0].name, "negative_test.com");
});
add_task(async function testPortPrefixedName() { if (inChildProcess()) {
do_send_remote_message("set-port-prefixed-pref");
await do_await_remote_message("set-port-prefixed-pref-done");
} else {
Services.prefs.setBoolPref( "network.dns.port_prefixed_qname_https_rr", true
);
}
let { inRecord } = await new TRRDNSListener(host, {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
});
let notused = {};
let answer = inRecord
.QueryInterface(Ci.nsIDNSHTTPSSVCRecord)
.GetAllRecordsWithEchConfig(false, false, "", notused, notused);
Assert.equal(answer.length, expected.length); for (let i = 0; i < answer.length; i++) { Assert.equal(answer[i].priority, expected[i].priority); Assert.equal(answer[i].name, expected[i].name); if (expected[i].selectedAlpn !== null) { Assert.equal(answer[i].selectedAlpn, expected[i].selectedAlpn);
}
}
}
add_task(async function testFlattenRecordsWithECH() { // Test when host name and targetName are the same.
await doTestFlattenRecordsWithECH( "test.target.com", "test.target.com",
["h3"],
[
{ priority: 1, name: "test.target.com", selectedAlpn: "h3" },
{ priority: 1, name: "test.target.com", selectedAlpn: "" },
]
);
await doTestFlattenRecordsWithECH( "test.target.com", ".",
["h3"],
[
{ priority: 1, name: "test.target.com", selectedAlpn: "h3" },
{ priority: 1, name: "test.target.com", selectedAlpn: "" },
]
);
// Test when host name and targetName are not the same. // We add
await doTestFlattenRecordsWithECH( "test.target.com", "test.target_1.com",
["h3"],
[
{ priority: 1, name: "test.target_1.com", selectedAlpn: "h3" },
{ priority: 1, name: "test.target_1.com", selectedAlpn: "" },
]
);
let { inRecord } = await new TRRDNSListener(host, {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
});
let notused = {};
let answer = inRecord
.QueryInterface(Ci.nsIDNSHTTPSSVCRecord)
.GetAllRecords(false, false, "", notused, notused);
Assert.equal(answer.length, expected.length); for (let i = 0; i < answer.length; i++) { Assert.equal(answer[i].priority, expected[i].priority); Assert.equal(answer[i].name, expected[i].name); if (expected[i].selectedAlpn !== null) { Assert.equal(answer[i].selectedAlpn, expected[i].selectedAlpn);
}
}
}
add_task(async function testFlattenRecordsWithoutECH() { // Test when host name and targetName are the same.
await doTestFlattenRecordsWithoutECH( "test.target_noech.com", "test.target_noech.com",
["h3"],
[{ priority: 1, name: "test.target_noech.com", selectedAlpn: "h3" }]
);
await doTestFlattenRecordsWithoutECH( "test.target_noech.com", ".",
["h3"],
[{ priority: 1, name: "test.target_noech.com", selectedAlpn: "h3" }]
);
// Test when host name and targetName are not the same.
await doTestFlattenRecordsWithoutECH( "test.target_noech.com", "test.target_noech_1.com",
["h3"],
[
{ priority: 1, name: "test.target_noech_1.com", selectedAlpn: "h3" },
{ priority: 1, name: "test.target_noech_1.com", selectedAlpn: "" },
]
);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.