mirror of
https://github.com/hashicorp/vault.git
synced 2026-02-18 18:38:08 -05:00
* updates kubernetes_ca_cert auth config field to file editType * adds changelog * renames changelog file * updates auth configure section route unit tests Co-authored-by: Jordan Reimer <zofskeez@gmail.com>
This commit is contained in:
parent
659833d85a
commit
a9b527583d
3 changed files with 59 additions and 1 deletions
3
changelog/_11643.txt
Normal file
3
changelog/_11643.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
```release-note:bug
|
||||
ui: Reverts Kubernetes CA Certificate auth method configuration form field type to file selector
|
||||
```
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue