mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Deflake node-tls-connect test
This commit is contained in:
@@ -167,6 +167,23 @@ it("should have peer certificate", async () => {
|
||||
});
|
||||
|
||||
it("getCipher, getProtocol, getEphemeralKeyInfo, getSharedSigalgs, getSession, exportKeyingMaterial and isSessionReused should work", async () => {
|
||||
const allowedCipherObjects = [
|
||||
{
|
||||
name: "TLS_AES_128_GCM_SHA256",
|
||||
standardName: "TLS_AES_128_GCM_SHA256",
|
||||
version: "TLSv1/SSLv3",
|
||||
},
|
||||
{
|
||||
name: "TLS_AES_256_GCM_SHA384",
|
||||
standardName: "TLS_AES_256_GCM_SHA384",
|
||||
version: "TLSv1/SSLv3",
|
||||
},
|
||||
{
|
||||
name: "TLS_CHACHA20_POLY1305_SHA256",
|
||||
standardName: "TLS_CHACHA20_POLY1305_SHA256",
|
||||
version: "TLSv1/SSLv3",
|
||||
},
|
||||
];
|
||||
const socket = (await new Promise((resolve, reject) => {
|
||||
connect({
|
||||
ALPNProtocols: ["http/1.1"],
|
||||
@@ -181,11 +198,18 @@ it("getCipher, getProtocol, getEphemeralKeyInfo, getSharedSigalgs, getSession, e
|
||||
})) as TLSSocket;
|
||||
|
||||
try {
|
||||
expect(socket.getCipher()).toMatchObject({
|
||||
name: "TLS_AES_128_GCM_SHA256",
|
||||
standardName: "TLS_AES_128_GCM_SHA256",
|
||||
version: "TLSv1/SSLv3",
|
||||
});
|
||||
const cipher = socket.getCipher();
|
||||
let hadMatch = false;
|
||||
for (const allowedCipher of allowedCipherObjects) {
|
||||
if (cipher.name === allowedCipher.name) {
|
||||
expect(cipher).toMatchObject(allowedCipher);
|
||||
hadMatch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hadMatch) {
|
||||
throw new Error(`Unexpected cipher ${cipher.name}`);
|
||||
}
|
||||
expect(socket.getProtocol()).toBe("TLSv1.3");
|
||||
expect(typeof socket.getEphemeralKeyInfo()).toBe("object");
|
||||
expect(socket.getSharedSigalgs()).toBeInstanceOf(Array);
|
||||
|
||||
Reference in New Issue
Block a user