fix: support Bedrock API key login

This commit is contained in:
Armin Ronacher
2026-07-10 19:34:11 +02:00
parent 91585d9a38
commit 3ea064ea2a
10 changed files with 72 additions and 36 deletions
+13
View File
@@ -54,6 +54,19 @@ describe("builtin providers", () => {
expect(result?.source).toBe("ANTHROPIC_OAUTH_TOKEN");
});
it("prompts for and stores a Bedrock API key", async () => {
const provider = amazonBedrockProvider();
const credential = await provider.auth.apiKey?.login?.({
prompt: async (prompt) => {
expect(prompt).toEqual({ type: "secret", message: "Enter Bedrock API key" });
return "bedrock-api-key";
},
notify: () => {},
});
expect(credential).toEqual({ type: "api_key", key: "bedrock-api-key" });
});
it("reports bedrock as configured from ambient AWS credentials without an api key", async () => {
const models = createModels({ authContext: fakeAuthContext({ AWS_PROFILE: "dev" }) });
models.setProvider(amazonBedrockProvider());