EndpointCertificateSecretsValidator extends Validator { @Override public void validate(VespaModel model, DeployState deployState) { if (deployState.endpointCertificateSecrets().isPresent() && deployState.endpointCertificateSecrets().get() == EndpointCertificateSecrets.MISSING) { throw new CertificateNotReadyException("TLS enabled, but could not yet retrieve certificate for application " + deployState.getProperties().applicationId().serializedForm()); } }  @Override void validate(VespaModel model, DeployState deployState);  }
@Test public void missing_certificate_fails_validation() throws Exception { DeployState deployState = deployState(servicesXml(), deploymentXml(), Optional.of(EndpointCertificateSecrets.MISSING)); VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState); exceptionRule.expect(CertificateNotReadyException.class); exceptionRule.expectMessage("TLS enabled, but could not yet retrieve certificate for application default:default:default"); new EndpointCertificateSecretsValidator().validate(model, deployState); }
@Test public void validation_succeeds_with_certificate() throws Exception { DeployState deployState = deployState(servicesXml(), deploymentXml(), Optional.of(new EndpointCertificateSecrets("cert", "key"))); VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState); new EndpointCertificateSecretsValidator().validate(model, deployState); }
@Test public void validation_succeeds_without_certificate() throws Exception { DeployState deployState = deployState(servicesXml(), deploymentXml(), Optional.empty()); VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState); new EndpointCertificateSecretsValidator().validate(model, deployState); }