Files
bun.sh/test/js/node/tls/node-tls-internals.test.ts
dave caruso d712254128 internal: remove secret hidden internals and introduce new way to call native code from js (#8166)
* oooooh magic

* stuff

* run format

* ok

* yippee

* run the formatter back

* finish things up

* fix webkit

* more

* [autofix.ci] apply automated fixes

* fix compile

* fix compilation on windows, it seems to not work though :(

* update

* a

* v

* ok

* [autofix.ci] apply automated fixes

* OOPS

* bump bun to reduce ci bugs

* a

* js2native is done!

* improve array binding

* rebase

* some final stuff

* wasi fixes

* os

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-29 21:47:11 -07:00

38 lines
1.5 KiB
TypeScript

import { createTest } from "node-harness";
import { TLSBinding } from "bun:internal-for-testing";
const { describe, expect } = createTest(import.meta.path);
const { canonicalizeIP, rootCertificates } = TLSBinding;
describe("NodeTLS.cpp", () => {
test("canonicalizeIP", () => {
expect(canonicalizeIP("127.0.0.1")).toBe("127.0.0.1");
expect(canonicalizeIP("10.1.0.1")).toBe("10.1.0.1");
expect(canonicalizeIP("::1")).toBe("::1");
expect(canonicalizeIP("fe80:0:0:0:0:0:0:1")).toBe("fe80::1");
expect(canonicalizeIP("fe80:0:0:0:0:0:0:0")).toBe("fe80::");
expect(canonicalizeIP("fe80::0000:0010:0001")).toBe("fe80::10:1");
expect(canonicalizeIP("0001:2222:3333:4444:5555:6666:7777:0088")).toBe("1:2222:3333:4444:5555:6666:7777:88");
expect(canonicalizeIP("0001:2222:3333:4444:5555:6666::")).toBe("1:2222:3333:4444:5555:6666::");
expect(canonicalizeIP("a002:B12:00Ba:4444:5555:6666:0:0")).toBe("a002:b12:ba:4444:5555:6666::");
// IPv4 address represented in IPv6
expect(canonicalizeIP("0:0:0:0:0:ffff:c0a8:101")).toBe("::ffff:192.168.1.1");
expect(canonicalizeIP("::ffff:192.168.1.1")).toBe("::ffff:192.168.1.1");
});
test("rootCertificates", () => {
expect(rootCertificates).toBeInstanceOf(Array);
expect(rootCertificates.length).toBeGreaterThan(0);
expect(typeof rootCertificates[0]).toBe("string");
for (const cert of rootCertificates) {
expect(cert).toStartWith("-----BEGIN CERTIFICATE-----");
expect(cert).toEndWith("-----END CERTIFICATE-----");
}
});
});