UI/fix db role ttl display (#14224)

* Format duration for display if editType ttl

* Update ttl fields to default_ttl

* Fix db tests

* Add changelog
This commit is contained in:
Chelsea Shaw 2022-02-23 10:00:20 -06:00 committed by GitHub
parent 2551a3e8ce
commit 96f5f3cf50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 13 deletions

3
changelog/14224.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
ui: Fix default TTL display and set on database role
```

View File

@ -26,7 +26,7 @@ export default Model.extend({
noDefault: true,
possibleValues: ['static', 'dynamic'],
}),
ttl: attr({
default_ttl: attr({
editType: 'ttl',
defaultValue: '1h',
label: 'Generated credentialss Time-to-Live (TTL)',
@ -98,7 +98,7 @@ export default Model.extend({
roleSettingAttrs: computed(function () {
// logic for which get displayed is on DatabaseRoleSettingForm
let allRoleSettingFields = [
'ttl',
'default_ttl',
'max_ttl',
'username',
'rotation_period',

View File

@ -63,6 +63,14 @@
@label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}}
@value={{stringify (get @model attr.name)}}
/>
{{else if (eq attr.options.editType "ttl")}}
<InfoTableRow
@alwaysRender={{true}}
@defaultShown={{defaultDisplay}}
@label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}}
@value={{format-duration (get @model attr.name)}}
@isLink={{eq attr.name "database"}}
/>
{{else}}
<InfoTableRow
@alwaysRender={{true}}

View File

@ -175,7 +175,7 @@ export const AVAILABLE_PLUGIN_TYPES = [
export const ROLE_FIELDS = {
static: ['username', 'rotation_period'],
dynamic: ['ttl', 'max_ttl'],
dynamic: ['default_ttl', 'max_ttl'],
};
export const STATEMENT_FIELDS = {

View File

@ -11,7 +11,7 @@ const testCases = [
staticRoleFields: ['name', 'username', 'rotation_period', 'rotation_statements'],
dynamicRoleFields: [
'name',
'ttl',
'default_ttl',
'max_ttl',
'creation_statements',
'revocation_statements',
@ -22,49 +22,49 @@ const testCases = [
{
pluginType: 'elasticsearch-database-plugin',
staticRoleFields: ['username', 'rotation_period'],
dynamicRoleFields: ['creation_statement', 'ttl', 'max_ttl'],
dynamicRoleFields: ['creation_statement', 'default_ttl', 'max_ttl'],
},
{
pluginType: 'mongodb-database-plugin',
staticRoleFields: ['username', 'rotation_period'],
dynamicRoleFields: ['creation_statement', 'revocation_statement', 'ttl', 'max_ttl'],
dynamicRoleFields: ['creation_statement', 'revocation_statement', 'default_ttl', 'max_ttl'],
statementsHidden: true,
},
{
pluginType: 'mssql-database-plugin',
staticRoleFields: ['username', 'rotation_period'],
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'ttl', 'max_ttl'],
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'default_ttl', 'max_ttl'],
},
{
pluginType: 'mysql-database-plugin',
staticRoleFields: ['username', 'rotation_period'],
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'ttl', 'max_ttl'],
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'default_ttl', 'max_ttl'],
},
{
pluginType: 'mysql-aurora-database-plugin',
staticRoleFields: ['username', 'rotation_period'],
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'ttl', 'max_ttl'],
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'default_ttl', 'max_ttl'],
},
{
pluginType: 'mysql-rds-database-plugin',
staticRoleFields: ['username', 'rotation_period'],
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'ttl', 'max_ttl'],
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'default_ttl', 'max_ttl'],
},
{
pluginType: 'mysql-legacy-database-plugin',
staticRoleFields: ['username', 'rotation_period'],
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'ttl', 'max_ttl'],
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'default_ttl', 'max_ttl'],
},
{
pluginType: 'vault-plugin-database-oracle',
staticRoleFields: ['username', 'rotation_period'],
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'ttl', 'max_ttl'],
dynamicRoleFields: ['creation_statements', 'revocation_statements', 'default_ttl', 'max_ttl'],
},
];
// used to calculate checks that fields do NOT show up
const ALL_ATTRS = [
{ name: 'ttl', type: 'string', options: {} },
{ name: 'default_ttl', type: 'string', options: {} },
{ name: 'max_ttl', type: 'string', options: {} },
{ name: 'username', type: 'string', options: {} },
{ name: 'rotation_period', type: 'string', options: {} },