/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
add_task(async function testHTTPSSVC() { // use the h2 server as DOH provider if (!inChildProcess()) {
Services.prefs.setCharPref( "network.trr.uri", "https://foo.example.com:" + h2Port + "/httpssvc"
);
}
// 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() {
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`
);
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);
}
}
await trrServer.stop();
}
add_task(
{ skip_if: () => inChildProcess() },
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);
}
}
await trrServer.stop();
}
add_task(
{ skip_if: () => inChildProcess() },
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.