mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-11 17:17:01 +02:00
* Update browserslist * Add browserslistrc * ember-cli-update --to 3.26, fix conflicts * Run codemodes that start with ember-* * More codemods - before cp* * More codemods (curly data-test-*) * WIP ember-basic-dropdown template errors * updates ember-basic-dropdown and related deps to fix build issues * updates basic dropdown instances to new version API * updates more deps -- ember-template-lint is working again * runs no-implicit-this codemod * creates and runs no-quoteless-attributes codemod * runs angle brackets codemod * updates lint:hbs globs to only touch hbs files * removes yield only templates * creates and runs deprecated args transform * supresses lint error for invokeAction on LinkTo component * resolves remaining ambiguous path lint errors * resolves simple-unless lint errors * adds warnings for deprecated tagName arg on LinkTo components * adds warnings for remaining curly component invocation * updates global template lint rules * resolves remaining template lint errors * disables some ember specfic lint rules that target pre octane patterns * js lint fix run * resolves remaining js lint errors * fixes test run * adds npm-run-all dep * fixes test attribute issues * fixes console acceptance tests * fixes tests * adds yield only wizard/tutorial-active template * fixes more tests * attempts to fix more flaky tests * removes commented out settled in transit test * updates deprecations workflow and adds initializer to filter by version * updates flaky policies acl old test * updates to flaky transit test * bumps ember deps down to LTS version * runs linters after main merge * fixes client count tests after bad merge conflict fixes * fixes client count history test * more updates to lint config * another round of hbs lint fixes after extending stylistic rule * updates lint-staged commands * removes indent eslint rule since it seems to break things * fixes bad attribute in transform-edit-form template * test fixes * fixes enterprise tests * adds changelog * removes deprecated ember-concurrency-test-waiters dep and adds @ember/test-waiters * flaky test fix Co-authored-by: hashishaw <cshaw@hashicorp.com>
161 lines
5.7 KiB
JavaScript
161 lines
5.7 KiB
JavaScript
import EmberObject from '@ember/object';
|
|
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { render } from '@ember/test-helpers';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
const testCases = [
|
|
{
|
|
// default case should show all possible fields for each type
|
|
pluginType: '',
|
|
staticRoleFields: ['name', 'username', 'rotation_period', 'rotation_statements'],
|
|
dynamicRoleFields: [
|
|
'name',
|
|
'ttl',
|
|
'max_ttl',
|
|
'creation_statements',
|
|
'revocation_statements',
|
|
'rollback_statements',
|
|
'renew_statements',
|
|
],
|
|
},
|
|
{
|
|
pluginType: 'elasticsearch-database-plugin',
|
|
staticRoleFields: ['username', 'rotation_period'],
|
|
dynamicRoleFields: ['creation_statement', 'ttl', 'max_ttl'],
|
|
},
|
|
{
|
|
pluginType: 'mongodb-database-plugin',
|
|
staticRoleFields: ['username', 'rotation_period'],
|
|
dynamicRoleFields: ['creation_statement', 'revocation_statement', 'ttl', 'max_ttl'],
|
|
statementsHidden: true,
|
|
},
|
|
{
|
|
pluginType: 'mssql-database-plugin',
|
|
staticRoleFields: ['username', 'rotation_period'],
|
|
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'ttl', 'max_ttl'],
|
|
},
|
|
{
|
|
pluginType: 'mysql-database-plugin',
|
|
staticRoleFields: ['username', 'rotation_period'],
|
|
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'ttl', 'max_ttl'],
|
|
},
|
|
{
|
|
pluginType: 'mysql-aurora-database-plugin',
|
|
staticRoleFields: ['username', 'rotation_period'],
|
|
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'ttl', 'max_ttl'],
|
|
},
|
|
{
|
|
pluginType: 'mysql-rds-database-plugin',
|
|
staticRoleFields: ['username', 'rotation_period'],
|
|
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'ttl', 'max_ttl'],
|
|
},
|
|
{
|
|
pluginType: 'mysql-legacy-database-plugin',
|
|
staticRoleFields: ['username', 'rotation_period'],
|
|
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'ttl', 'max_ttl'],
|
|
},
|
|
{
|
|
pluginType: 'vault-plugin-database-oracle',
|
|
staticRoleFields: ['username', 'rotation_period'],
|
|
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'ttl', 'max_ttl'],
|
|
},
|
|
];
|
|
|
|
// used to calculate checks that fields do NOT show up
|
|
const ALL_ATTRS = [
|
|
{ name: 'ttl', type: 'string', options: {} },
|
|
{ name: 'max_ttl', type: 'string', options: {} },
|
|
{ name: 'username', type: 'string', options: {} },
|
|
{ name: 'rotation_period', type: 'string', options: {} },
|
|
{ name: 'creation_statements', type: 'string', options: {} },
|
|
{ name: 'creation_statement', type: 'string', options: {} },
|
|
{ name: 'revocation_statements', type: 'string', options: {} },
|
|
{ name: 'revocation_statement', type: 'string', options: {} },
|
|
{ name: 'rotation_statements', type: 'string', options: {} },
|
|
{ name: 'rollback_statements', type: 'string', options: {} },
|
|
{ name: 'renew_statements', type: 'string', options: {} },
|
|
];
|
|
const getFields = (nameArray) => {
|
|
const show = ALL_ATTRS.filter((attr) => nameArray.indexOf(attr.name) >= 0);
|
|
const hide = ALL_ATTRS.filter((attr) => nameArray.indexOf(attr.name) < 0);
|
|
return { show, hide };
|
|
};
|
|
|
|
module('Integration | Component | database-role-setting-form', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
hooks.beforeEach(function () {
|
|
this.set(
|
|
'model',
|
|
EmberObject.create({
|
|
// attrs is not its own set value b/c ember hates arrays as args
|
|
attrs: ALL_ATTRS,
|
|
})
|
|
);
|
|
});
|
|
|
|
test('it shows empty states when no roleType passed in', async function (assert) {
|
|
await render(hbs`<DatabaseRoleSettingForm @attrs={{model.attrs}} @model={{model}}/>`);
|
|
assert.dom('[data-test-component="empty-state"]').exists({ count: 2 }, 'Two empty states exist');
|
|
});
|
|
|
|
test('it shows appropriate fields based on roleType and db plugin', async function (assert) {
|
|
this.set('roleType', 'static');
|
|
this.set('dbType', '');
|
|
await render(hbs`
|
|
<DatabaseRoleSettingForm
|
|
@attrs={{model.attrs}}
|
|
@model={{model}}
|
|
@roleType={{roleType}}
|
|
@dbType={{dbType}}
|
|
/>
|
|
`);
|
|
assert.dom('[data-test-component="empty-state"]').doesNotExist('Does not show empty states');
|
|
for (let testCase of testCases) {
|
|
let staticFields = getFields(testCase.staticRoleFields);
|
|
let dynamicFields = getFields(testCase.dynamicRoleFields);
|
|
this.set('dbType', testCase.pluginType);
|
|
this.set('roleType', 'static');
|
|
staticFields.show.forEach((attr) => {
|
|
assert
|
|
.dom(`[data-test-input="${attr.name}"]`)
|
|
.exists(
|
|
`${attr.name} attribute exists on static role for ${testCase.pluginType || 'default'} db type`
|
|
);
|
|
});
|
|
staticFields.hide.forEach((attr) => {
|
|
assert
|
|
.dom(`[data-test-input="${attr.name}"]`)
|
|
.doesNotExist(
|
|
`${attr.name} attribute does not exist on static role for ${
|
|
testCase.pluginType || 'default'
|
|
} db type`
|
|
);
|
|
});
|
|
if (testCase.statementsHidden) {
|
|
assert
|
|
.dom('[data-test-statements-section]')
|
|
.doesNotExist(`Statements section is hidden for static ${testCase.pluginType} role`);
|
|
}
|
|
this.set('roleType', 'dynamic');
|
|
dynamicFields.show.forEach((attr) => {
|
|
assert
|
|
.dom(`[data-test-input="${attr.name}"]`)
|
|
.exists(
|
|
`${attr.name} attribute exists on dynamic role for ${testCase.pluginType || 'default'} db type`
|
|
);
|
|
});
|
|
dynamicFields.hide.forEach((attr) => {
|
|
assert
|
|
.dom(`[data-test-input="${attr.name}"]`)
|
|
.doesNotExist(
|
|
`${attr.name} attribute does not exist on dynamic role for ${
|
|
testCase.pluginType || 'default'
|
|
} db type`
|
|
);
|
|
});
|
|
}
|
|
});
|
|
});
|