use of io.fabric8.kubernetes.api.model.apiextensions.v1.WebhookClientConfig in project stackgres by ongres.
the class WebhookConfiguratorImplTest method configureWebhook_shouldNotFail.
@Test
void configureWebhook_shouldNotFail() {
var definition = crdFinder.scanDefinitions().get(0);
final String certificate = StringUtil.generateRandom();
ArgumentCaptor<CustomResourceDefinition> crdCaptor = ArgumentCaptor.forClass(CustomResourceDefinition.class);
when(crdWriter.update(crdCaptor.capture())).thenReturn(definition);
webhookConfigurator.configureWebhook(definition.getMetadata().getName(), certificate);
CustomResourceDefinition crd = crdCaptor.getValue();
final CustomResourceDefinitionSpec spec = crd.getSpec();
final CustomResourceConversion conversion = spec.getConversion();
final WebhookClientConfig clientConfig = conversion.getWebhook().getClientConfig();
final ServiceReference service = clientConfig.getService();
assertEquals("Webhook", conversion.getStrategy());
assertEquals(OPERATOR_NAME, service.getName());
assertEquals(OPERATOR_NAMESPACE, service.getNamespace());
assertEquals("/stackgres/conversion/" + definition.getSpec().getNames().getSingular(), service.getPath());
assertEquals(certificate, clientConfig.getCaBundle());
assertFalse(spec.getPreserveUnknownFields());
}
Aggregations