updates k8s config validation (#19123)
This commit is contained in:
parent
12871c1974
commit
a682852afb
|
@ -3,7 +3,12 @@ import { withFormFields } from 'vault/decorators/model-form-fields';
|
|||
import { withModelValidations } from 'vault/decorators/model-validations';
|
||||
|
||||
const validations = {
|
||||
kubernetesHost: [{ type: 'presence', message: 'Kubernetes host is required' }],
|
||||
kubernetesHost: [
|
||||
{
|
||||
validator: (model) => (model.disableLocalCaJwt && !model.kubernetesHost ? false : true),
|
||||
message: 'Kubernetes host is required',
|
||||
},
|
||||
],
|
||||
};
|
||||
@withModelValidations(validations)
|
||||
@withFormFields(['kubernetesHost', 'serviceAccountJwt', 'kubernetesCaCert'])
|
||||
|
|
|
@ -216,4 +216,29 @@ module('Integration | Component | kubernetes | Page::Configure', function (hooks
|
|||
.hasText('Kubernetes host is required', 'Error renders for required field');
|
||||
assert.dom('[data-test-alert] p').hasText('There is an error with this form.', 'Alert renders');
|
||||
});
|
||||
|
||||
test('it should save inferred config', async function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
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');
|
||||
return new Response(204, {});
|
||||
});
|
||||
|
||||
const stub = sinon.stub(this.owner.lookup('service:router'), 'transitionTo');
|
||||
|
||||
await render(hbs`<Page::Configure @model={{this.newModel}} @breadcrumbs={{this.breadcrumbs}} />`, {
|
||||
owner: this.engine,
|
||||
});
|
||||
|
||||
await click('[data-test-config] button');
|
||||
await click('[data-test-config-save]');
|
||||
|
||||
assert.ok(
|
||||
stub.calledWith('vault.cluster.secrets.backend.kubernetes.configuration'),
|
||||
'Transitions to configuration route on save success'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue