use of io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder in project ingress-access-operator by neo9.
the class ServiceExposerReconcilerTest method shouldNotEnableTlsByDefault.
@Test
public void shouldNotEnableTlsByDefault() {
// given
Ingress ingress = new IngressBuilder().withNewMetadata().withNamespace("mynamespace").withName("myname").addToAnnotations(EXPOSE_INGRESS_HOSTNAME, "hello.{{domain}}").endMetadata().build();
// when
boolean shouldEnableTls = serviceExposerReconciler.shouldEnableTls(ingress.getMetadata().getAnnotations());
// then
assertThat(shouldEnableTls).isFalse();
}
use of io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder in project ingress-access-operator by neo9.
the class VisitorGroupServiceExposerReconcilerTest method shouldWellComputeWhitelistForTwoGroup.
@Test
public void shouldWellComputeWhitelistForTwoGroup() {
// given
Ingress ingress = new IngressBuilder().withNewMetadata().withName("test").withAnnotations(Map.of(MutationAnnotations.MUTABLE_INGRESS_VISITOR_GROUP_KEY, "vg1,vg2")).endMetadata().build();
// when
String cidrListAsString = visitorGroupIngressReconciler.getCidrListAsString(ingress);
// then
assertThat(cidrListAsString).isEqualTo(visitorGroup1Ips + "," + visitorGroup2Ips);
}
use of io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder in project ingress-access-operator by neo9.
the class VisitorGroupServiceExposerReconcilerTest method shouldPanicOnUnknownVisitorGroup.
@Test
public void shouldPanicOnUnknownVisitorGroup() {
// given
Ingress ingress = new IngressBuilder().withNewMetadata().withName("test").withAnnotations(Map.of(MutationAnnotations.MUTABLE_INGRESS_VISITOR_GROUP_KEY, "vgUndefined")).endMetadata().build();
// when / then
assertThatThrownBy(() -> visitorGroupIngressReconciler.getCidrListAsString(ingress)).isInstanceOf(VisitorGroupNotFoundException.class);
}
use of io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder in project dekorate by dekorateio.
the class AddIngressDecorator method visit.
public void visit(KubernetesListBuilder list) {
Optional<Port> p = getHttpPort(config);
if (!p.isPresent() || !config.isExpose()) {
return;
}
if (contains(list, ANY, "Ingress", config.getName())) {
return;
}
Port port = p.get();
list.addToItems(new IngressBuilder().withNewMetadata().withName(config.getName()).withLabels(allLabels).endMetadata().withNewSpec().addNewRule().withHost(config.getHost()).withNewHttp().addNewPath().withNewPathType("Prefix").withPath(Strings.isNotNullOrEmpty(port.getPath()) ? port.getPath() : "/").withNewBackend().withNewService().withName(config.getName()).withNewPort().withName(port.getName()).withNumber(Strings.isNullOrEmpty(port.getName()) && port.getHostPort() != null && port.getHostPort() > 0 ? port.getHostPort() : null).endPort().endService().endBackend().endPath().endHttp().endRule().endSpec().build());
}
use of io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder in project jkube by eclipse.
the class ApplyServiceTest method testApplyToMultipleNamespaceNoNamespaceConfigured.
@Test
public void testApplyToMultipleNamespaceNoNamespaceConfigured() throws InterruptedException {
// Given
ConfigMap configMap = new ConfigMapBuilder().withNewMetadata().withName("cm1").withNamespace("ns1").endMetadata().build();
Ingress ingress = new IngressBuilder().withNewMetadata().withName("ing1").withNamespace("ns2").endMetadata().build();
ServiceAccount serviceAccount = new ServiceAccountBuilder().withNewMetadata().withName("sa1").endMetadata().build();
List<HasMetadata> entities = new ArrayList<>();
entities.add(configMap);
entities.add(serviceAccount);
entities.add(ingress);
WebServerEventCollector collector = new WebServerEventCollector();
mockServer.expect().post().withPath("/api/v1/namespaces/ns1/configmaps").andReply(collector.record("configmap-ns1-create").andReturn(HTTP_OK, configMap)).once();
mockServer.expect().post().withPath("/apis/networking.k8s.io/v1/namespaces/ns2/ingresses").andReply(collector.record("ingress-ns2-create").andReturn(HTTP_OK, ingress)).once();
mockServer.expect().post().withPath("/api/v1/namespaces/default/serviceaccounts").andReply(collector.record("serviceaccount-default-create").andReturn(HTTP_OK, serviceAccount)).once();
String configuredNamespace = applyService.getNamespace();
applyService.setNamespace(null);
applyService.setFallbackNamespace("default");
// When
applyService.applyEntities(null, entities, log, 5);
// Then
collector.assertEventsRecordedInOrder("configmap-ns1-create", "serviceaccount-default-create", "ingress-ns2-create");
assertEquals(5, mockServer.getOpenShiftMockServer().getRequestCount());
applyService.setFallbackNamespace(null);
applyService.setNamespace(configuredNamespace);
}
Aggregations