Kubernetes config payload fix (#19184)
* unsets kubernetes manual config properties when saving local cluster option * fixes test
This commit is contained in:
parent
fc13efc80e
commit
c3d4b2ff7b
|
@ -32,7 +32,7 @@ export default class KubernetesRoleAdapter extends NamedPathAdapter {
|
|||
}
|
||||
generateCredentials(backend, data) {
|
||||
const generateCredentialsUrl = `${this.buildURL()}/${encodePath(backend)}/creds/${data.role}`;
|
||||
|
||||
delete data.role;
|
||||
return this.ajax(generateCredentialsUrl, 'POST', { data }).then((response) => {
|
||||
const { lease_id, lease_duration, data } = response;
|
||||
|
||||
|
|
|
@ -7,6 +7,12 @@ export default class KubernetesConfigSerializer extends ApplicationSerializer {
|
|||
const json = super.serialize(...arguments);
|
||||
// remove backend value from payload
|
||||
delete json.backend;
|
||||
// ensure that values from a previous manual configuration are unset
|
||||
if (json.disable_local_ca_jwt === false) {
|
||||
json.kubernetes_ca_cert = null;
|
||||
json.kubernetes_host = null;
|
||||
json.service_account_jwt = null;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,12 @@ module('Integration | Component | kubernetes | Page::Configure', function (hooks
|
|||
{ label: 'kubernetes', route: 'overview' },
|
||||
{ label: 'configure' },
|
||||
];
|
||||
this.expectedInferred = {
|
||||
disable_local_ca_jwt: false,
|
||||
kubernetes_ca_cert: null,
|
||||
kubernetes_host: null,
|
||||
service_account_jwt: null,
|
||||
};
|
||||
});
|
||||
|
||||
test('it should display proper options when toggling radio cards', async function (assert) {
|
||||
|
@ -223,7 +229,7 @@ module('Integration | Component | kubernetes | Page::Configure', function (hooks
|
|||
this.server.get('/:path/check', () => new Response(204, {}));
|
||||
this.server.post('/:path/config', (schema, req) => {
|
||||
const json = JSON.parse(req.requestBody);
|
||||
assert.deepEqual(json, { disable_local_ca_jwt: false }, 'Values are passed to create endpoint');
|
||||
assert.deepEqual(json, this.expectedInferred, 'Values are passed to create endpoint');
|
||||
return new Response(204, {});
|
||||
});
|
||||
|
||||
|
@ -241,4 +247,28 @@ module('Integration | Component | kubernetes | Page::Configure', function (hooks
|
|||
'Transitions to configuration route on save success'
|
||||
);
|
||||
});
|
||||
|
||||
test('it should unset manual config values when saving local cluster option', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
this.server.get('/:path/check', () => new Response(204, {}));
|
||||
this.server.post('/:path/config', (schema, req) => {
|
||||
const json = JSON.parse(req.requestBody);
|
||||
assert.deepEqual(json, this.expectedInferred, 'Manual config values are unset in server payload');
|
||||
return new Response(204, {});
|
||||
});
|
||||
|
||||
await render(hbs`<Page::Configure @model={{this.newModel}} @breadcrumbs={{this.breadcrumbs}} />`, {
|
||||
owner: this.engine,
|
||||
});
|
||||
|
||||
await click('[data-test-radio-card="manual"]');
|
||||
await fillIn('[data-test-input="kubernetesHost"]', this.existingConfig.kubernetes_host);
|
||||
await fillIn('[data-test-input="serviceAccountJwt"]', this.existingConfig.service_account_jwt);
|
||||
await fillIn('[data-test-input="kubernetesCaCert"]', this.existingConfig.kubernetes_ca_cert);
|
||||
|
||||
await click('[data-test-radio-card="local"]');
|
||||
await click('[data-test-config] button');
|
||||
await click('[data-test-config-save]');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue