mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 03:00:21 +00:00
refactor: unify typing dispatch lifecycle and policy boundaries
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { fetchWithBearerAuthScopeFallback } from "./fetch-auth.js";
|
||||
|
||||
const asFetch = (fn: unknown): typeof fetch => fn as typeof fetch;
|
||||
|
||||
describe("fetchWithBearerAuthScopeFallback", () => {
|
||||
it("rejects non-https urls when https is required", async () => {
|
||||
await expect(
|
||||
@@ -19,7 +21,7 @@ describe("fetchWithBearerAuthScopeFallback", () => {
|
||||
const response = await fetchWithBearerAuthScopeFallback({
|
||||
url: "https://example.com/file",
|
||||
scopes: ["https://graph.microsoft.com"],
|
||||
fetchFn,
|
||||
fetchFn: asFetch(fetchFn),
|
||||
tokenProvider,
|
||||
});
|
||||
|
||||
@@ -38,7 +40,7 @@ describe("fetchWithBearerAuthScopeFallback", () => {
|
||||
const response = await fetchWithBearerAuthScopeFallback({
|
||||
url: "https://graph.microsoft.com/v1.0/me",
|
||||
scopes: ["https://graph.microsoft.com", "https://api.botframework.com"],
|
||||
fetchFn,
|
||||
fetchFn: asFetch(fetchFn),
|
||||
tokenProvider,
|
||||
});
|
||||
|
||||
@@ -57,7 +59,7 @@ describe("fetchWithBearerAuthScopeFallback", () => {
|
||||
const response = await fetchWithBearerAuthScopeFallback({
|
||||
url: "https://example.com/file",
|
||||
scopes: ["https://graph.microsoft.com"],
|
||||
fetchFn,
|
||||
fetchFn: asFetch(fetchFn),
|
||||
tokenProvider,
|
||||
shouldAttachAuth: () => false,
|
||||
});
|
||||
@@ -82,7 +84,7 @@ describe("fetchWithBearerAuthScopeFallback", () => {
|
||||
const response = await fetchWithBearerAuthScopeFallback({
|
||||
url: "https://graph.microsoft.com/v1.0/me",
|
||||
scopes: ["https://first.example", "https://second.example"],
|
||||
fetchFn,
|
||||
fetchFn: asFetch(fetchFn),
|
||||
tokenProvider,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user