2024-03-25 11:22:01 -04:00
|
|
|
console.log("window is", globalThis.window);
|
2024-03-26 11:56:52 -04:00
|
|
|
console.log("Deno.Buffer is", Deno.Buffer);
|
2024-03-27 08:45:19 -04:00
|
|
|
console.log(
|
|
|
|
"Deno.FsFile.prototype.rid is",
|
|
|
|
Deno.openSync(import.meta.filename).rid,
|
|
|
|
);
|
2024-04-04 12:27:18 -04:00
|
|
|
|
2024-04-07 18:59:37 -04:00
|
|
|
// TCP
|
|
|
|
// Since these tests may run in parallel, ensure this port is unique to this file
|
|
|
|
const tcpPort = 4509;
|
|
|
|
const tcpListener = Deno.listen({ port: tcpPort });
|
|
|
|
console.log("Deno.Listener.prototype.rid is", tcpListener.rid);
|
|
|
|
|
|
|
|
const tcpConn = await Deno.connect({ port: tcpPort });
|
|
|
|
console.log("Deno.Conn.prototype.rid is", tcpConn.rid);
|
|
|
|
|
|
|
|
tcpConn.close();
|
|
|
|
tcpListener.close();
|
|
|
|
|
|
|
|
// Unix
|
|
|
|
if (Deno.build.os === "windows") {
|
|
|
|
console.log("Deno.UnixConn.prototype.rid is undefined");
|
|
|
|
} else {
|
|
|
|
const socketPath = "./test.sock";
|
|
|
|
const unixListener = Deno.listen({ transport: "unix", path: socketPath });
|
|
|
|
|
|
|
|
const unixConn = await Deno.connect({ transport: "unix", path: socketPath });
|
|
|
|
console.log("Deno.UnixConn.prototype.rid is", unixConn.rid);
|
|
|
|
|
|
|
|
unixConn.close();
|
|
|
|
unixListener.close();
|
|
|
|
Deno.removeSync(socketPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TLS
|
|
|
|
// Since these tests may run in parallel, ensure this port is unique to this file
|
|
|
|
const tlsPort = 4510;
|
2024-04-19 06:50:18 -04:00
|
|
|
const cert = Deno.readTextFileSync(
|
|
|
|
new URL("../../../testdata/tls/localhost.crt", import.meta.url),
|
|
|
|
);
|
|
|
|
const key = Deno.readTextFileSync(
|
|
|
|
new URL("../../../testdata/tls/localhost.key", import.meta.url),
|
|
|
|
);
|
2024-04-07 18:59:37 -04:00
|
|
|
const tlsListener = Deno.listenTls({ port: tlsPort, cert, key });
|
|
|
|
console.log("Deno.TlsListener.prototype.rid is", tlsListener.rid);
|
|
|
|
|
|
|
|
const tlsConn = await Deno.connectTls({ port: tlsPort });
|
|
|
|
console.log("Deno.TlsConn.prototype.rid is", tlsConn.rid);
|
|
|
|
|
|
|
|
tlsConn.close();
|
|
|
|
|
2024-04-07 01:42:53 -04:00
|
|
|
try {
|
|
|
|
new Deno.FsFile(0);
|
|
|
|
} catch (error) {
|
|
|
|
if (
|
|
|
|
error instanceof TypeError &&
|
|
|
|
error.message ===
|
|
|
|
"`Deno.FsFile` cannot be constructed, use `Deno.open()` or `Deno.openSync()` instead."
|
|
|
|
) {
|
|
|
|
console.log("Deno.FsFile constructor is illegal");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-20 23:03:44 -04:00
|
|
|
// Note: this could throw with a `Deno.errors.NotFound` error if `keyFile` and
|
|
|
|
// `certFile` were used.
|
|
|
|
const conn1 = await Deno.connectTls({
|
|
|
|
port: tlsPort,
|
|
|
|
certFile: "foo",
|
|
|
|
keyFile: "foo",
|
|
|
|
});
|
|
|
|
conn1.close();
|
|
|
|
console.log("Deno.ConnectTlsOptions.(certFile|keyFile) do nothing");
|
|
|
|
|
|
|
|
// Note: this could throw with a `Deno.errors.InvalidData` error if `certChain`
|
|
|
|
// and `privateKey` were used.
|
|
|
|
const conn2 = await Deno.connectTls({
|
|
|
|
port: tlsPort,
|
|
|
|
certChain: "foo",
|
|
|
|
privateKey: "foo",
|
|
|
|
});
|
|
|
|
conn2.close();
|
|
|
|
console.log("Deno.ConnectTlsOptions.(certChain|privateKey) do nothing");
|
|
|
|
|
|
|
|
tlsListener.close();
|
|
|
|
|
2024-04-20 21:58:59 -04:00
|
|
|
// Note: this could throw with a `Deno.errors.NotFound` error if `keyFile` and
|
|
|
|
// `certFile` were used.
|
|
|
|
try {
|
|
|
|
Deno.listenTls({ port: tlsPort, keyFile: "foo", certFile: "foo" });
|
|
|
|
} catch (error) {
|
|
|
|
if (
|
|
|
|
error instanceof Deno.errors.InvalidData &&
|
|
|
|
error.message ===
|
|
|
|
"Deno.listenTls requires a key: Error creating TLS certificate"
|
|
|
|
) {
|
|
|
|
console.log("Deno.ListenTlsOptions.(keyFile|certFile) do nothing");
|
|
|
|
}
|
|
|
|
}
|
2024-04-19 06:50:18 -04:00
|
|
|
|
2024-04-04 12:27:18 -04:00
|
|
|
self.close();
|