

























@@ -57,6 +57,17 @@ async function expectFirstModelId(): Promise<string> {
5757return firstId;
5858}
595960+async function expectMissingReadScope(res: Response) {
61+expect(res.status).toBe(403);
62+await expect(res.json()).resolves.toEqual({
63+ok: false,
64+error: {
65+type: "forbidden",
66+message: "missing scope: operator.read",
67+},
68+});
69+}
70+6071describe("OpenAI-compatible models HTTP API (e2e)", () => {
6172it("serves /v1/models when compatibility endpoints are enabled", async () => {
6273const res = await getModels("/v1/models");
@@ -83,41 +94,20 @@ describe("OpenAI-compatible models HTTP API (e2e)", () => {
83948495it("rejects operator scopes that lack read access", async () => {
8596const res = await getModels("/v1/models", { "x-openclaw-scopes": "operator.approvals" });
86-expect(res.status).toBe(403);
87-await expect(res.json()).resolves.toMatchObject({
88-ok: false,
89-error: {
90-type: "forbidden",
91-message: "missing scope: operator.read",
92-},
93-});
97+await expectMissingReadScope(res);
9498});
959996100it("rejects requests with no declared operator scopes", async () => {
97101const res = await getModels("/v1/models", { "x-openclaw-scopes": "" });
98-expect(res.status).toBe(403);
99-await expect(res.json()).resolves.toMatchObject({
100-ok: false,
101-error: {
102-type: "forbidden",
103-message: "missing scope: operator.read",
104-},
105-});
102+await expectMissingReadScope(res);
106103});
107104108105it("rejects /v1/models/{id} without read access", async () => {
109106const firstId = await expectFirstModelId();
110107const res = await getModels(`/v1/models/${encodeURIComponent(firstId)}`, {
111108"x-openclaw-scopes": "operator.approvals",
112109});
113-expect(res.status).toBe(403);
114-await expect(res.json()).resolves.toMatchObject({
115-ok: false,
116-error: {
117-type: "forbidden",
118-message: "missing scope: operator.read",
119-},
120-});
110+await expectMissingReadScope(res);
121111});
122112123113it("rejects when disabled", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。