All of the mid-session and step-up auth work
This commit is contained in:
parent
1f31e0f1f8
commit
562bdd00f1
1 changed files with 11437 additions and 1212 deletions
|
|
@ -2,6 +2,7 @@ import React from "react";
|
|||
import { describe, it, expect, vi, afterEach } from "vitest";
|
||||
import { render } from "ink-testing-library";
|
||||
import type { InspectorClient } from "@inspector/core/mcp/index.js";
|
||||
import { AuthRecoveryRequiredError } from "@inspector/core/auth/challenge.js";
|
||||
|
||||
// ScrollView passthrough so the results JSX actually mounts (and is covered).
|
||||
vi.mock("ink-scroll-view", () => import("./helpers/inkScrollViewMock.js"));
|
||||
|
|
@ -264,4 +265,32 @@ describe("ResourceTestModal", () => {
|
|||
await tick();
|
||||
api.unmount();
|
||||
});
|
||||
|
||||
it("delegates AuthRecoveryRequiredError to onAuthRecoveryRequired and closes", async () => {
|
||||
const recovery = new AuthRecoveryRequiredError(
|
||||
new URL("https://auth.example.com/authorize"),
|
||||
{ reason: "insufficient_scope", requiredScopes: ["weather:read"] },
|
||||
);
|
||||
const read = vi.fn().mockRejectedValue(recovery);
|
||||
const onClose = vi.fn();
|
||||
const onAuthRecoveryRequired = vi.fn();
|
||||
const api = render(
|
||||
<ResourceTestModal
|
||||
template={makeTemplate()}
|
||||
inspectorClient={fakeClient(read)}
|
||||
width={80}
|
||||
height={24}
|
||||
onClose={onClose}
|
||||
onAuthRecoveryRequired={onAuthRecoveryRequired}
|
||||
/>,
|
||||
);
|
||||
await tick();
|
||||
setSubmitValue({ name: "world" });
|
||||
api.stdin.write("\r");
|
||||
await tick();
|
||||
await tick();
|
||||
expect(onAuthRecoveryRequired).toHaveBeenCalledWith(recovery);
|
||||
expect(onClose).toHaveBeenCalledTimes(1);
|
||||
api.unmount();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue