Add websocket contract guards for empty requests and hello version
Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
1 parent
2af6a90fab
commit
22c644927f
1 file changed
+30
@@ -19,6 +19,26 @@ describe("wsClientMessageSchema", () => {
|
||||
|
||||
expect(parsed.method).toBe("providers.startSession");
|
||||
});
|
||||
|
||||
it("rejects empty request ids", () => {
|
||||
expect(() =>
|
||||
wsClientMessageSchema.parse({
|
||||
type: "request",
|
||||
id: "",
|
||||
method: "providers.startSession",
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects empty request methods", () => {
|
||||
expect(() =>
|
||||
wsClientMessageSchema.parse({
|
||||
type: "request",
|
||||
id: "req-1",
|
||||
method: "",
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("wsServerMessageSchema", () => {
|
||||
@@ -87,6 +107,16 @@ describe("wsServerMessageSchema", () => {
|
||||
|
||||
expect(parsed.type).toBe("hello");
|
||||
});
|
||||
|
||||
it("rejects hello messages with unsupported versions", () => {
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "hello",
|
||||
version: 2,
|
||||
launchCwd: "/workspace",
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("ws close metadata", () => {
|
||||
|
||||
Reference in new issue
Block a user