Skip to content

Commit 44d69aa

Browse files
committed
test(coding-agent): align multi-account tests with CredentialStore list() shape
1 parent a7648c9 commit 44d69aa

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

packages/coding-agent/test/suite/auth-multi-account.test.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import { AuthStorage } from "../../src/core/auth-storage.ts";
99

1010
describe("current single-account auth storage characterization", () => {
11-
it("keeps one credential per provider and preserves independent providers", () => {
11+
it("keeps one credential per provider and preserves independent providers", async () => {
1212
// Given: the current AuthStorage with credentials for two providers.
1313
const storage = AuthStorage.inMemory({
1414
anthropic: { type: "api_key", key: "first-anthropic-key" },
@@ -21,7 +21,10 @@ describe("current single-account auth storage characterization", () => {
2121
// Then: it replaces that provider's sole credential without changing OpenAI.
2222
expect(storage.get("anthropic")).toEqual({ type: "api_key", key: "second-anthropic-key" });
2323
expect(storage.get("openai")).toEqual({ type: "api_key", key: "openai-key" });
24-
expect(storage.list()).toEqual(["anthropic", "openai"]);
24+
expect(await storage.list()).toEqual([
25+
{ providerId: "anthropic", type: "api_key" },
26+
{ providerId: "openai", type: "api_key" },
27+
]);
2528
});
2629
});
2730

@@ -56,7 +59,7 @@ function selectionRequest(): SelectionLeaseRequest {
5659
}
5760

5861
describe("multi-account credential contracts", () => {
59-
it("rotates A B A and preserves a healthy session affinity", () => {
62+
it("rotates A B A and preserves a healthy session affinity", async () => {
6063
const secondApiKeyRecord: CredentialRecord = {
6164
...apiKeyRecord,
6265
credentialId: "credential-b",
@@ -81,7 +84,7 @@ describe("multi-account credential contracts", () => {
8184
expect(vault.issueSelectionLease(sessionRequest, "gateway-a").credentialId).toBe("credential-b");
8285
});
8386

84-
it("does not fall back from an explicit pin and cools down after 401 or 429", () => {
87+
it("does not fall back from an explicit pin and cools down after 401 or 429", async () => {
8588
let now = 1_784_131_200_000;
8689
const secondApiKeyRecord: CredentialRecord = {
8790
...apiKeyRecord,
@@ -164,7 +167,7 @@ describe("multi-account credential contracts", () => {
164167
selected?.reportOutcome("rate_limited");
165168
await expect(storage.selectPooledCredential("openai")).rejects.toThrow("No eligible credential is available");
166169
});
167-
it("persists two redacted credential records and consumes one authenticated lease", () => {
170+
it("persists two redacted credential records and consumes one authenticated lease", async () => {
168171
// Given: two credentials from separate provider/type pools.
169172
const original = InMemoryCredentialVault.fromRecords([apiKeyRecord, oauthRecord]);
170173

@@ -185,7 +188,7 @@ describe("multi-account credential contracts", () => {
185188
expect(lease.material).toEqual({ type: "api_key", apiKey: "test-api-key-a" });
186189
});
187190

188-
it("rejects an invalid selector and a replayed or unauthenticated lease without logging secrets", () => {
191+
it("rejects an invalid selector and a replayed or unauthenticated lease without logging secrets", async () => {
189192
// Given: a vault with a single API-key credential and a captured log sink.
190193
const logs: string[] = [];
191194
const vault = InMemoryCredentialVault.fromRecords([apiKeyRecord, oauthRecord], (entry) =>
@@ -214,7 +217,7 @@ describe("multi-account credential contracts", () => {
214217
expect(logs.join("\n")).not.toContain("test-refresh-token-b");
215218
});
216219

217-
it("redacts malformed runtime selector errors", () => {
220+
it("redacts malformed runtime selector errors", async () => {
218221
// Given: an untyped runtime selector containing caller-supplied secret-like data.
219222
const sentinel = "selector-secret-sentinel";
220223
const logs: string[] = [];
@@ -237,7 +240,7 @@ describe("multi-account credential contracts", () => {
237240
expect(logs.join("\n")).not.toContain(sentinel);
238241
});
239242

240-
it("counts pool-only credentials as configured auth", () => {
243+
it("counts pool-only credentials as configured auth", async () => {
241244
const poolOnly = {
242245
...apiKeyRecord,
243246
pool: { provider: "custom-pool-provider", type: "api_key" as const },
@@ -285,4 +288,4 @@ describe("multi-account credential contracts", () => {
285288
resetOAuthProviders();
286289
});
287290

288-
});
291+
});

0 commit comments

Comments
 (0)