OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
feat: Improve Red Hat OpenShift API model provider settings UI / UX (#2525)
Mike Pawlowski619dc003320b
diff --git a/enhancements/providers/redhat/openshift_ai.py b/enhancements/providers/redhat/openshift_ai.pyindex 11552e0d4..2ff45faab 100644--- a/enhancements/providers/redhat/openshift_ai.py+++ b/enhancements/providers/redhat/openshift_ai.py@@ -102,8 +102,9 @@ CREDENTIAL_FIELDS: list[dict[str, Any]] = ["label": "Chat endpoint","placeholder": "https://openrag-chat-predictor.openrag-models.svc.cluster.local:8443/v1","tooltip": "URL of the InferenceService serving your chat model, ending in /v1. "- "In-cluster this is the predictor Service; from a laptop it is an oc port-forward "- "or a Route.",+ "In-cluster, this is the predictor Service; otherwise, this is a Route or an "+ "`oc port-forward`. "+ "This endpoint may also serve an embedding model.","required": True,"field_type": "text","options": None,@@ -114,8 +115,7 @@ CREDENTIAL_FIELDS: list[dict[str, Any]] = ["label": "Embeddings endpoint","placeholder": "https://openrag-embed-predictor.openrag-models.svc.cluster.local:8443/v1","tooltip": "URL of the InferenceService serving your embedding model, ending in /v1. "- "vLLM serves one model per deployment, so this is a second InferenceService. Leave "- "blank only if one endpoint serves both.",+ "vLLM serves one model per deployment, so this is a second InferenceService.","required": False,"field_type": "text","options": None,@@ -123,11 +123,12 @@ CREDENTIAL_FIELDS: list[dict[str, Any]] = [},{"key": "api_key",+ # The Kubernetes kind name: a proper noun, so it reads correctly where+ # it is interpolated mid-sentence (CredentialTargetChangedError)."label": "ServiceAccount token","placeholder": None,"tooltip": "A Kubernetes bearer token whose subject has `get` on inferenceservices in "- "the model namespace, e.g. `oc create token openrag-inference -n openrag`. Both "- "endpoints are authenticated with the same token.",+ "the model namespace. Both endpoints are authenticated with the same token.","required": True,"field_type": "password","options": None,@@ -135,13 +136,13 @@ CREDENTIAL_FIELDS: list[dict[str, Any]] = [},{"key": "ssl_verify",- "label": "TLS certificate authority",+ "label": "Verify TLS certificates","placeholder": "/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt",- "tooltip": "Path to the CA bundle that signs the endpoint's certificate. In-cluster "- "this is OpenShift's projected service CA. Set to `false` to skip verification — "- "development only, for a port-forward whose certificate cannot match localhost.",+ "tooltip": "Path to the CA bundle that signs the endpoint's certificate. In-cluster, "+ "this is OpenShift's projected service CA.","required": False,- "field_type": "text",+ # A switch plus a CA path; blank (`default_value` None) means verify.+ "field_type": "tls_verify","options": None,"default_value": None,},@@ -152,11 +153,8 @@ CREDENTIAL_FIELDS: list[dict[str, Any]] = ["tooltip": "How many embedding requests OpenRAG sends to the embedding endpoint at ""once; the rest wait in OpenRAG. One slot is kept for search and chat queries so ""they never wait behind ingestion. Leave blank for the default of 16, sized for a "- "GPU-served model. A CPU-served model whose vLLM threads match its CPU limit "- "copes with 16; lower it to 4 if the endpoint takes more than about a second per "- "chunk: the endpoint's kube-rbac-proxy returns 502 once a queued request waits "- "past its upstream timeout (30s by default), which fails ingestion. 0 means no "- "limit.",+ "GPU-served model. Lower to 4 if ingestion fails with 502s on a slow CPU-served "+ "model. 0 means no limit.","required": False,"field_type": "text","options": None,diff --git a/enhancements/providers/watsonx/onprem.py b/enhancements/providers/watsonx/onprem.pyindex 8b6bb5dd2..18ba1c27f 100644--- a/enhancements/providers/watsonx/onprem.py+++ b/enhancements/providers/watsonx/onprem.py@@ -152,13 +152,13 @@ CREDENTIAL_FIELDS: list[dict[str, Any]] = [},{"key": "ssl_verify",- "label": "TLS certificate verification",+ "label": "Verify TLS certificates","placeholder": "/etc/ssl/certs/openrag-ca.pem",- "tooltip": "Verify the cluster certificate using OpenRAG's trust store, or provide "- "the backend path to a mounted CA bundle. Disabling verification is for local "- "development only.",+ "tooltip": "Optional backend filesystem path to a mounted CA bundle. Include public "+ "roots too if this OpenRAG deployment also calls public providers.","required": False,- "field_type": "text",+ # A switch plus a CA path; `default_value` is what "verify" is stored as.+ "field_type": "tls_verify","options": None,"default_value": "true",},diff --git a/frontend/app/onboarding/_components/generic-onboarding.test.tsx b/frontend/app/onboarding/_components/generic-onboarding.test.tsxindex 6e3d9f3df..f10f9c60b 100644--- a/frontend/app/onboarding/_components/generic-onboarding.test.tsx+++ b/frontend/app/onboarding/_components/generic-onboarding.test.tsx@@ -67,9 +67,9 @@ const catalog = {},{key: "ssl_verify",- label: "TLS certificate verification",+ label: "Verify TLS certificates",required: false,- field_type: "text",+ field_type: "tls_verify",},],models: [@@ -103,6 +103,19 @@ const catalog = {required: true,field_type: "password",},+ // Catalogue order, as the backend publishes it: TLS before the limit.+ {+ key: "ssl_verify",+ label: "Verify TLS certificates",+ required: false,+ field_type: "tls_verify",+ },+ {+ key: "embedding_max_concurrency",+ label: "Max concurrent embedding requests",+ required: false,+ field_type: "text",+ },],models: [{ model: "granite-3.3-2b-instruct", mode: "chat" }],embedding_models: [@@ -1209,3 +1222,253 @@ describe("GenericOnboarding cluster model discovery", () => {expect(requests).toHaveLength(0);});});++describe("GenericOnboarding RHOAI sections", () => {+ const embeddingsToggle = () =>+ screen.getByRole("button", { name: "Embeddings" });+ const advancedToggle = () =>+ screen.getByRole("button", { name: "Advanced settings" });+ const tlsSwitch = () =>+ screen.getByRole("switch", { name: "Verify TLS certificates" });+ const embeddingEndpoint = () =>+ screen.getByRole("textbox", { name: /Embedding endpoint/ });+ const concurrency = () =>+ screen.getByRole("textbox", { name: /Max concurrent embedding requests/ });+ const caPath = () =>+ screen.getByRole("textbox", { name: "Custom CA bundle path" });++ function expectInDocumentOrder(...elements: HTMLElement[]) {+ for (let i = 1; i < elements.length; i++) {+ expect(+ elements[i - 1].compareDocumentPosition(elements[i]) &+ Node.DOCUMENT_POSITION_FOLLOWING,+ ).toBeTruthy();+ }+ }++ const savedRhoai = (+ credentialValues: Record<string, string>,+ secretFields: string[] = [],+ ): SavedProvidersSnapshot => ({+ custom: {+ rhoai: {+ credential_values: {+ api_base: "https://chat.example.com/v1",+ ...credentialValues,+ },+ secret_fields: secretFields,+ },+ },+ });++ it("shows only the chat endpoint and token up front in the language step", async () => {+ renderOnboarding("rhoai");++ const chat = await screen.findByLabelText(/Chat endpoint/);+ expectInDocumentOrder(+ chat,+ screen.getByLabelText(/Token/),+ embeddingsToggle(),+ advancedToggle(),+ );+ expect(embeddingsToggle()).toHaveAttribute("aria-expanded", "false");+ expect(advancedToggle()).toHaveAttribute("aria-expanded", "false");+ expect(+ screen.queryByLabelText(/Embedding endpoint/),+ ).not.toBeInTheDocument();+ expect(+ screen.queryByLabelText(/Max concurrent embedding requests/),+ ).not.toBeInTheDocument();+ expect(screen.queryByRole("switch")).not.toBeInTheDocument();+ // The free-text field is replaced, never rendered alongside the switch.+ expect(+ screen.queryByRole("textbox", { name: /Verify TLS certificates/ }),+ ).not.toBeInTheDocument();+ });++ it("opens Embeddings in the embedding step, where its endpoint matters", async () => {+ renderOnboarding("rhoai", true);++ await screen.findByLabelText(/Chat endpoint/);+ expect(embeddingsToggle()).toHaveAttribute("aria-expanded", "true");+ expect(embeddingEndpoint()).toBeInTheDocument();+ expect(+ screen.getByText(+ "Leave endpoint blank only if the chat endpoint also serves your embedding model.",+ ),+ ).toBeInTheDocument();+ expect(advancedToggle()).toHaveAttribute("aria-expanded", "false");+ });++ it("orders the fields inside each section", async () => {+ const { user } = renderOnboarding("rhoai");+ await user.click(await screen.findByRole("button", { name: "Embeddings" }));+ await user.click(advancedToggle());++ expectInDocumentOrder(+ embeddingEndpoint(),+ concurrency(),+ tlsSwitch(),+ caPath(),+ );+ // Verification is on unless the operator turns it off.+ expect(tlsSwitch()).toBeChecked();+ });++ it("submits false when verification is switched off", async () => {+ const { user, getSettings } = renderOnboarding("rhoai");+ await user.click(+ await screen.findByRole("button", { name: "Advanced settings" }),+ );++ await user.click(tlsSwitch());++ expect(getSettings().provider_credentials?.rhoai?.ssl_verify).toBe("false");+ expect(screen.getByRole("alert")).toHaveTextContent(+ "Certificate verification is disabled.",+ );+ });++ it("submits the embeddings endpoint, limit and CA path that were typed", async () => {+ const { user, getSettings } = renderOnboarding("rhoai");+ await user.click(await screen.findByRole("button", { name: "Embeddings" }));+ await user.click(advancedToggle());++ await user.type(embeddingEndpoint(), "https://embed.example.com/v1");+ await user.type(concurrency(), "4");+ await user.type(caPath(), "/var/run/secrets/service-ca.crt");++ expect(getSettings().provider_credentials?.rhoai).toMatchObject({+ embedding_api_base: "https://embed.example.com/v1",+ embedding_max_concurrency: "4",+ ssl_verify: "/var/run/secrets/service-ca.crt",+ });+ });++ it("submits nothing for TLS while verification stays at its default", async () => {+ const { user, getSettings } = renderOnboarding("rhoai");+ await user.type(+ await screen.findByLabelText(/Chat endpoint/),+ "https://chat.example.com/v1",+ );++ expect(getSettings().provider_credentials?.rhoai).toEqual({+ api_base: "https://chat.example.com/v1",+ });+ });++ it.each([+ [+ "an embeddings endpoint",+ { embedding_api_base: "https://embed.example.com/v1" },+ { embeddings: "true", advanced: "false" },+ ],+ [+ "a concurrency limit",+ { embedding_max_concurrency: "4" },+ { embeddings: "true", advanced: "false" },+ ],+ [+ "a disabled TLS setting",+ { ssl_verify: "false" },+ { embeddings: "false", advanced: "true" },+ ],+ [+ "a CA path",+ { ssl_verify: "/var/run/secrets/service-ca.crt" },+ { embeddings: "false", advanced: "true" },+ ],+ [+ "the default TLS setting",+ { ssl_verify: "true" },+ { embeddings: "false", advanced: "false" },+ ],+ ])("opens only the section holding %s when saved", async (_name, saved, expanded) => {+ renderOnboarding("rhoai", false, savedRhoai(saved));++ await screen.findByLabelText(/Chat endpoint/);+ expect(embeddingsToggle()).toHaveAttribute(+ "aria-expanded",+ expanded.embeddings,+ );+ expect(advancedToggle()).toHaveAttribute(+ "aria-expanded",+ expanded.advanced,+ );+ });++ it("shows saved values in their fields", async () => {+ renderOnboarding(+ "rhoai",+ false,+ savedRhoai({+ embedding_api_base: "https://embed.example.com/v1",+ embedding_max_concurrency: "4",+ ssl_verify: "/var/run/secrets/service-ca.crt",+ }),+ );++ await screen.findByRole("switch", { name: "Verify TLS certificates" });+ expect(embeddingEndpoint()).toHaveValue("https://embed.example.com/v1");+ expect(concurrency()).toHaveValue("4");+ expect(caPath()).toHaveValue("/var/run/secrets/service-ca.crt");+ expect(tlsSwitch()).toBeChecked();+ });++ it("removes a saved false once verification is switched back on", async () => {+ const { user, getSettings } = renderOnboarding(+ "rhoai",+ false,+ savedRhoai({ ssl_verify: "false" }),+ );+ const toggle = await screen.findByRole("switch", {+ name: "Verify TLS certificates",+ });+ expect(toggle).not.toBeChecked();+ expect(screen.getByRole("alert")).toBeInTheDocument();++ await user.click(toggle);++ // Blank means "verify" to the backend, so the saved false is removed+ // rather than overwritten with "true".+ expect(getSettings().provider_credential_removals?.rhoai).toEqual([+ "ssl_verify",+ ]);+ expect(+ getSettings().provider_credentials?.rhoai?.ssl_verify,+ ).toBeUndefined();+ });++ it("asks for the token again only while the TLS setting differs from the saved one", async () => {+ const { user, getBlocker } = renderOnboarding(+ "rhoai",+ false,+ savedRhoai({}, ["api_key"]),+ [+ http.post("/api/models/rhoai/discover", () =>+ HttpResponse.json({ models: null, embedding_models: null }),+ ),+ ],+ );+ await user.click(+ await screen.findByRole("button", { name: "Advanced settings" }),+ );+ expect(getBlocker()).toBeNull();++ await user.click(tlsSwitch());+ await waitFor(() =>+ expect(getBlocker()).toBe(+ "Enter Token again: the endpoint or TLS setting changed.",+ ),+ );++ // Back on: blank again, exactly as saved, so the saved token still counts.+ await user.click(tlsSwitch());+ await waitFor(() => expect(getBlocker()).toBeNull());+ expect(+ screen.getByText(+ "A value is already saved. Leave this blank to keep it.",+ ),+ ).toBeInTheDocument();+ });+});diff --git a/frontend/app/onboarding/_components/generic-onboarding.tsx b/frontend/app/onboarding/_components/generic-onboarding.tsxindex 352778ca5..4eed74556 100644--- a/frontend/app/onboarding/_components/generic-onboarding.tsx+++ b/frontend/app/onboarding/_components/generic-onboarding.tsx@@ -21,9 +21,11 @@ import {authMethodCredentialKeys,clearedSavedCredentialKeys,credentialTargetChanged,+ rhoaiSectionsOpenByDefault,} from "@/components/models/provider-credentials";+import { TLS_VERIFY_FIELD_TYPE } from "@/components/models/tls-verification";+import { TlsVerificationField } from "@/components/models/tls-verification-settings";import { WatsonxSpaceSelect } from "@/components/models/watsonx-space-select";-import { WatsonxTlsSettings } from "@/components/models/watsonx-tls-settings";import type { OnboardingVariables } from "../../api/mutations/useOnboardingMutation";import { AdvancedOnboarding } from "./advanced";import {@@ -269,13 +271,15 @@ export function GenericOnboarding({);}- if (provider === "watsonx_onprem" && field.key === "ssl_verify") {+ if (field.field_type === TLS_VERIFY_FIELD_TYPE) {return (- <WatsonxTlsSettings+ <TlsVerificationFieldkey={field.key}+ field={field}idPrefix={`onboarding-${provider}`}- value={credentials.ssl_verify}- onValueChange={(value) => handleCredentialChange("ssl_verify", value)}+ value={credentials[field.key]}+ savedValue={savedCredentials[field.key] ?? ""}+ onValueChange={(value) => handleCredentialChange(field.key, value)}/>);}@@ -301,6 +305,9 @@ export function GenericOnboarding({fields={fields}azureAuthMethod={azureAuthMethod}onPremAuthMethod={onPremAuthMethod}+ rhoaiOpenByDefault={rhoaiSectionsOpenByDefault(savedCredentials, {+ isEmbedding,+ })}onAzureAuthMethodChange={(method) =>handleAuthMethodChange("azure", method)}diff --git a/frontend/app/onboarding/_components/generic-provider-credential-fields.tsx b/frontend/app/onboarding/_components/generic-provider-credential-fields.tsxindex 125c889a1..4f116a08a 100644--- a/frontend/app/onboarding/_components/generic-provider-credential-fields.tsx+++ b/frontend/app/onboarding/_components/generic-provider-credential-fields.tsx@@ -5,8 +5,10 @@ import {AZURE_AUTH_GROUPS,fieldsForKeys,ON_PREM_AUTH_GROUPS,+ type RhoaiSectionsOpen,SECRET_REENTRY_HINT,} from "@/components/models/provider-credentials";+import { RhoaiCredentialSections } from "@/components/models/rhoai-credential-sections";import {Accordion,AccordionContent,@@ -14,11 +16,17 @@ import {AccordionTrigger,} from "@/components/ui/accordion";+const RHOAI_SECTIONS_CLOSED: RhoaiSectionsOpen = {+ embeddings: false,+ advanced: false,+};+export function GenericProviderCredentialFields({provider,fields,azureAuthMethod,onPremAuthMethod,+ rhoaiOpenByDefault = RHOAI_SECTIONS_CLOSED,onAzureAuthMethodChange,onOnPremAuthMethodChange,renderField,@@ -27,6 +35,8 @@ export function GenericProviderCredentialFields({fields: CatalogCredentialField[];azureAuthMethod: string;onPremAuthMethod: string;+ /** Which RHOAI sections start open. */+ rhoaiOpenByDefault?: RhoaiSectionsOpen;onAzureAuthMethodChange: (method: string) => void;onOnPremAuthMethodChange: (method: string) => void;renderField: (field: CatalogCredentialField) => ReactNode;@@ -109,6 +119,15 @@ export function GenericProviderCredentialFields({</>);}+ if (provider === "rhoai") {+ return (+ <RhoaiCredentialSections+ fields={fields}+ renderField={renderField}+ openByDefault={rhoaiOpenByDefault}+ />+ );+ }return <>{fields.map(renderField)}</>;}diff --git a/frontend/app/settings/_components/provider-settings-dialog.test.tsx b/frontend/app/settings/_components/provider-settings-dialog.test.tsxindex adf4047df..28570e1ce 100644--- a/frontend/app/settings/_components/provider-settings-dialog.test.tsx+++ b/frontend/app/settings/_components/provider-settings-dialog.test.tsx@@ -42,9 +42,9 @@ const catalog = {},{key: "ssl_verify",- label: "TLS certificate verification",+ label: "Verify TLS certificates",required: false,- field_type: "text",+ field_type: "tls_verify",},],models: [],@@ -528,3 +528,275 @@ describe("ProviderSettingsDialog credential target changes", () => {expect(result.submitted).toBeUndefined();});});++const rhoaiCatalog = {+ providers: [+ {+ key: "rhoai",+ name: "Red Hat OpenShift AI",+ // Catalogue order, as the backend publishes it: TLS before the limit.+ credential_fields: [+ {+ key: "api_base",+ label: "Chat endpoint",+ required: true,+ field_type: "text",+ },+ {+ key: "embedding_api_base",+ label: "Embeddings endpoint",+ required: false,+ field_type: "text",+ },+ {+ key: "api_key",+ label: "ServiceAccount token",+ required: true,+ field_type: "password",+ },+ {+ key: "ssl_verify",+ label: "Verify TLS certificates",+ required: false,+ field_type: "tls_verify",+ },+ {+ key: "embedding_max_concurrency",+ label: "Max concurrent embedding requests",+ required: false,+ field_type: "text",+ },+ ],+ models: [],+ embedding_models: [],+ },+ ],+};++describe("ProviderSettingsDialog Red Hat OpenShift AI", () => {+ const rhoaiSaved = (credentialValues: Record<string, string> = {}) => ({+ provider: "rhoai",+ providerCatalog: rhoaiCatalog,+ credentialValues: {+ api_base: "https://chat.example.com/v1",+ ...credentialValues,+ },+ secretFields: ["api_key"],+ authMethod: "",+ });+ const embeddingsToggle = () =>+ screen.getByRole("button", { name: "Embeddings" });+ const advancedToggle = () =>+ screen.getByRole("button", { name: "Advanced settings" });+ const tlsSwitch = () =>+ screen.getByRole("switch", { name: "Verify TLS certificates" });+ const caPath = () =>+ screen.getByRole("textbox", { name: "Custom CA bundle path" });++ function expectInDocumentOrder(...elements: HTMLElement[]) {+ for (let i = 1; i < elements.length; i++) {+ expect(+ elements[i - 1].compareDocumentPosition(elements[i]) &+ Node.DOCUMENT_POSITION_FOLLOWING,+ ).toBeTruthy();+ }+ }++ it("shows only the chat endpoint and token up front", async () => {+ renderDialog(rhoaiSaved());+ const user = userEvent.setup();++ const chat = await screen.findByLabelText(/^Chat endpoint/);+ expectInDocumentOrder(+ chat,+ screen.getByLabelText(/^ServiceAccount token/),+ embeddingsToggle(),+ advancedToggle(),+ );+ expect(embeddingsToggle()).toHaveAttribute("aria-expanded", "false");+ expect(advancedToggle()).toHaveAttribute("aria-expanded", "false");+ expect(+ screen.queryByLabelText(/^Embeddings endpoint/),+ ).not.toBeInTheDocument();+ expect(screen.queryByRole("switch")).not.toBeInTheDocument();++ await user.click(embeddingsToggle());+ await user.click(advancedToggle());++ expectInDocumentOrder(+ screen.getByLabelText(/^Embeddings endpoint/),+ screen.getByLabelText(/^Max concurrent embedding requests/),+ tlsSwitch(),+ caPath(),+ );+ expect(tlsSwitch()).toBeChecked();+ // The free-text field is replaced, never rendered alongside the switch.+ expect(+ screen.queryByRole("textbox", { name: /^Verify TLS certificates/ }),+ ).not.toBeInTheDocument();+ });++ it("opens Embeddings with a saved endpoint and treats editing it as a target change", async () => {+ const result = renderDialog(+ rhoaiSaved({ embedding_api_base: "https://embed.example.com/v1" }),+ );+ const user = userEvent.setup();++ const endpoint = await screen.findByLabelText(/^Embeddings endpoint/);+ expect(embeddingsToggle()).toHaveAttribute("aria-expanded", "true");+ expect(advancedToggle()).toHaveAttribute("aria-expanded", "false");+ expect(endpoint).toHaveValue("https://embed.example.com/v1");++ await user.clear(endpoint);+ await user.type(endpoint, "https://other-embed.example.com/v1");+ expect(screen.getByText(REENTRY_HINT)).toBeInTheDocument();+ await user.click(screen.getByRole("button", { name: "Save" }));++ expect(+ await screen.findByText("ServiceAccount token is required"),+ ).toBeInTheDocument();+ expect(result.submitted).toBeUndefined();+ });++ it("saves false once verification is switched off and the token retyped", async () => {+ const result = renderDialog(rhoaiSaved());+ const user = userEvent.setup();++ await screen.findByText(SAVED_HINT);+ await user.click(advancedToggle());+ await user.click(tlsSwitch());+ expect(screen.getByRole("alert")).toHaveTextContent(+ "Certificate verification is disabled.",+ );+ // A changed TLS setting is a new credential target.+ expect(screen.getByText(REENTRY_HINT)).toBeInTheDocument();+ await user.type(+ screen.getByLabelText(/^ServiceAccount token/),+ "sha256~new-token",+ );+ await user.click(screen.getByRole("button", { name: "Save" }));++ await waitFor(() => {+ expect(result.submitted).toEqual({+ provider_credentials: {+ rhoai: {+ api_base: "https://chat.example.com/v1",+ api_key: "sha256~new-token",+ ssl_verify: "false",+ },+ },+ });+ });+ });++ it("refuses to save a disabled TLS setting with the token kept", async () => {+ const result = renderDialog(rhoaiSaved());+ const user = userEvent.setup();++ await screen.findByText(SAVED_HINT);+ await user.click(advancedToggle());+ await user.click(tlsSwitch());+ await user.click(screen.getByRole("button", { name: "Save" }));++ expect(+ await screen.findByText("ServiceAccount token is required"),+ ).toBeInTheDocument();+ expect(result.submitted).toBeUndefined();+ });++ it("removes a saved false once verification is switched back on", async () => {+ const result = renderDialog(rhoaiSaved({ ssl_verify: "false" }));+ const user = userEvent.setup();++ // Opened by itself: a disabled TLS setting is never hidden.+ const toggle = await screen.findByRole("switch", {+ name: "Verify TLS certificates",+ });+ expect(advancedToggle()).toHaveAttribute("aria-expanded", "true");+ expect(toggle).not.toBeChecked();++ await user.click(toggle);+ await user.type(+ screen.getByLabelText(/^ServiceAccount token/),+ "sha256~new-token",+ );+ await user.click(screen.getByRole("button", { name: "Save" }));++ await waitFor(() => {+ expect(result.submitted).toEqual({+ provider_credentials: {+ rhoai: {+ api_base: "https://chat.example.com/v1",+ api_key: "sha256~new-token",+ },+ },+ provider_credential_removals: { rhoai: ["ssl_verify"] },+ });+ });+ });++ it("opens Advanced with a saved CA path and treats editing it as a target change", async () => {+ renderDialog(rhoaiSaved({ ssl_verify: "/var/run/secrets/service-ca.crt" }));+ const user = userEvent.setup();++ await screen.findByRole("switch", { name: "Verify TLS certificates" });+ expect(caPath()).toHaveValue("/var/run/secrets/service-ca.crt");+ expect(screen.queryByText(REENTRY_HINT)).not.toBeInTheDocument();++ await user.type(caPath(), "x");++ expect(screen.getByText(REENTRY_HINT)).toBeInTheDocument();+ });++ it("opens Embeddings with a saved concurrency limit and saves a new one", async () => {+ const result = renderDialog(rhoaiSaved({ embedding_max_concurrency: "4" }));+ const user = userEvent.setup();++ const limit = await screen.findByLabelText(+ /^Max concurrent embedding requests/,+ );+ expect(limit).toHaveValue("4");+ await user.clear(limit);+ await user.type(limit, "16");+ await user.click(screen.getByRole("button", { name: "Save" }));++ // Not a credential target, so the saved token is kept.+ await waitFor(() => {+ expect(result.submitted).toEqual({+ provider_credentials: {+ rhoai: {+ api_base: "https://chat.example.com/v1",+ embedding_max_concurrency: "16",+ },+ },+ });+ });+ });++ it("keeps the saved token when verification is switched off and on again", async () => {+ renderDialog(rhoaiSaved());+ const user = userEvent.setup();++ await screen.findByText(SAVED_HINT);+ await user.click(advancedToggle());+ await user.click(tlsSwitch());+ await user.click(tlsSwitch());++ expect(screen.queryByText(REENTRY_HINT)).not.toBeInTheDocument();+ expect(screen.getByText(SAVED_HINT)).toBeInTheDocument();+ });++ it("restores the saved CA path when verification is switched back on after Advanced was collapsed", async () => {+ renderDialog(rhoaiSaved({ ssl_verify: "/var/run/secrets/service-ca.crt" }));+ const user = userEvent.setup();++ await screen.findByRole("switch", { name: "Verify TLS certificates" });+ await user.click(tlsSwitch());+ await user.click(advancedToggle());+ await user.click(advancedToggle());+ await user.click(tlsSwitch());++ expect(caPath()).toHaveValue("/var/run/secrets/service-ca.crt");+ expect(screen.queryByText(REENTRY_HINT)).not.toBeInTheDocument();+ });+});diff --git a/frontend/app/settings/_components/provider-settings-dialog.tsx b/frontend/app/settings/_components/provider-settings-dialog.tsxindex 9eda1f4be..bff0e72e0 100644--- a/frontend/app/settings/_components/provider-settings-dialog.tsx+++ b/frontend/app/settings/_components/provider-settings-dialog.tsx@@ -255,6 +255,7 @@ const ProviderSettingsDialog = ({fields={fields}savedSecretFields={reusableSecretFields}reenterSecretFields={reenterSecretFields}+ savedCredentialValues={savedCredentialValues}saveError={methods.formState.errors.root?.message}azureAuthMethod={azureAuthMethod}onAzureAuthMethodChange={setAzureAuthMethod}diff --git a/frontend/app/settings/_components/provider-settings-form.tsx b/frontend/app/settings/_components/provider-settings-form.tsxindex 19d8449b4..071eef7c6 100644--- a/frontend/app/settings/_components/provider-settings-form.tsx+++ b/frontend/app/settings/_components/provider-settings-form.tsx@@ -5,10 +5,13 @@ import {AZURE_AUTH_GROUPS,fieldsForKeys,ON_PREM_AUTH_GROUPS,+ rhoaiSectionsOpenByDefault,SECRET_REENTRY_HINT,} from "@/components/models/provider-credentials";+import { RhoaiCredentialSections } from "@/components/models/rhoai-credential-sections";+import { TLS_VERIFY_FIELD_TYPE } from "@/components/models/tls-verification";+import { TlsVerificationField } from "@/components/models/tls-verification-settings";import { WatsonxSpaceSelect } from "@/components/models/watsonx-space-select";-import { WatsonxTlsSettings } from "@/components/models/watsonx-tls-settings";import {Accordion,AccordionContent,@@ -34,6 +37,7 @@ export function ProviderSettingsForm({fields,savedSecretFields,reenterSecretFields = [],+ savedCredentialValues,saveError,azureAuthMethod,onAzureAuthMethodChange,@@ -50,6 +54,8 @@ export function ProviderSettingsForm({savedSecretFields: string[];/** Saved secrets the chosen auth method needs typed again before Save. */reenterSecretFields?: string[];+ /** Saved non-secret values; decide which collapsed sections start open. */+ savedCredentialValues?: Record<string, string>;saveError?: string | null;azureAuthMethod?: string;onAzureAuthMethodChange?: (method: string) => void;@@ -86,14 +92,16 @@ export function ProviderSettingsForm({);}- if (provider === "watsonx_onprem" && field.key === "ssl_verify") {+ if (field.field_type === TLS_VERIFY_FIELD_TYPE) {return (- <WatsonxTlsSettings+ <TlsVerificationFieldkey={field.key}- idPrefix="provider-watsonx-onprem"- value={watch("credentials.ssl_verify")}+ field={field}+ idPrefix={`provider-${provider}`}+ value={watch(`credentials.${field.key}`)}+ savedValue={savedCredentialValues?.[field.key] ?? ""}onValueChange={(value) =>- setValue("credentials.ssl_verify", value, { shouldDirty: true })+ setValue(`credentials.${field.key}`, value, { shouldDirty: true })}/>);@@ -253,6 +261,12 @@ export function ProviderSettingsForm({</AccordionItem></Accordion></>+ ) : provider === "rhoai" ? (+ <RhoaiCredentialSections+ fields={fields}+ renderField={renderField}+ openByDefault={rhoaiSectionsOpenByDefault(savedCredentialValues)}+ />) : (fields.map(renderField))}diff --git a/frontend/components/models/provider-credentials.test.ts b/frontend/components/models/provider-credentials.test.tsindex 9f12783a7..d27d5a9b8 100644--- a/frontend/components/models/provider-credentials.test.ts+++ b/frontend/components/models/provider-credentials.test.ts@@ -4,6 +4,8 @@ import {authMethodCredentialKeys,clearedSavedCredentialKeys,credentialTargetChanged,+ groupRhoaiFields,+ rhoaiSectionsOpenByDefault,secretsToReenter,} from "./provider-credentials";@@ -183,3 +185,99 @@ describe("secretsToReenter", () => {).toEqual(["api_key"]);});});++describe("groupRhoaiFields", () => {+ const field = (key: string) => ({+ key,+ label: key,+ required: false,+ field_type: "text",+ });+ const keys = (fields: Array<{ key: string }>) => fields.map((f) => f.key);++ it("puts the chat endpoint and token up front and the rest in sections", () => {+ // Catalogue order deliberately differs from the display order.+ const grouped = groupRhoaiFields([+ field("ssl_verify"),+ field("embedding_max_concurrency"),+ field("api_key"),+ field("embedding_api_base"),+ field("api_base"),+ ]);++ expect(keys(grouped.primary)).toEqual(["api_base", "api_key"]);+ expect(keys(grouped.embeddings)).toEqual([+ "embedding_api_base",+ "embedding_max_concurrency",+ ]);+ expect(keys(grouped.advanced)).toEqual(["ssl_verify"]);+ });++ it("shows a field no group names up front instead of dropping it", () => {+ const grouped = groupRhoaiFields([+ field("api_base"),+ field("new_backend_field"),+ field("ssl_verify"),+ ]);++ expect(keys(grouped.primary)).toEqual(["api_base", "new_backend_field"]);+ expect(keys(grouped.embeddings)).toEqual([]);+ expect(keys(grouped.advanced)).toEqual(["ssl_verify"]);+ });++ it("skips fields the catalogue does not publish", () => {+ expect(groupRhoaiFields([field("api_base")])).toEqual({+ primary: [field("api_base")],+ embeddings: [],+ advanced: [],+ });+ expect(groupRhoaiFields([])).toEqual({+ primary: [],+ embeddings: [],+ advanced: [],+ });+ });+});++describe("rhoaiSectionsOpenByDefault", () => {+ it.each([+ [undefined, { embeddings: false, advanced: false }],+ [{}, { embeddings: false, advanced: false }],+ [+ { api_base: "https://chat.example.com/v1" },+ { embeddings: false, advanced: false },+ ],+ [+ { embedding_api_base: "https://embed.example.com/v1" },+ { embeddings: true, advanced: false },+ ],+ [{ embedding_max_concurrency: "4" }, { embeddings: true, advanced: false }],+ [+ { embedding_api_base: " ", embedding_max_concurrency: " " },+ { embeddings: false, advanced: false },+ ],+ [{ ssl_verify: "" }, { embeddings: false, advanced: false }],+ [{ ssl_verify: "true" }, { embeddings: false, advanced: false }],+ [{ ssl_verify: "false" }, { embeddings: false, advanced: true }],+ [+ { ssl_verify: "/var/run/secrets/ca.crt" },+ { embeddings: false, advanced: true },+ ],+ [+ { embedding_api_base: "https://embed.example.com/v1", ssl_verify: "0" },+ { embeddings: true, advanced: true },+ ],+ ])("opens for %j → %j", (saved, expected) => {+ expect(rhoaiSectionsOpenByDefault(saved)).toEqual(expected);+ });++ it("opens Embeddings in the onboarding embedding step whatever is saved", () => {+ expect(rhoaiSectionsOpenByDefault({}, { isEmbedding: true })).toEqual({+ embeddings: true,+ advanced: false,+ });+ expect(+ rhoaiSectionsOpenByDefault(undefined, { isEmbedding: false }),+ ).toEqual({ embeddings: false, advanced: false });+ });+});diff --git a/frontend/components/models/provider-credentials.ts b/frontend/components/models/provider-credentials.tsindex 6610e87c9..a0c3753bf 100644--- a/frontend/components/models/provider-credentials.ts+++ b/frontend/components/models/provider-credentials.ts@@ -1,4 +1,5 @@import type { CatalogCredentialField } from "@/components/models/catalog-models";+import { isDefaultTlsSetting } from "@/components/models/tls-verification";export const AZURE_AUTH_GROUPS = [{ key: "api_key", label: "API key", fields: ["api_key"] },@@ -34,6 +35,75 @@ export function fieldsForKeys(});}+/** RHOAI fields shown up front: the two every configuration needs. */+const RHOAI_PRIMARY_FIELDS = ["api_base", "api_key"] as const;++/** RHOAI fields behind "Embeddings": only embedding calls use them. */+const RHOAI_EMBEDDING_FIELDS = [+ "embedding_api_base",+ "embedding_max_concurrency",+] as const;++/** RHOAI fields behind "Advanced settings". */+const RHOAI_ADVANCED_FIELDS = ["ssl_verify"] as const;++export interface RhoaiFieldGroups {+ primary: CatalogCredentialField[];+ embeddings: CatalogCredentialField[];+ advanced: CatalogCredentialField[];+}++export interface RhoaiSectionsOpen {+ embeddings: boolean;+ advanced: boolean;+}++/**+ * The RHOAI catalogue fields split into the always-visible fields and the two+ * collapsible sections, each in display order. A field the catalogue publishes+ * that no list names goes to the visible fields, so a credential the backend+ * adds later is never silently left out of the form.+ */+export function groupRhoaiFields(+ fields: CatalogCredentialField[],+): RhoaiFieldGroups {+ const grouped = new Set<string>([+ ...RHOAI_PRIMARY_FIELDS,+ ...RHOAI_EMBEDDING_FIELDS,+ ...RHOAI_ADVANCED_FIELDS,+ ]);+ return {+ primary: [+ ...fieldsForKeys(fields, RHOAI_PRIMARY_FIELDS),+ ...fields.filter((field) => !grouped.has(field.key)),+ ],+ embeddings: fieldsForKeys(fields, RHOAI_EMBEDDING_FIELDS),+ advanced: fieldsForKeys(fields, RHOAI_ADVANCED_FIELDS),+ };+}++/**+ * Which RHOAI sections start open. A section opens when a saved value in it+ * differs from the default, so an embeddings endpoint, a concurrency limit, a+ * CA path or disabled verification is never hidden behind a collapsed section.+ * The onboarding embedding step opens "Embeddings" regardless: there, the+ * embeddings endpoint is the one that matters.+ */+export function rhoaiSectionsOpenByDefault(+ savedCredentials: Record<string, string> | undefined,+ { isEmbedding = false }: { isEmbedding?: boolean } = {},+): RhoaiSectionsOpen {+ const saved = savedCredentials ?? {};+ const hasSaved = (key: string) => (saved[key] ?? "").trim() !== "";+ return {+ embeddings:+ isEmbedding ||+ hasSaved("embedding_api_base") ||+ hasSaved("embedding_max_concurrency"),+ advanced: !isDefaultTlsSetting(saved.ssl_verify),+ };+}+const ON_PREM_SHARED_FIELDS = ["api_base","space_id",diff --git a/frontend/components/models/rhoai-credential-sections.tsx b/frontend/components/models/rhoai-credential-sections.tsxnew file mode 100644index 000000000..f4dcd413b--- /dev/null+++ b/frontend/components/models/rhoai-credential-sections.tsx@@ -0,0 +1,70 @@+import type { ReactNode } from "react";+import type { CatalogCredentialField } from "@/components/models/catalog-models";+import {+ groupRhoaiFields,+ type RhoaiSectionsOpen,+} from "@/components/models/provider-credentials";+import {+ Accordion,+ AccordionContent,+ AccordionItem,+ AccordionTrigger,+} from "@/components/ui/accordion";++/**+ * The Red Hat OpenShift AI credential form layout, shared by the Settings+ * dialog and onboarding: the chat endpoint and token up front, then the+ * collapsed "Embeddings" and "Advanced settings" sections.+ */+export function RhoaiCredentialSections({+ fields,+ renderField,+ openByDefault,+}: {+ fields: CatalogCredentialField[];+ renderField: (field: CatalogCredentialField) => ReactNode;+ openByDefault: RhoaiSectionsOpen;+}) {+ const { primary, embeddings, advanced } = groupRhoaiFields(fields);+ const defaultValue = [+ ...(openByDefault.embeddings ? ["embeddings"] : []),+ ...(openByDefault.advanced ? ["advanced"] : []),+ ];++ return (+ <>+ {primary.map(renderField)}+ {(embeddings.length > 0 || advanced.length > 0) && (+ <Accordion+ // Remounted when saved settings arrive after the first render, so a+ // saved value still opens its section.+ key={defaultValue.join(",") || "closed"}+ type="multiple"+ defaultValue={defaultValue}+ className="space-y-2"+ >+ {embeddings.length > 0 && (+ <AccordionItem value="embeddings">+ <AccordionTrigger>Embeddings</AccordionTrigger>+ <AccordionContent className="space-y-4">+ <p className="text-sm text-muted-foreground">+ Leave endpoint blank only if the chat endpoint also serves+ your embedding model.+ </p>+ {embeddings.map(renderField)}+ </AccordionContent>+ </AccordionItem>+ )}+ {advanced.length > 0 && (+ <AccordionItem value="advanced">+ <AccordionTrigger>Advanced settings</AccordionTrigger>+ <AccordionContent className="space-y-4">+ {advanced.map(renderField)}+ </AccordionContent>+ </AccordionItem>+ )}+ </Accordion>+ )}+ </>+ );+}diff --git a/frontend/components/models/tls-verification-settings.test.tsx b/frontend/components/models/tls-verification-settings.test.tsxnew file mode 100644index 000000000..293569c32--- /dev/null+++ b/frontend/components/models/tls-verification-settings.test.tsx@@ -0,0 +1,299 @@+import { useState } from "react";+import { describe, expect, it, vi } from "vitest";+import {+ Accordion,+ AccordionContent,+ AccordionItem,+ AccordionTrigger,+} from "@/components/ui/accordion";+import {+ renderWithProviders,+ screen,+ userEvent,+ within,+} from "@/test-utils/render";+import type { CatalogCredentialField } from "./catalog-models";+import { TlsVerificationField } from "./tls-verification-settings";++/** The `ssl_verify` rows the RHOAI and watsonx.ai on-prem catalogues publish. */+const PRESETS = {+ rhoai: {+ key: "ssl_verify",+ label: "Verify TLS certificates",+ placeholder: "/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt",+ tooltip:+ "Path to the CA bundle that signs the endpoint's certificate. In-cluster, this is OpenShift's projected service CA.",+ required: false,+ field_type: "tls_verify",+ default_value: null,+ },+ watsonx: {+ key: "ssl_verify",+ label: "Verify TLS certificates",+ placeholder: "/etc/ssl/certs/openrag-ca.pem",+ tooltip:+ "Optional backend filesystem path to a mounted CA bundle. Include public roots too if this OpenRAG deployment also calls public providers.",+ required: false,+ field_type: "tls_verify",+ default_value: "true",+ },+} satisfies Record<string, CatalogCredentialField>;++/**+ * Renders a field as a parent form would: the value it writes flows back in.+ * `inAccordion` puts it in an open collapsible section, as the forms do.+ */+function renderTls(+ initial: string | undefined,+ preset: keyof typeof PRESETS | CatalogCredentialField,+ {+ savedValue,+ inAccordion = false,+ }: { savedValue?: string; inAccordion?: boolean } = {},+) {+ const field = typeof preset === "string" ? PRESETS[preset] : preset;+ const writes: string[] = [];+ const onWrite = vi.fn((value: string) => writes.push(value));+ function Harness() {+ const [value, setValue] = useState(initial);+ const settings = (+ <TlsVerificationField+ field={field}+ idPrefix="test"+ value={value}+ savedValue={savedValue}+ onValueChange={(next) => {+ onWrite(next);+ setValue(next);+ }}+ />+ );+ if (!inAccordion) return settings;+ return (+ <Accordion type="multiple" defaultValue={["advanced"]}>+ <AccordionItem value="advanced">+ <AccordionTrigger>Advanced settings</AccordionTrigger>+ <AccordionContent>{settings}</AccordionContent>+ </AccordionItem>+ </Accordion>+ );+ }+ renderWithProviders(<Harness />, { providers: ["tooltip"] });+ return { user: userEvent.setup(), writes, onWrite };+}++const tlsSwitch = () =>+ screen.getByRole("switch", { name: "Verify TLS certificates" });+const caPath = () =>+ screen.queryByRole("textbox", { name: "Custom CA bundle path" });++describe.each([+ "rhoai",+ "watsonx",+] as const)("%s TLS verification settings", (preset) => {+ it("verifies by default when nothing is stored", () => {+ renderTls(undefined, preset);++ expect(tlsSwitch()).toBeChecked();+ expect(caPath()).toHaveValue("");+ expect(screen.queryByRole("alert")).not.toBeInTheDocument();+ });++ it("stores false when switched off and warns instead of asking for a CA", async () => {+ const { user, writes } = renderTls("", preset);++ await user.click(tlsSwitch());++ expect(writes.at(-1)).toBe("false");+ expect(tlsSwitch()).not.toBeChecked();+ expect(caPath()).not.toBeInTheDocument();+ expect(screen.getByRole("alert")).toHaveTextContent(+ "Certificate verification is disabled.",+ );+ });++ it("restores the CA path typed before verification was switched off", async () => {+ const { user, writes } = renderTls("", preset);++ await user.type(caPath() as HTMLElement, "/etc/ca.pem");+ expect(writes.at(-1)).toBe("/etc/ca.pem");+ await user.click(tlsSwitch());+ await user.click(tlsSwitch());++ expect(writes.at(-1)).toBe("/etc/ca.pem");+ expect(caPath()).toHaveValue("/etc/ca.pem");+ });++ it("shows a stored CA path in the CA box", () => {+ renderTls("/var/run/secrets/ca.crt", preset);+ expect(tlsSwitch()).toBeChecked();+ expect(caPath()).toHaveValue("/var/run/secrets/ca.crt");+ });++ it.each([+ "false",+ "OFF",+ "0",+ ])("shows a stored %j as switched off", (stored) => {+ renderTls(stored, preset);+ expect(tlsSwitch()).not.toBeChecked();+ expect(screen.getByRole("alert")).toBeInTheDocument();+ });++ it.each([+ "",+ "true",+ ])("writes the stored %j back when switched off and on again", async (stored) => {+ // Anything else would count as a new credential target and make the+ // operator retype a saved token for an unchanged setting.+ const { user, writes } = renderTls(stored, preset);++ await user.click(tlsSwitch());+ await user.click(tlsSwitch());++ expect(writes).toEqual(["false", stored]);+ });++ it.each([+ "/etc/ca.pem",+ "",+ "true",+ ])("restores the saved %j when switched on after its section was collapsed", async (saved) => {+ // Collapsing unmounts the section, so what was switched off from is gone;+ // the saved value is what keeps this from being a target change.+ const { user, writes } = renderTls(saved, preset, {+ savedValue: saved,+ inAccordion: true,+ });+ const section = screen.getByRole("button", { name: "Advanced settings" });++ await user.click(tlsSwitch());+ await user.click(section);+ await user.click(section);+ await user.click(tlsSwitch());++ expect(writes).toEqual(["false", saved]);+ });++ it("forgets a CA path cleared before verification was switched off", async () => {+ const { user, writes } = renderTls("/etc/ca.pem", preset, {+ savedValue: "",+ });++ await user.clear(caPath() as HTMLElement);+ await user.click(tlsSwitch());+ await user.click(tlsSwitch());++ expect(writes.at(-1)).toBe("");+ expect(caPath()).toHaveValue("");+ });+});++describe("TLS verification settings: the verified value", () => {+ it.each([+ ["rhoai", ""],+ ["watsonx", "true"],+ ] as const)("%s writes %j when switched on from a stored false with no CA path", async (preset, expected) => {+ const { user, writes } = renderTls("false", preset);++ await user.click(tlsSwitch());++ expect(writes).toEqual([expected]);+ expect(caPath()).toHaveValue("");+ });++ it.each([+ ["rhoai", ""],+ ["watsonx", "true"],+ ] as const)("%s writes %j once a stored CA path is cleared", async (preset, expected) => {+ const { user, writes } = renderTls("/etc/ca.pem", preset);++ await user.clear(caPath() as HTMLElement);++ expect(writes.at(-1)).toBe(expected);+ expect(tlsSwitch()).toBeChecked();+ });++ it.each([+ "rhoai",+ "watsonx",+ ] as const)("%s writes the saved value back once a typed CA path is cleared", async (preset) => {+ const { user, writes } = renderTls("", preset, { savedValue: "" });++ await user.type(caPath() as HTMLElement, "/x");+ await user.clear(caPath() as HTMLElement);++ expect(writes.at(-1)).toBe("");+ });++ it.each([+ ["rhoai", ""],+ ["watsonx", "true"],+ ] as const)("%s writes %j when switched on from a saved false", async (preset, expected) => {+ const { user, writes } = renderTls("false", preset, {+ savedValue: "false",+ inAccordion: true,+ });++ await user.click(tlsSwitch());++ expect(writes).toEqual([expected]);+ });+});++describe("TLS verification settings: help text from the catalogue", () => {+ async function tooltipFor(+ user: ReturnType<typeof userEvent.setup>,+ label: string,+ ) {+ const labelElement = screen.getByText(label).closest("label");+ expect(labelElement).not.toBeNull();+ await user.hover(within(labelElement as HTMLElement).getByRole("button"));+ return screen.findByRole("tooltip");+ }++ it.each([+ "rhoai",+ "watsonx",+ ] as const)("%s shows the shared switch description inline", (preset) => {+ renderTls("", preset);++ expect(tlsSwitch()).toHaveAccessibleDescription(+ "Validates the cluster certificate before sending credentials or model traffic.",+ );+ });++ it.each([+ "rhoai",+ "watsonx",+ ] as const)("%s puts the field's tooltip and placeholder on the CA path", async (preset) => {+ const { user } = renderTls("", preset);++ expect(await tooltipFor(user, "Custom CA bundle path")).toHaveTextContent(+ PRESETS[preset].tooltip,+ );+ expect(caPath()).toHaveAttribute(+ "placeholder",+ PRESETS[preset].placeholder,+ );+ });++ it("names the switch with the field's label", () => {+ renderTls("", { ...PRESETS.rhoai, label: "Check certificates" });++ expect(+ screen.getByRole("switch", { name: "Check certificates" }),+ ).toBeChecked();+ });++ it("renders a field with no tooltip or placeholder", () => {+ renderTls("", { ...PRESETS.rhoai, tooltip: null, placeholder: null });++ expect(tlsSwitch()).toBeChecked();+ expect(caPath()).not.toHaveAttribute("placeholder");+ const caLabel = screen.getByText("Custom CA bundle path").closest("label");+ expect(+ within(caLabel as HTMLElement).queryByRole("button"),+ ).not.toBeInTheDocument();+ });+});diff --git a/frontend/components/models/tls-verification-settings.tsx b/frontend/components/models/tls-verification-settings.tsxnew file mode 100644index 000000000..f6986d692--- /dev/null+++ b/frontend/components/models/tls-verification-settings.tsx@@ -0,0 +1,128 @@+"use client";++import { AlertTriangle } from "lucide-react";+import { useRef } from "react";+import { LabelWrapper } from "@/components/label-wrapper";+import type { CatalogCredentialField } from "@/components/models/catalog-models";+import { Input } from "@/components/ui/input";+import { Label } from "@/components/ui/label";+import { Switch } from "@/components/ui/switch";+import {+ isDefaultTlsSetting,+ isTlsVerificationDisabled,+ parseTlsSetting,+} from "./tls-verification";++const SWITCH_DESCRIPTION =+ "Validates the cluster certificate before sending credentials or model traffic.";+const CA_PATH_LABEL = "Custom CA bundle path";++/**+ * A provider's `tls_verify` catalogue field (its `ssl_verify` credential) as a+ * switch plus an optional CA bundle path. The stored value stays a single+ * string — blank or a true-equivalent word (verify), a false-equivalent word+ * (don't), or a CA path — which is what the backend's `resolve_ssl_verify`+ * reads.+ *+ * The catalogue supplies the copy and the default: `label` names the switch,+ * `tooltip` helps with the CA path, `placeholder` is the CA path example and+ * `default_value` is what "verify" is stored as (blank when it has none).+ */+export function TlsVerificationField({+ field,+ value,+ savedValue,+ onValueChange,+ idPrefix,+}: {+ field: CatalogCredentialField;+ value?: string;+ /**+ * The saved `ssl_verify`; blank when unset, as the credential-target check+ * reads it. Turning verification back on, or clearing the CA path, restores+ * it where it verifies, so neither reads as a target change.+ */+ savedValue?: string;+ onValueChange: (value: string) => void;+ idPrefix: string;+}) {+ // Written when verification is on with no CA path and nothing to restore.+ const verifiedValue =+ typeof field.default_value === "string" ? field.default_value : "";+ const { enabled, caPath } = parseTlsSetting(value);+ const saved = savedValue?.trim();+ const restoredValue =+ saved !== undefined && !isTlsVerificationDisabled(saved)+ ? saved+ : verifiedValue;+ const clearedValue =+ saved !== undefined && isDefaultTlsSetting(saved) ? saved : verifiedValue;+ // The value verification was switched off from. It lasts only as long as+ // this mount — a collapsed accordion section unmounts it — so the saved+ // value is the fallback.+ const valueBeforeDisabling = useRef<string | null>(null);++ const switchId = `${idPrefix}-tls-verify`;+ const descriptionId = `${switchId}-description`;+ const caPathId = `${idPrefix}-tls-ca-path`;++ return (+ <div className="space-y-4">+ <div className="flex items-center justify-between gap-4 py-1">+ <div className="space-y-1">+ <Label htmlFor={switchId} className="text-mmd font-medium">+ {field.label}+ </Label>+ <p id={descriptionId} className="text-sm text-muted-foreground">+ {SWITCH_DESCRIPTION}+ </p>+ </div>+ <Switch+ id={switchId}+ checked={enabled}+ aria-describedby={descriptionId}+ onCheckedChange={(checked) => {+ if (checked) {+ onValueChange(valueBeforeDisabling.current ?? restoredValue);+ return;+ }+ valueBeforeDisabling.current = (value ?? "").trim();+ onValueChange("false");+ }}+ />+ </div>++ {enabled ? (+ <LabelWrapper+ id={caPathId}+ label={CA_PATH_LABEL}+ helperText={field.tooltip ?? undefined}+ >+ <Input+ id={caPathId}+ value={caPath}+ placeholder={field.placeholder ?? undefined}+ autoComplete="off"+ onChange={(event) =>+ onValueChange(event.target.value || clearedValue)+ }+ />+ </LabelWrapper>+ ) : (+ <div+ role="alert"+ className="flex gap-2 rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive"+ >+ <AlertTriangle+ className="mt-0.5 h-4 w-4 shrink-0"+ aria-hidden="true"+ />+ <p>+ Certificate verification is disabled. Credentials and model traffic+ can be intercepted. Use this only for local development.+ </p>+ </div>+ )}+ </div>+ );+}diff --git a/frontend/components/models/tls-verification.test.ts b/frontend/components/models/tls-verification.test.tsnew file mode 100644index 000000000..2ef4be502--- /dev/null+++ b/frontend/components/models/tls-verification.test.ts@@ -0,0 +1,66 @@+import { describe, expect, it } from "vitest";+import {+ isDefaultTlsSetting,+ isTlsVerificationDisabled,+ parseTlsSetting,+} from "./tls-verification";++describe("parseTlsSetting", () => {+ it.each([+ undefined,+ null,+ "",+ " ",+ "true",+ "TRUE",+ "1",+ "yes",+ " on ",+ ])("reads %j as verify against the default trust store", (value) => {+ expect(parseTlsSetting(value)).toEqual({ enabled: true, caPath: "" });+ });++ it.each([+ "false",+ " Off ",+ "0",+ "no",+ "FALSE",+ ])("reads %j as verification disabled", (value) => {+ expect(parseTlsSetting(value)).toEqual({ enabled: false, caPath: "" });+ });++ it.each([+ "/var/run/secrets/ca.crt",+ "bogus",+ ])("reads %j as a CA path, keeping verification on", (value) => {+ // An unrecognised word fails closed, as the backend does: it is a path,+ // never a way to switch verification off.+ expect(parseTlsSetting(value)).toEqual({ enabled: true, caPath: value });+ });+});++describe("isTlsVerificationDisabled", () => {+ it.each([+ ["false", true],+ ["Off", true],+ ["", false],+ ["true", false],+ ["/ca.crt", false],+ [undefined, false],+ ])("is %j → %s", (value, expected) => {+ expect(isTlsVerificationDisabled(value)).toBe(expected);+ });+});++describe("isDefaultTlsSetting", () => {+ it.each([+ ["", true],+ [undefined, true],+ ["yes", true],+ ["false", false],+ ["/ca.crt", false],+ ])("is %j → %s", (value, expected) => {+ expect(isDefaultTlsSetting(value)).toBe(expected);+ });+});diff --git a/frontend/components/models/tls-verification.ts b/frontend/components/models/tls-verification.tsnew file mode 100644index 000000000..9308aa2e9--- /dev/null+++ b/frontend/components/models/tls-verification.ts@@ -0,0 +1,53 @@+/**+ * The catalogue `field_type` of a provider's `ssl_verify` credential, rendered+ * by `TlsVerificationField`. Mirrors `KNOWN_FIELD_TYPES` in `model_catalog.py`.+ */+export const TLS_VERIFY_FIELD_TYPE = "tls_verify";++/**+ * Values of a provider's `ssl_verify` credential that mean "do not verify".+ * Mirrors `_FALSE_VALUES` / `_FALSE_TLS_VALUES` in the RHOAI and watsonx.ai+ * on-prem enhancement modules.+ */+const TLS_DISABLED_VALUES: Record<string, true> = {+ false: true,+ "0": true,+ no: true,+ off: true,+};++/** Values that mean "verify against the default trust store". */+const TLS_ENABLED_VALUES: Record<string, true> = {+ true: true,+ "1": true,+ yes: true,+ on: true,+};++/**+ * Whether a stored `ssl_verify` turns verification off. Anything unrecognised+ * is a CA bundle path, so verification stays on — the backend fails closed the+ * same way.+ */+export function isTlsVerificationDisabled(value?: string | null): boolean {+ return TLS_DISABLED_VALUES[(value ?? "").trim().toLowerCase()] === true;+}++/**+ * Whether a stored `ssl_verify` is the default: blank, or a true-equivalent+ * word. Neither names a CA bundle nor turns verification off.+ */+export function isDefaultTlsSetting(value?: string | null): boolean {+ const normalized = (value ?? "").trim().toLowerCase();+ return !normalized || TLS_ENABLED_VALUES[normalized] === true;+}++/** A stored `ssl_verify` as the toggle and the CA path box show it. */+export function parseTlsSetting(value?: string | null): {+ enabled: boolean;+ caPath: string;+} {+ if (isTlsVerificationDisabled(value)) return { enabled: false, caPath: "" };+ if (isDefaultTlsSetting(value)) return { enabled: true, caPath: "" };+ return { enabled: true, caPath: value ?? "" };+}diff --git a/frontend/components/models/watsonx-space-select.tsx b/frontend/components/models/watsonx-space-select.tsxindex b8f82b9d7..88e244528 100644--- a/frontend/components/models/watsonx-space-select.tsx+++ b/frontend/components/models/watsonx-space-select.tsx@@ -19,7 +19,7 @@ import {} from "@/components/ui/popover";import { apiClient } from "@/lib/api-client";import { cn } from "@/lib/utils";-import { WATSONX_TLS_DISABLED_VALUES } from "./watsonx-tls-settings";+import { isTlsVerificationDisabled } from "./tls-verification";interface WatsonxSpace {id: string;@@ -98,8 +98,7 @@ export function WatsonxSpaceSelect({const apiKey = credentials.api_key ?? "";const zenApiKey = credentials.zen_api_key ?? "";const sslVerify = credentials.ssl_verify ?? "";- const tlsVerificationEnabled =- WATSONX_TLS_DISABLED_VALUES[sslVerify.trim().toLowerCase()] !== true;+ const tlsVerificationEnabled = !isTlsVerificationDisabled(sslVerify);const ready =Boolean(apiBase) &&(authMethod === "zen_api_key"diff --git a/frontend/components/models/watsonx-tls-settings.tsx b/frontend/components/models/watsonx-tls-settings.tsxdeleted file mode 100644index 251e4668e..000000000--- a/frontend/components/models/watsonx-tls-settings.tsx+++ /dev/null@@ -1,106 +0,0 @@-"use client";--import { AlertTriangle } from "lucide-react";-import { useRef } from "react";-import { LabelWrapper } from "@/components/label-wrapper";-import { Input } from "@/components/ui/input";-import { Label } from "@/components/ui/label";-import { Switch } from "@/components/ui/switch";--export const WATSONX_TLS_DISABLED_VALUES: Record<string, true> = {- false: true,- "0": true,- no: true,- off: true,-};-const TRUE_VALUES: Record<string, true> = {- true: true,- "1": true,- yes: true,- on: true,-};--export function WatsonxTlsSettings({- value,- onValueChange,- idPrefix,-}: {- value?: string;- onValueChange: (value: string) => void;- idPrefix: string;-}) {- const normalized = (value ?? "").trim().toLowerCase();- const enabled = WATSONX_TLS_DISABLED_VALUES[normalized] !== true;- const caPath =- !normalized ||- TRUE_VALUES[normalized] === true ||- WATSONX_TLS_DISABLED_VALUES[normalized] === true- ? ""- : (value ?? "");- const lastCaPath = useRef(caPath);- if (caPath) lastCaPath.current = caPath;-- const switchId = `${idPrefix}-tls-verify`;- const descriptionId = `${switchId}-description`;- const caPathId = `${idPrefix}-tls-ca-path`;-- return (- <div className="space-y-4">- <div className="flex items-center justify-between gap-4 py-1">- <div className="space-y-1">- <Label htmlFor={switchId} className="text-mmd font-medium">- Verify TLS certificates- </Label>- <p id={descriptionId} className="text-sm text-muted-foreground">- Recommended. Validates the cluster certificate before sending- credentials or model traffic.- </p>- </div>- <Switch- id={switchId}- checked={enabled}- aria-describedby={descriptionId}- onCheckedChange={(checked) =>- onValueChange(- checked ? lastCaPath.current.trim() || "true" : "false",- )- }- />- </div>-- {enabled ? (- <LabelWrapper- id={caPathId}- label="Custom CA bundle path"- helperText="Optional backend filesystem path to a mounted CA bundle. Include public roots too if this OpenRAG deployment also calls public providers."- >- <Input- id={caPathId}- value={caPath}- placeholder="/etc/ssl/certs/openrag-ca.pem"- autoComplete="off"- onChange={(event) => {- const next = event.target.value;- if (next) lastCaPath.current = next;- onValueChange(next || "true");- }}- />- </LabelWrapper>- ) : (- <div- role="alert"- className="flex gap-2 rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive"- >- <AlertTriangle- className="mt-0.5 h-4 w-4 shrink-0"- aria-hidden="true"- />- <p>- Certificate verification is disabled. Credentials and model traffic- can be intercepted. Use this only for local development.- </p>- </div>- )}- </div>- );-}diff --git a/src/services/model_catalog.py b/src/services/model_catalog.pyindex 46fb85f33..aab71c6f0 100644--- a/src/services/model_catalog.py+++ b/src/services/model_catalog.py@@ -96,7 +96,9 @@ GENERIC_CREDENTIAL_FIELDS: list[dict[str, Any]] = [},]-KNOWN_FIELD_TYPES = frozenset({"text", "password", "select", "textarea", "upload"})+#: `tls_verify` is a provider's `ssl_verify`: rendered as a "verify" switch plus+#: an optional CA bundle path, stored as one string.+KNOWN_FIELD_TYPES = frozenset({"text", "password", "select", "textarea", "upload", "tls_verify"})#: OpenRAG provider keys LiteLLM cannot route under their own name, mapped to#: the key it routes them as. A row here is for a deployment shape that needsdiff --git a/tests/unit/enhancements/providers/redhat/test_openshift_ai.py b/tests/unit/enhancements/providers/redhat/test_openshift_ai.pyindex 1c336fe40..d87f28904 100644--- a/tests/unit/enhancements/providers/redhat/test_openshift_ai.py+++ b/tests/unit/enhancements/providers/redhat/test_openshift_ai.py@@ -108,11 +108,31 @@ def test_the_form_asks_for_two_endpoints_a_token_and_a_ca() -> None:assert fields["api_base"]["field_type"] == "text"assert fields["embedding_api_base"]["field_type"] == "text"assert fields["api_key"]["field_type"] == "password"- assert fields["ssl_verify"]["field_type"] == "text"+ # The form renders it as a switch (labelled by `label`) plus a CA path+ # (helped by `tooltip`), so the tooltip no longer says to type `false`, and+ # blank — no `default_value` — is what "verify" is stored as.+ assert fields["ssl_verify"]["field_type"] == "tls_verify"+ assert fields["ssl_verify"]["label"] == "Verify TLS certificates"+ assert "`false`" not in fields["ssl_verify"]["tooltip"]+ assert fields["ssl_verify"]["required"] is False+ assert fields["ssl_verify"]["default_value"] is Noneassert fields["embedding_max_concurrency"]["field_type"] == "text"assert fields["embedding_max_concurrency"]["required"] is False+def test_the_tooltips_keep_the_guidance_an_operator_needs() -> None:+ """The non-obvious setup and failure hints stay in the form, not only in the docs."""+ fields = {field["key"]: field for field in model_catalog.credential_fields(PROVIDER)}++ # A laptop reaches the cluster through a Route or a port-forward.+ assert "oc port-forward" in fields["api_base"]["tooltip"]+ # A slow CPU-served model needs a lower limit, or kube-rbac-proxy answers 502.+ assert "Lower to 4" in fields["embedding_max_concurrency"]["tooltip"]+ assert "502" in fields["embedding_max_concurrency"]["tooltip"]+ # "Leave blank" lives in the Embeddings section hint, so it is not repeated here.+ assert "blank" not in fields["embedding_api_base"]["tooltip"]++def test_only_the_token_is_encrypted_at_rest() -> None:"""`field_type` drives encryption. A CA path is not a secret; a token is."""assert model_catalog.secret_field_keys(PROVIDER) == {"api_key"}diff --git a/tests/unit/enhancements/providers/watsonx/test_onprem.py b/tests/unit/enhancements/providers/watsonx/test_onprem.pyindex ed1fff743..7072a76d0 100644--- a/tests/unit/enhancements/providers/watsonx/test_onprem.py+++ b/tests/unit/enhancements/providers/watsonx/test_onprem.py@@ -208,6 +208,7 @@ def test_the_settings_form_asks_for_cluster_credentials_not_ibm_cloud_ones() ->"project_id","ssl_verify",}+ assert fields["ssl_verify"]["field_type"] == "tls_verify"assert fields["ssl_verify"]["default_value"] == "true"assert model_catalog.secret_field_keys(PROVIDER) == {"api_key", "zen_api_key"}diff --git a/tests/unit/services/test_model_catalog.py b/tests/unit/services/test_model_catalog.pyindex 996a8df08..d9bfb5510 100644--- a/tests/unit/services/test_model_catalog.py+++ b/tests/unit/services/test_model_catalog.py@@ -85,6 +85,18 @@ def test_an_unknown_provider_still_gets_a_usable_form() -> None:assert model_catalog.missing_required_fields("some-private-gateway", set()) == []+def test_a_tls_verify_field_keeps_its_type_and_is_not_a_secret() -> None:+ """The UI renders `tls_verify` as a switch, so normalizing must not turn it into text."""+ fields = {field["key"]: field for field in model_catalog.credential_fields("rhoai")}+ assert fields["ssl_verify"]["field_type"] == "tls_verify"+ assert "ssl_verify" not in model_catalog.secret_field_keys("rhoai")+++def test_an_unrecognised_field_type_falls_back_to_text() -> None:+ field = model_catalog._normalize_field({"key": "x", "field_type": "colour"})+ assert field["field_type"] == "text"++def test_openai_models_list_is_openai_compatible() -> None:payload = model_catalog.openai_models_list()assert payload["object"] == "list"