forked from mtusi2026/mtusi2026lab7
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { test, expect } from "bun:test";
|
|
import { expectDenied } from "./transport";
|
|
test("native explicit revoked-certificate alert is client denial, while an application success is not", async () => {
|
|
expect(
|
|
await expectDenied(
|
|
() =>
|
|
Promise.reject(
|
|
Object.assign(new Error("synthetic revoked certificate"), {
|
|
code: "ERR_SSL_SSLV3_ALERT_CERTIFICATE_REVOKED",
|
|
}),
|
|
),
|
|
"client",
|
|
),
|
|
).toBe("ERR_SSL_SSLV3_ALERT_CERTIFICATE_REVOKED");
|
|
await expect(
|
|
expectDenied(
|
|
async () => ({
|
|
data: "HTTP/1.1 200 OK",
|
|
authorized: true,
|
|
protocol: "TLSv1.3",
|
|
}),
|
|
"client",
|
|
),
|
|
).rejects.toThrow("NEGATIVE_FAILED_FOR_UNEXPECTED_REASON");
|
|
});
|
|
test("Bun native certificate-required alert counts as client denial while timeout never does", async () => {
|
|
const certificate = () =>
|
|
Promise.reject(
|
|
Object.assign(new Error("synthetic native certificate alert"), {
|
|
code: "ERR_SSL_TLSV1_ALERT_CERTIFICATE_REQUIRED",
|
|
}),
|
|
);
|
|
expect(await expectDenied(certificate, "client")).toBe(
|
|
"ERR_SSL_TLSV1_ALERT_CERTIFICATE_REQUIRED",
|
|
);
|
|
await expect(
|
|
expectDenied(
|
|
() =>
|
|
Promise.reject(
|
|
Object.assign(new Error("synthetic timeout"), { code: "ETIMEDOUT" }),
|
|
),
|
|
"client",
|
|
),
|
|
).rejects.toThrow("NEGATIVE_FAILED_FOR_UNEXPECTED_REASON");
|
|
});
|