fixes issue saving edited k8s role (#19133)
This commit is contained in:
parent
4af59fd6cd
commit
caa06f267a
|
@ -27,7 +27,10 @@ export default class CreateAndEditRolePageComponent extends Component {
|
|||
|
||||
constructor() {
|
||||
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
|
||||
const { extraAnnotations, extraLabels } = this.args.model;
|
||||
if (extraAnnotations || extraLabels) {
|
||||
|
@ -127,7 +130,7 @@ export default class CreateAndEditRolePageComponent extends Component {
|
|||
*save() {
|
||||
try {
|
||||
// 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) {
|
||||
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]')
|
||||
.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]');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue