espennilsen/pi / extensions/pi-a2a
pi-a2a
Flaggedoutbound-auth.test.ts
View on GitHubimport { describe, it } from "node:test";
import assert from "node:assert/strict";
import type { AuthSelection, PeerAuthMetadata } from "./auth-types.ts";
import { LegacyApiKeyProvider } from "./token-provider.ts";
import { buildOutboundAuthContext } from "./outbound-auth.ts";
const peer: PeerAuthMetadata = { agentId: "peer-1", endpoint: "https://peer.example", source: "static-directory", supportedAuthModes: ["legacy-api-key", "oauth2+mtls"] };
const selection: AuthSelection = { selectedAuthMode: "legacy-api-key", source: "static-directory", denial: null };
describe("buildOutboundAuthContext", () => {
it("returns a typed Bearer authorization header for legacy auth", async () => {
const context = await buildOutboundAuthContext({ peer, selection, provider: new LegacyApiKeyProvider("legacy-secret") });
assert.equal(context.headers.Authorization, "Bearer legacy-secret");
assert.deepEqual(context.transport, { kind: "default" });
});
it("rejects oauth2+mtls before consulting a token provider", async () => {
let acquired = false;
const provider = { getAccessToken: async () => { acquired = true; return { value: "secret", tokenType: "Bearer" as const, mode: "oauth2+mtls" as const }; } };
await assert.rejects(
() => buildOutboundAuthContext({ peer, selection: { ...selection, selectedAuthMode: "oauth2+mtls" }, provider, localAuth: { mtls: { certPath: "cert.pem", keyPath: "key.pem" } } }),
/unavailable until outbound mTLS transport is installed/,
);
assert.equal(acquired, false);
});
});
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |