fix(providers): show revealed connection API keys (#4583)

Integrated into release/v3.8.34
This commit is contained in:
Randi
2026-06-22 16:04:21 -04:00
committed by GitHub
parent e2522e2e0a
commit 1087d5a406
2 changed files with 28 additions and 6 deletions

View File

@@ -683,9 +683,7 @@ export default function EditConnectionModal({
{showFreeModelsToggle && (
<Toggle
checked={formData.importFreeModelsOnly}
onChange={(checked) =>
setFormData({ ...formData, importFreeModelsOnly: checked })
}
onChange={(checked) => setFormData({ ...formData, importFreeModelsOnly: checked })}
label={t("importFreeModelsOnlyLabel")}
description={t("importFreeModelsOnlyHint")}
/>
@@ -1020,10 +1018,9 @@ export default function EditConnectionModal({
return (
<div className="flex items-center gap-2">
<span
className={`flex-1 font-mono text-xs bg-sidebar/50 px-3 py-2 rounded border border-border truncate ${statusColor}`}
className={`flex-1 min-w-0 break-all font-mono text-xs bg-sidebar/50 px-3 py-2 rounded border border-border ${statusColor}`}
>
{statusIcon} {t("primaryKey")}: {connection.apiKey.slice(0, 6)}...
{connection.apiKey.slice(-4)}
{statusIcon} {t("primaryKey")}: {connection.apiKey}
</span>
{health && (
<span

View File

@@ -149,6 +149,31 @@ describe("conn-modals (Phase 1c extraction)", () => {
expect(c.querySelector("*")).not.toBeNull();
});
it("EditConnectionModal renders the API key value returned by the provider connection API", () => {
const onSave = vi.fn().mockResolvedValue(undefined);
const fullApiKey = "test-provider-key-full-1234567890abcdef78b9";
const connection = {
id: "conn-full-key",
name: "Test Connection",
provider: "openai",
authType: "apikey",
priority: 1,
apiKey: fullApiKey,
};
const c = renderModal(
<EditConnectionModal
isOpen={true}
connection={connection}
providerId="openai"
onSave={onSave}
onClose={vi.fn()}
/>
);
expect(c.textContent).toContain(fullApiKey);
expect(c.textContent).not.toContain("test-p...78b9");
});
it("EditConnectionModal renders OpenRouter preset when provider comes from the page", () => {
const onSave = vi.fn().mockResolvedValue(undefined);
const connection = {