Search in sources :

Example 1 with UndertowFraction

use of org.wildfly.swarm.undertow.UndertowFraction in project wildfly-swarm by wildfly-swarm.

the class UndertowFilterCustomizer method customize.

@Override
public void customize() {
    if (!undertowFractionInstance.isUnsatisfied()) {
        UndertowFraction undertow = undertowFractionInstance.get();
        if (undertow.subresources().filterConfiguration() == null) {
            undertow.filterConfiguration();
        }
        undertow.subresources().filterConfiguration().customFilter("wfs-health", customFilter -> {
            customFilter.module("org.wildfly.swarm.microprofile.health:runtime");
            customFilter.className("org.wildfly.swarm.microprofile.health.runtime.SecureHttpContexts");
        });
        undertow.subresources().server("default-server").subresources().host("default-host").filterRef("wfs-health", f -> {
            f.priority(100);
        });
    } else {
        throw new RuntimeException("The health fraction requires the undertow fraction!");
    }
}
Also used : UndertowFraction(org.wildfly.swarm.undertow.UndertowFraction)

Example 2 with UndertowFraction

use of org.wildfly.swarm.undertow.UndertowFraction in project wildfly-swarm by wildfly-swarm.

the class OpenApiUndertowFilterCustomizer method customize.

@Override
public void customize() {
    if (!undertowFractionInstance.isUnsatisfied()) {
        UndertowFraction undertow = undertowFractionInstance.get();
        if (undertow.subresources().filterConfiguration() == null) {
            undertow.filterConfiguration();
        }
        undertow.subresources().filterConfiguration().customFilter("wfs-openapi", customFilter -> {
            customFilter.module("org.wildfly.swarm.microprofile.openapi:runtime");
            customFilter.className("org.wildfly.swarm.microprofile.openapi.runtime.OpenApiHttpHandler");
        });
        undertow.subresources().server("default-server").subresources().host("default-host").filterRef("wfs-openapi", f -> {
            f.priority(100);
        });
    } else {
        throw new RuntimeException("The microprofile-openapi fraction requires the undertow fraction!");
    }
}
Also used : UndertowFraction(org.wildfly.swarm.undertow.UndertowFraction)

Example 3 with UndertowFraction

use of org.wildfly.swarm.undertow.UndertowFraction in project wildfly-swarm by wildfly-swarm.

the class CertInfoProducerTest method testGenerateWithDefaults.

@Test
@Category(CommunityOnly.class)
public void testGenerateWithDefaults() {
    CertInfoProducer producer = new CertInfoProducer();
    producer.undertow = new UndertowFraction();
    producer.generateSelfCertificate.set(true);
    CertInfo certInfo = producer.produceCertInfo();
    assertThat(certInfo).isNotNull();
    assertThat(certInfo.generateSelfSignedCertificateHost()).isEqualTo("localhost");
}
Also used : CertInfo(org.wildfly.swarm.undertow.descriptors.CertInfo) UndertowFraction(org.wildfly.swarm.undertow.UndertowFraction) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 4 with UndertowFraction

use of org.wildfly.swarm.undertow.UndertowFraction in project wildfly-swarm by wildfly-swarm.

the class CertInfoProducerTest method testGenerateWithExplicitHost.

@Test
@Category(CommunityOnly.class)
public void testGenerateWithExplicitHost() {
    CertInfoProducer producer = new CertInfoProducer();
    producer.undertow = new UndertowFraction();
    producer.generateSelfCertificate.set(true);
    producer.selfCertificateHost.set("www.mycorp.com");
    CertInfo certInfo = producer.produceCertInfo();
    assertThat(certInfo).isNotNull();
    assertThat(certInfo.generateSelfSignedCertificateHost()).isEqualTo("www.mycorp.com");
}
Also used : CertInfo(org.wildfly.swarm.undertow.descriptors.CertInfo) UndertowFraction(org.wildfly.swarm.undertow.UndertowFraction) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 5 with UndertowFraction

use of org.wildfly.swarm.undertow.UndertowFraction in project wildfly-swarm by wildfly-swarm.

the class HTTP2CustomizerTest method testHTTP2Enabled.

@Test
public void testHTTP2Enabled() {
    HTTP2Customizer customizer = new HTTP2Customizer();
    customizer.undertow = new UndertowFraction().applyDefaults();
    Server server = customizer.undertow.subresources().server(UndertowProperties.DEFAULT_SERVER);
    AtomicReference<HttpsListener> listener = new AtomicReference<>();
    server.httpsListener("default-https", (config) -> {
        listener.set(config);
    });
    assertThat(listener.get()).isNotNull();
    assertThat(listener.get().enableHttp2()).isNull();
    customizer.customize();
    assertThat(listener.get().enableHttp2()).isTrue();
}
Also used : UndertowFraction(org.wildfly.swarm.undertow.UndertowFraction) Server(org.wildfly.swarm.config.undertow.Server) AtomicReference(java.util.concurrent.atomic.AtomicReference) HttpsListener(org.wildfly.swarm.config.undertow.server.HttpsListener) Test(org.junit.Test)

Aggregations

UndertowFraction (org.wildfly.swarm.undertow.UndertowFraction)13 Test (org.junit.Test)9 CertInfo (org.wildfly.swarm.undertow.descriptors.CertInfo)4 Server (org.wildfly.swarm.config.undertow.Server)3 SocketBinding (org.wildfly.swarm.spi.api.SocketBinding)3 SocketBindingGroup (org.wildfly.swarm.spi.api.SocketBindingGroup)3 Category (org.junit.experimental.categories.Category)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 ManagementCoreService (org.wildfly.swarm.config.ManagementCoreService)1 SecurityRealm (org.wildfly.swarm.config.management.SecurityRealm)1 HttpsListener (org.wildfly.swarm.config.undertow.server.HttpsListener)1