mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-21 22:51:09 +02:00
UI: adding skip import rotation field when creating static roles (#29633)
* adding skip import rotation field to ui * changing labels and subtext * removing readonly, user input on edit would not affect value * changelog * fix test * fix test2
This commit is contained in:
parent
09e7c2e8fa
commit
dd8a0d57a8
3
changelog/29633.txt
Normal file
3
changelog/29633.txt
Normal file
@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
ui/database: Added input field for setting 'skip_import_rotation' when creating a static role
|
||||
```
|
@ -54,6 +54,12 @@ export default Model.extend({
|
||||
'Specifies the amount of time Vault should wait before rotating the password. The minimum is 5 seconds. Default is 24 hours.',
|
||||
helperTextEnabled: 'Vault will rotate password after',
|
||||
}),
|
||||
skip_import_rotation: attr({
|
||||
label: 'Skip initial rotation',
|
||||
editType: 'boolean',
|
||||
defaultValue: false,
|
||||
subText: 'When unchecked, Vault automatically rotates the password upon creation',
|
||||
}),
|
||||
creation_statements: attr('array', {
|
||||
editType: 'stringArray',
|
||||
}),
|
||||
@ -110,6 +116,7 @@ export default Model.extend({
|
||||
'max_ttl',
|
||||
'username',
|
||||
'rotation_period',
|
||||
'skip_import_rotation',
|
||||
'creation_statements',
|
||||
'creation_statement', // for editType: JSON
|
||||
'revocation_statements',
|
||||
|
@ -188,7 +188,7 @@ export const AVAILABLE_PLUGIN_TYPES = [
|
||||
];
|
||||
|
||||
export const ROLE_FIELDS = {
|
||||
static: ['username', 'rotation_period'],
|
||||
static: ['username', 'rotation_period', 'skip_import_rotation'],
|
||||
dynamic: ['default_ttl', 'max_ttl'],
|
||||
};
|
||||
|
||||
|
@ -22,6 +22,7 @@ module('Integration | Component | database-role-edit', function (hooks) {
|
||||
database: ['my-mongodb-database'],
|
||||
backend: 'database',
|
||||
username: 'staticTestUser',
|
||||
skip_import_rotation: false,
|
||||
type: 'static',
|
||||
name: 'my-static-role',
|
||||
id: 'my-static-role',
|
||||
@ -58,6 +59,31 @@ module('Integration | Component | database-role-edit', function (hooks) {
|
||||
await click('[data-test-secret-save]');
|
||||
});
|
||||
|
||||
test('it should successfully create user with skip import rotation', async function (assert) {
|
||||
this.server.post('/sys/capabilities-self', capabilitiesStub('database/static-creds/my-role', ['create']));
|
||||
this.server.post(`/database/static-roles/my-static-role`, (schema, req) => {
|
||||
assert.true(true, 'request made to create static role');
|
||||
assert.propEqual(
|
||||
JSON.parse(req.requestBody),
|
||||
{
|
||||
path: 'static-roles',
|
||||
username: 'staticTestUser',
|
||||
rotation_period: '172800s', // 2 days in seconds
|
||||
skip_import_rotation: true,
|
||||
},
|
||||
'it creates a static role with correct payload'
|
||||
);
|
||||
});
|
||||
|
||||
await render(hbs`<DatabaseRoleEdit @model={{this.modelStatic}} @mode="create"/>`);
|
||||
await fillIn('[data-test-ttl-value="Rotation period"]', '2');
|
||||
await click('[data-test-input="skip_import_rotation"]');
|
||||
await click('[data-test-secret-save]');
|
||||
|
||||
await render(hbs`<DatabaseRoleEdit @model={{this.modelStatic}} @mode="show"/>`);
|
||||
assert.dom('[data-test-value-div="Skip initial rotation"]').containsText('Yes');
|
||||
});
|
||||
|
||||
test('it should show Get credentials button when a user has the correct policy', async function (assert) {
|
||||
this.server.post('/sys/capabilities-self', capabilitiesStub('database/static-creds/my-role', ['read']));
|
||||
await render(hbs`<DatabaseRoleEdit @model={{this.modelStatic}} @mode="show"/>`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user