fix: support Bedrock API key login
This commit is contained in:
@@ -181,4 +181,13 @@ describe("bedrock endpoint resolution", () => {
|
||||
|
||||
expect(config.region).toBe("us-gov-west-1");
|
||||
});
|
||||
|
||||
it("uses the generic API key option as a Bedrock bearer token", async () => {
|
||||
const model = getModel("amazon-bedrock", "us.anthropic.claude-opus-4-8");
|
||||
|
||||
const config = await captureClientConfig(model, { apiKey: "bedrock-api-key" });
|
||||
|
||||
expect(config.token).toEqual({ token: "bedrock-api-key" });
|
||||
expect(config.authSchemePreference).toEqual(["httpBearerAuth"]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user