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
49
clients/tui/__tests__/tuiOAuth.test.ts
Normal file
49
clients/tui/__tests__/tuiOAuth.test.ts
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import { describe, it, expect } from "vitest";
|
||||
import {
|
||||
isStandardOAuthStepUp,
|
||||
isStepUpConfirmation,
|
||||
stepUpConfirmMessage,
|
||||
stepUpInsufficientScopeMessage,
|
||||
} from "../src/utils/tuiOAuth.js";
|
||||
|
||||
describe("tuiOAuth", () => {
|
||||
it("detects standard OAuth step-up", () => {
|
||||
expect(
|
||||
isStandardOAuthStepUp(
|
||||
{ reason: "insufficient_scope", requiredScopes: ["weather:read"] },
|
||||
{ enterpriseManaged: false },
|
||||
),
|
||||
).toBe(true);
|
||||
expect(
|
||||
isStandardOAuthStepUp(
|
||||
{ reason: "insufficient_scope", requiredScopes: ["weather:read"] },
|
||||
{ enterpriseManaged: true },
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("detects EMA step-up confirmation", () => {
|
||||
expect(
|
||||
isStepUpConfirmation(
|
||||
{ reason: "insufficient_scope", requiredScopes: ["env:read"] },
|
||||
{ enterpriseManaged: true },
|
||||
),
|
||||
).toBe(true);
|
||||
expect(
|
||||
isStepUpConfirmation(
|
||||
{ reason: "insufficient_scope", requiredScopes: ["weather:read"] },
|
||||
{ enterpriseManaged: false },
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("formats step-up messages", () => {
|
||||
const challenge = {
|
||||
reason: "insufficient_scope" as const,
|
||||
requiredScopes: ["weather:read"],
|
||||
context: { toolName: "get_temp" },
|
||||
};
|
||||
expect(stepUpConfirmMessage(challenge)).toMatch(/get_temp/);
|
||||
expect(stepUpInsufficientScopeMessage(challenge)).toMatch(/get_temp/);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue