mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 20:54:33 +00:00
chore: Fix lint.
This commit is contained in:
@@ -6,10 +6,17 @@ import {
|
|||||||
refreshChutesTokens,
|
refreshChutesTokens,
|
||||||
} from "./chutes-oauth.js";
|
} from "./chutes-oauth.js";
|
||||||
|
|
||||||
|
const urlToString = (url: Request | URL | string): string => {
|
||||||
|
if (typeof url === "string") {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
return "url" in url ? url.url : String(url);
|
||||||
|
};
|
||||||
|
|
||||||
describe("chutes-oauth", () => {
|
describe("chutes-oauth", () => {
|
||||||
it("exchanges code for tokens and stores username as email", async () => {
|
it("exchanges code for tokens and stores username as email", async () => {
|
||||||
const fetchFn: typeof fetch = async (input, init) => {
|
const fetchFn: typeof fetch = async (input, init) => {
|
||||||
const url = String(input);
|
const url = urlToString(input);
|
||||||
if (url === CHUTES_TOKEN_ENDPOINT) {
|
if (url === CHUTES_TOKEN_ENDPOINT) {
|
||||||
expect(init?.method).toBe("POST");
|
expect(init?.method).toBe("POST");
|
||||||
expect(
|
expect(
|
||||||
@@ -59,7 +66,7 @@ describe("chutes-oauth", () => {
|
|||||||
|
|
||||||
it("refreshes tokens using stored client id and falls back to old refresh token", async () => {
|
it("refreshes tokens using stored client id and falls back to old refresh token", async () => {
|
||||||
const fetchFn: typeof fetch = async (input, init) => {
|
const fetchFn: typeof fetch = async (input, init) => {
|
||||||
const url = String(input);
|
const url = urlToString(input);
|
||||||
if (url !== CHUTES_TOKEN_ENDPOINT) {
|
if (url !== CHUTES_TOKEN_ENDPOINT) {
|
||||||
return new Response("not found", { status: 404 });
|
return new Response("not found", { status: 404 });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ function installFailingFetchCapture() {
|
|||||||
if (rawBody instanceof ArrayBuffer) {
|
if (rawBody instanceof ArrayBuffer) {
|
||||||
return Buffer.from(new Uint8Array(rawBody)).toString("utf8");
|
return Buffer.from(new Uint8Array(rawBody)).toString("utf8");
|
||||||
}
|
}
|
||||||
return String(rawBody);
|
return null;
|
||||||
})();
|
})();
|
||||||
lastBody = bodyText ? (JSON.parse(bodyText) as unknown) : undefined;
|
lastBody = bodyText ? (JSON.parse(bodyText) as unknown) : undefined;
|
||||||
throw new Error("intentional fetch abort (test)");
|
throw new Error("intentional fetch abort (test)");
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ describe("acquireSessionWriteLock", () => {
|
|||||||
});
|
});
|
||||||
it("cleans up locks on SIGINT without removing other handlers", async () => {
|
it("cleans up locks on SIGINT without removing other handlers", async () => {
|
||||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-lock-"));
|
const root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-lock-"));
|
||||||
const originalKill = process.kill.bind(process) as typeof process.kill;
|
const originalKill = process.kill.bind(process);
|
||||||
const killCalls: Array<NodeJS.Signals | undefined> = [];
|
const killCalls: Array<NodeJS.Signals | undefined> = [];
|
||||||
let otherHandlerCalled = false;
|
let otherHandlerCalled = false;
|
||||||
|
|
||||||
|
|||||||
@@ -19,13 +19,20 @@ async function getFreePort(): Promise<number> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const urlToString = (url: Request | URL | string): string => {
|
||||||
|
if (typeof url === "string") {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
return "url" in url ? url.url : String(url);
|
||||||
|
};
|
||||||
|
|
||||||
describe("loginChutes", () => {
|
describe("loginChutes", () => {
|
||||||
it("captures local redirect and exchanges code for tokens", async () => {
|
it("captures local redirect and exchanges code for tokens", async () => {
|
||||||
const port = await getFreePort();
|
const port = await getFreePort();
|
||||||
const redirectUri = `http://127.0.0.1:${port}/oauth-callback`;
|
const redirectUri = `http://127.0.0.1:${port}/oauth-callback`;
|
||||||
|
|
||||||
const fetchFn: typeof fetch = async (input, init) => {
|
const fetchFn: typeof fetch = async (input, init) => {
|
||||||
const url = String(input);
|
const url = urlToString(input);
|
||||||
if (url === CHUTES_TOKEN_ENDPOINT) {
|
if (url === CHUTES_TOKEN_ENDPOINT) {
|
||||||
return new Response(
|
return new Response(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
@@ -68,7 +75,7 @@ describe("loginChutes", () => {
|
|||||||
|
|
||||||
it("supports manual flow with pasted code", async () => {
|
it("supports manual flow with pasted code", async () => {
|
||||||
const fetchFn: typeof fetch = async (input) => {
|
const fetchFn: typeof fetch = async (input) => {
|
||||||
const url = String(input);
|
const url = urlToString(input);
|
||||||
if (url === CHUTES_TOKEN_ENDPOINT) {
|
if (url === CHUTES_TOKEN_ENDPOINT) {
|
||||||
return new Response(
|
return new Response(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
@@ -107,7 +114,7 @@ describe("loginChutes", () => {
|
|||||||
|
|
||||||
it("does not reuse code_verifier as state", async () => {
|
it("does not reuse code_verifier as state", async () => {
|
||||||
const fetchFn: typeof fetch = async (input) => {
|
const fetchFn: typeof fetch = async (input) => {
|
||||||
const url = String(input);
|
const url = urlToString(input);
|
||||||
if (url === CHUTES_TOKEN_ENDPOINT) {
|
if (url === CHUTES_TOKEN_ENDPOINT) {
|
||||||
return new Response(
|
return new Response(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|||||||
import { installProcessWarningFilter, shouldIgnoreWarning } from "./warning-filter.js";
|
import { installProcessWarningFilter, shouldIgnoreWarning } from "./warning-filter.js";
|
||||||
|
|
||||||
const warningFilterKey = Symbol.for("openclaw.warning-filter");
|
const warningFilterKey = Symbol.for("openclaw.warning-filter");
|
||||||
const baseEmitWarning = process.emitWarning.bind(process) as typeof process.emitWarning;
|
const baseEmitWarning = process.emitWarning.bind(process);
|
||||||
|
|
||||||
function resetWarningFilterInstallState(): void {
|
function resetWarningFilterInstallState(): void {
|
||||||
const globalState = globalThis as typeof globalThis & {
|
const globalState = globalThis as typeof globalThis & {
|
||||||
|
|||||||
Reference in New Issue
Block a user