test(voice-call): cover cloudflare twilio signatures · openclaw/openclaw@250acdd
steipete
·
2026-04-25
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -618,6 +618,37 @@ describe("verifyTwilioWebhook", () => {
|
618 | 618 | expect(result.verificationUrl).toBe(webhookUrl); |
619 | 619 | }); |
620 | 620 | |
| 621 | +it("verifies Twilio signatures for Cloudflare Tunnel publicUrl requests", () => { |
| 622 | +const authToken = "test-auth-token"; |
| 623 | +const postBody = "CallSid=CA123&CallStatus=ringing&Direction=inbound&From=%2B15550000000"; |
| 624 | +const webhookUrl = "https://oc1.example.com/voice/webhook"; |
| 625 | +const signature = twilioSignature({ authToken, url: webhookUrl, postBody }); |
| 626 | + |
| 627 | +const result = verifyTwilioWebhook( |
| 628 | +{ |
| 629 | +headers: { |
| 630 | +host: "localhost:8765", |
| 631 | +"cf-connecting-ip": "203.0.113.42", |
| 632 | +"x-forwarded-proto": "https", |
| 633 | +"x-twilio-signature": signature, |
| 634 | +}, |
| 635 | +rawBody: postBody, |
| 636 | +url: "http://localhost:8765/voice/webhook", |
| 637 | +method: "POST", |
| 638 | +remoteAddress: "127.0.0.1", |
| 639 | +}, |
| 640 | +authToken, |
| 641 | +{ |
| 642 | +publicUrl: webhookUrl, |
| 643 | +allowedHosts: ["oc1.example.com"], |
| 644 | +trustForwardingHeaders: true, |
| 645 | +}, |
| 646 | +); |
| 647 | + |
| 648 | +expect(result.ok).toBe(true); |
| 649 | +expect(result.verificationUrl).toBe(webhookUrl); |
| 650 | +}); |
| 651 | + |
621 | 652 | it("rejects X-Forwarded-Host not in allowedHosts whitelist", () => { |
622 | 653 | const authToken = "test-auth-token"; |
623 | 654 | const postBody = "CallSid=CS123&CallStatus=completed&From=%2B15550000000"; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。