mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-18 21:21:06 +02:00
* Add helper combineOpenApiAttrs + test * hydrateModel working with upgradeModelSchema * new registerNewModelWithAttrs method for generated models * Add newFields to generated models * copyright * Glimmerize path-help service * update generated-item-list adapter and path-help usage of it * remove unused methods combineAttributes and combineFields * move expandOpenApiProps to ts helper file * fix auth test * fix bug where adding user to second userpass mount saves to first mount * Add mutableId * fix ent test * remove addressed deprecation * Address PR comments * [VAULT-31208] remove deprecation early-static from decorator tests
81 lines
2.4 KiB
JavaScript
81 lines
2.4 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { combineFieldGroups } from 'vault/utils/openapi-to-attrs';
|
|
import { module, test } from 'qunit';
|
|
|
|
module('Unit | Util | combineFieldGroups', function () {
|
|
const NEW_FIELDS = ['one', 'two', 'three'];
|
|
|
|
test('it adds new fields from OpenAPI to fieldGroups except for exclusions', function (assert) {
|
|
assert.expect(3);
|
|
const modelFieldGroups = [
|
|
{ default: ['name', 'awesomePeople'] },
|
|
{
|
|
Options: ['ttl'],
|
|
},
|
|
];
|
|
const excludedFields = ['two'];
|
|
const expectedGroups = [
|
|
{ default: ['name', 'awesomePeople', 'one', 'three'] },
|
|
{
|
|
Options: ['ttl'],
|
|
},
|
|
];
|
|
const newFieldGroups = combineFieldGroups(modelFieldGroups, NEW_FIELDS, excludedFields);
|
|
for (const groupName in modelFieldGroups) {
|
|
assert.deepEqual(
|
|
newFieldGroups[groupName],
|
|
expectedGroups[groupName],
|
|
'it incorporates all new fields except for those excluded'
|
|
);
|
|
}
|
|
});
|
|
test('it adds all new fields from OpenAPI to fieldGroups when excludedFields is empty', function (assert) {
|
|
assert.expect(3);
|
|
const modelFieldGroups = [
|
|
{ default: ['name', 'awesomePeople'] },
|
|
{
|
|
Options: ['ttl'],
|
|
},
|
|
];
|
|
const excludedFields = [];
|
|
const expectedGroups = [
|
|
{ default: ['name', 'awesomePeople', 'one', 'two', 'three'] },
|
|
{
|
|
Options: ['ttl'],
|
|
},
|
|
];
|
|
const nonExcludedFieldGroups = combineFieldGroups(modelFieldGroups, NEW_FIELDS, excludedFields);
|
|
for (const groupName in modelFieldGroups) {
|
|
assert.deepEqual(
|
|
nonExcludedFieldGroups[groupName],
|
|
expectedGroups[groupName],
|
|
'it incorporates all new fields'
|
|
);
|
|
}
|
|
});
|
|
test('it keeps fields the same when there are no brand new fields from OpenAPI', function (assert) {
|
|
assert.expect(3);
|
|
const modelFieldGroups = [
|
|
{ default: ['name', 'awesomePeople', 'two', 'one', 'three'] },
|
|
{
|
|
Options: ['ttl'],
|
|
},
|
|
];
|
|
const excludedFields = [];
|
|
const expectedGroups = [
|
|
{ default: ['name', 'awesomePeople', 'two', 'one', 'three'] },
|
|
{
|
|
Options: ['ttl'],
|
|
},
|
|
];
|
|
const fieldGroups = combineFieldGroups(modelFieldGroups, NEW_FIELDS, excludedFields);
|
|
for (const groupName in modelFieldGroups) {
|
|
assert.deepEqual(fieldGroups[groupName], expectedGroups[groupName], 'it incorporates all new fields');
|
|
}
|
|
});
|
|
});
|