mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 19:47:54 +00:00
fixes issue saving edited k8s role (#19133)
This commit is contained in:
@@ -27,7 +27,10 @@ export default class CreateAndEditRolePageComponent extends Component {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(...arguments);
|
super(...arguments);
|
||||||
this.initRoleRules();
|
// generated role rules are only rendered for the full object chain option
|
||||||
|
if (this.args.model.generationPreference === 'full') {
|
||||||
|
this.initRoleRules();
|
||||||
|
}
|
||||||
// if editing and annotations or labels exist expand the section
|
// if editing and annotations or labels exist expand the section
|
||||||
const { extraAnnotations, extraLabels } = this.args.model;
|
const { extraAnnotations, extraLabels } = this.args.model;
|
||||||
if (extraAnnotations || extraLabels) {
|
if (extraAnnotations || extraLabels) {
|
||||||
@@ -127,7 +130,7 @@ export default class CreateAndEditRolePageComponent extends Component {
|
|||||||
*save() {
|
*save() {
|
||||||
try {
|
try {
|
||||||
// set generatedRoleRoles to value of selected template
|
// set generatedRoleRoles to value of selected template
|
||||||
const selectedTemplate = this.roleRulesTemplates.findBy('id', this.selectedTemplateId);
|
const selectedTemplate = this.roleRulesTemplates?.findBy('id', this.selectedTemplateId);
|
||||||
if (selectedTemplate) {
|
if (selectedTemplate) {
|
||||||
this.args.model.generatedRoleRules = selectedTemplate.rules;
|
this.args.model.generatedRoleRules = selectedTemplate.rules;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -321,4 +321,30 @@ module('Integration | Component | kubernetes | Page::Role::CreateAndEdit', funct
|
|||||||
.dom('[data-test-invalid-form-alert] [data-test-inline-error-message]')
|
.dom('[data-test-invalid-form-alert] [data-test-inline-error-message]')
|
||||||
.hasText('There is an error with this form.');
|
.hasText('There is an error with this form.');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('it should save edited role with correct properties', async function (assert) {
|
||||||
|
assert.expect(1);
|
||||||
|
|
||||||
|
this.role = this.getRole();
|
||||||
|
|
||||||
|
this.server.post('/kubernetes-test/roles/:name', (schema, req) => {
|
||||||
|
const data = JSON.parse(req.requestBody);
|
||||||
|
const expected = {
|
||||||
|
name: 'role-0',
|
||||||
|
service_account_name: 'demo',
|
||||||
|
kubernetes_role_type: 'Role',
|
||||||
|
allowed_kubernetes_namespaces: '*',
|
||||||
|
token_max_ttl: 86400,
|
||||||
|
token_default_ttl: 600,
|
||||||
|
};
|
||||||
|
assert.deepEqual(expected, data, 'POST request made to save role with correct properties');
|
||||||
|
});
|
||||||
|
|
||||||
|
await render(hbs`<Page::Role::CreateAndEdit @model={{this.role}} @breadcrumbs={{this.breadcrumbs}} />`, {
|
||||||
|
owner: this.engine,
|
||||||
|
});
|
||||||
|
|
||||||
|
await fillIn('[data-test-input="serviceAccountName"]', 'demo');
|
||||||
|
await click('[data-test-save]');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user