diff --git a/changelog/_11643.txt b/changelog/_11643.txt new file mode 100644 index 0000000000..eb1b98e9ed --- /dev/null +++ b/changelog/_11643.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Reverts Kubernetes CA Certificate auth method configuration form field type to file selector +``` \ No newline at end of file diff --git a/ui/app/routes/vault/cluster/settings/auth/configure/section.ts b/ui/app/routes/vault/cluster/settings/auth/configure/section.ts index 59c2192086..fa92d6370f 100644 --- a/ui/app/routes/vault/cluster/settings/auth/configure/section.ts +++ b/ui/app/routes/vault/cluster/settings/auth/configure/section.ts @@ -132,10 +132,17 @@ export default class ClusterSettingsAuthConfigureRoute extends Route { } } const form = new OpenApiForm(this.schemaForType(methodType, section), formData, formOptions); + const defaultGroup = form.formFieldGroups[0]?.['default'] || []; + // to improve UX, set kubernetes_ca_cert editType to file + if (methodType === 'kubernetes') { + const kubernetesCaCertField = defaultGroup.find((field) => field.name === 'kubernetes_ca_cert'); + if (kubernetesCaCertField) { + kubernetesCaCertField.options.editType = 'file'; + } + } // for jwt and oidc types, the jwks_pairs field is not deprecated but we do not render it in the UI // remove the field from the group before rendering the form if (['jwt', 'oidc'].includes(methodType)) { - const defaultGroup = form.formFieldGroups[0]?.['default'] || []; const index = defaultGroup.findIndex((field) => field.name === 'jwks_pairs'); if (index !== undefined && index >= 0) { defaultGroup.splice(index, 1); diff --git a/ui/tests/unit/routes/vault/cluster/settings/auth/configure/section-test.js b/ui/tests/unit/routes/vault/cluster/settings/auth/configure/section-test.js new file mode 100644 index 0000000000..404c660185 --- /dev/null +++ b/ui/tests/unit/routes/vault/cluster/settings/auth/configure/section-test.js @@ -0,0 +1,48 @@ +/** + * Copyright IBM Corp. 2016, 2025 + * SPDX-License-Identifier: BUSL-1.1 + */ + +import { module, test } from 'qunit'; +import { setupTest } from 'vault/tests/helpers'; +import sinon from 'sinon'; + +module('Unit | Route | vault/cluster/settings/auth/configure/section', function (hooks) { + setupTest(hooks); + + hooks.beforeEach(function () { + const { auth } = this.owner.lookup('service:api'); + sinon.stub(auth, 'kubernetesReadAuthConfiguration').resolves({}); + sinon.stub(auth, 'jwtReadConfiguration').resolves({}); + + this.route = this.owner.lookup('route:vault/cluster/settings/auth/configure/section'); + this.modelForStub = sinon.stub(this.route, 'modelFor'); + + this.testModelForConfiguration = async (methodType, fieldKey) => { + this.modelForStub.returns({ method: { methodType, path: `${methodType}-test` } }); + const { form } = await this.route.modelForConfiguration('configuration'); + const defaultGroup = form.formFieldGroups[0]['default']; + const field = defaultGroup.find((field) => field.name === fieldKey); + return { form, defaultGroup, field }; + }; + }); + + test('it should remove jwks_pairs form field for jwt type', async function (assert) { + const { field } = await this.testModelForConfiguration('jwt', 'jwks_pairs'); + assert.strictEqual(field, undefined, 'jwks_pairs field is removed for jwt type'); + }); + + test('it should remove jwks_pairs form field for oidc type', async function (assert) { + const { field } = await this.testModelForConfiguration('oidc', 'jwks_pairs'); + assert.strictEqual(field, undefined, 'jwks_pairs field is removed for oidc type'); + }); + + test('it should update kubernetes_ca_cert form field editType to file', async function (assert) { + const { field } = await this.testModelForConfiguration('kubernetes', 'kubernetes_ca_cert'); + assert.strictEqual( + field.options.editType, + 'file', + 'editType is set to file for kubernetes_ca_cert field' + ); + }); +});