updates k8s config validation (#19123)

This commit is contained in:
Jordan Reimer 2023-02-10 10:33:26 -07:00 committed by GitHub
parent 12871c1974
commit a682852afb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 1 deletions

View File

@ -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'])

View File

@ -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'
);
});
});