2022-01-24 04:39:28 -05:00
|
|
|
import { assert } from "./test_util.ts";
|
|
|
|
|
|
|
|
Deno.test(
|
2022-09-28 08:46:50 -04:00
|
|
|
{
|
|
|
|
name: "Deno.networkInterfaces",
|
|
|
|
permissions: { sys: ["networkInterfaces"] },
|
|
|
|
},
|
2022-01-24 04:39:28 -05:00
|
|
|
() => {
|
|
|
|
const networkInterfaces = Deno.networkInterfaces();
|
|
|
|
assert(Array.isArray(networkInterfaces));
|
|
|
|
assert(networkInterfaces.length > 0);
|
|
|
|
for (
|
|
|
|
const { name, family, address, netmask, scopeid, cidr, mac }
|
|
|
|
of networkInterfaces
|
|
|
|
) {
|
|
|
|
assert(typeof name === "string");
|
|
|
|
assert(family === "IPv4" || family === "IPv6");
|
|
|
|
assert(typeof address === "string");
|
|
|
|
assert(typeof netmask === "string");
|
|
|
|
assert(
|
|
|
|
(family === "IPv6" && typeof scopeid === "number") ||
|
|
|
|
(family === "IPv4" && scopeid === null),
|
|
|
|
);
|
|
|
|
assert(typeof cidr === "string");
|
|
|
|
assert(typeof mac === "string");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|