cdp: add test for setIgnoreCertificateErrors

This commit is contained in:
Pierre Tachoire
2025-10-21 14:08:26 +02:00
parent 6915738e02
commit 510c61cc20

View File

@@ -35,15 +35,34 @@ fn setIgnoreCertificateErrors(cmd: anytype) !void {
ignore: bool, ignore: bool,
})) orelse return error.InvalidParams; })) orelse return error.InvalidParams;
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
if (params.ignore) { if (params.ignore) {
try cmd.cdp.browser.http_client.disableTlsVerify(); try cmd.cdp.browser.http_client.disableTlsVerify();
} else { } else {
try cmd.cdp.browser.http_client.enableTlsVerify(); try cmd.cdp.browser.http_client.enableTlsVerify();
} }
return cmd.sendResult(.{ return cmd.sendResult(null, .{});
.browserContextId = bc.id, }
}, .{});
const testing = @import("../testing.zig");
test "cdp.Security: setIgnoreCertificateErrors" {
var ctx = testing.context();
defer ctx.deinit();
_ = try ctx.loadBrowserContext(.{ .id = "BID-9" });
try ctx.processMessage(.{
.id = 8,
.method = "Security.setIgnoreCertificateErrors",
.params = .{ .ignore = true },
});
try ctx.expectSentResult(null, .{ .id = 8 });
try ctx.processMessage(.{
.id = 9,
.method = "Security.setIgnoreCertificateErrors",
.params = .{ .ignore = false },
});
try ctx.expectSentResult(null, .{ .id = 9 });
} }