|
1 | 1 | import * as providerAuth from "openclaw/plugin-sdk/provider-auth-runtime"; |
| 2 | +import * as providerHttp from "openclaw/plugin-sdk/provider-http"; |
2 | 3 | import { installPinnedHostnameTestHooks } from "openclaw/plugin-sdk/test-env"; |
3 | 4 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
4 | 5 | import { |
@@ -93,6 +94,36 @@ describe("minimax image-generation provider", () => { |
93 | 94 | }); |
94 | 95 | }); |
95 | 96 |
|
| 97 | + it("passes request SSRF policy to the provider HTTP helper", async () => { |
| 98 | + mockMinimaxApiKey(); |
| 99 | + const postJsonRequest = vi.spyOn(providerHttp, "postJsonRequest").mockResolvedValue({ |
| 100 | + response: new Response( |
| 101 | + JSON.stringify({ |
| 102 | + data: { image_base64: [Buffer.from("png-data").toString("base64")] }, |
| 103 | + base_resp: { status_code: 0 }, |
| 104 | + }), |
| 105 | + { status: 200, headers: { "Content-Type": "application/json" } }, |
| 106 | + ), |
| 107 | + finalUrl: "https://api.minimax.io/v1/image_generation", |
| 108 | + release: async () => {}, |
| 109 | + }); |
| 110 | + |
| 111 | + const provider = buildMinimaxImageGenerationProvider(); |
| 112 | + await provider.generateImage({ |
| 113 | + provider: "minimax", |
| 114 | + model: "image-01", |
| 115 | + prompt: "draw a cat", |
| 116 | + cfg: {}, |
| 117 | + ssrfPolicy: { allowRfc2544BenchmarkRange: true }, |
| 118 | + }); |
| 119 | + |
| 120 | + expect(postJsonRequest).toHaveBeenCalledWith( |
| 121 | + expect.objectContaining({ |
| 122 | + ssrfPolicy: { allowRfc2544BenchmarkRange: true }, |
| 123 | + }), |
| 124 | + ); |
| 125 | + }); |
| 126 | + |
96 | 127 | it("keeps the dedicated global image endpoint when text config uses the global API host", async () => { |
97 | 128 | mockMinimaxApiKey(); |
98 | 129 | const fetchMock = mockSuccessfulMinimaxImageResponse(); |
|
0 commit comments