SecretStoreValidator extends Validator { @Override public void validate(VespaModel model, DeployState deployState) { if (! deployState.isHosted()) return; if (model.getAdmin().getApplicationType() != ApplicationType.DEFAULT) return; for (ContainerCluster cluster : model.getContainerClusters().values()) { if (cluster.getSecretStore().isPresent() && ! hasIdentityProvider(cluster)) { throw new IllegalArgumentException(String.format( "Container cluster '%s' uses a secret store, so an Athenz domain and an Athenz service" + " must be declared in deployment.xml.", cluster.getName())); } } }  @Override void validate(VespaModel model, DeployState deployState);  }
@Test public void app_with_athenz_in_deployment_passes_validation() throws Exception { DeployState deployState = deployState(servicesXml(), deploymentXml(true)); VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState); new SecretStoreValidator().validate(model, deployState); }
@Test public void app_without_athenz_in_deployment_fails_validation() throws Exception { exceptionRule.expect(IllegalArgumentException.class); exceptionRule.expectMessage( "Container cluster 'default' uses a secret store, so an Athenz domain and" + " an Athenz service must be declared in deployment.xml."); DeployState deployState = deployState(servicesXml(), deploymentXml(false)); VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState); new SecretStoreValidator().validate(model, deployState); }
@Test public void app_without_secret_store_passes_validation_without_athenz_in_deployment() throws Exception { String servicesXml = joinLines("<services version='1.0'>", " <container id='default' version='1.0' />", "</services>"); DeployState deployState = deployState(servicesXml, deploymentXml(false)); VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState); new SecretStoreValidator().validate(model, deployState); }