Search in sources :

Example 11 with UndertowFraction

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

the class HTTPSCustomizerTest method testWithManagementFraction.

@Test
public void testWithManagementFraction() throws Exception {
    HTTPSCustomizer customizer = new HTTPSCustomizer();
    customizer.undertow = new UndertowFraction();
    customizer.undertow.applyDefaults();
    customizer.certInfo = new CertInfo("myhost.com", "./my/path");
    customizer.managementCoreService = new MockInstance<>(new ManagementCoreService());
    customizer.customize();
    Server server = customizer.undertow.subresources().server("default-server");
    assertThat(server).isNotNull();
    assertThat(server.subresources().httpListeners()).hasSize(1);
    assertThat(server.subresources().httpListener("default")).isNotNull();
    assertThat(server.subresources().httpsListeners()).hasSize(1);
    assertThat(server.subresources().httpsListener("default-https")).isNotNull();
    SecurityRealm realm = customizer.managementCoreService.get().subresources().securityRealm("SSLRealm");
    assertThat(realm).isNotNull();
    assertThat(realm.subresources().sslServerIdentity().keystoreRelativeTo()).isEqualTo("./my/path");
    assertSelfSignedCertificate(realm.subresources().sslServerIdentity(), "myhost.com");
}
Also used : CertInfo(org.wildfly.swarm.undertow.descriptors.CertInfo) UndertowFraction(org.wildfly.swarm.undertow.UndertowFraction) Server(org.wildfly.swarm.config.undertow.Server) SecurityRealm(org.wildfly.swarm.config.management.SecurityRealm) ManagementCoreService(org.wildfly.swarm.config.ManagementCoreService) Test(org.junit.Test)

Example 12 with UndertowFraction

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

the class HTTPSCustomizerTest method testWithoutManagementFraction.

@Test
public void testWithoutManagementFraction() {
    HTTPSCustomizer customizer = new HTTPSCustomizer();
    customizer.undertow = new UndertowFraction();
    customizer.undertow.applyDefaults();
    customizer.certInfo = CertInfo.INVALID;
    customizer.managementCoreService = new MockInstance<>(null);
    customizer.customize();
    Server server = customizer.undertow.subresources().server("default-server");
    assertThat(server).isNotNull();
    assertThat(server.subresources().httpListeners()).hasSize(1);
    assertThat(server.subresources().httpListener("default")).isNotNull();
    assertThat(server.subresources().httpsListeners()).isEmpty();
}
Also used : UndertowFraction(org.wildfly.swarm.undertow.UndertowFraction) Server(org.wildfly.swarm.config.undertow.Server) Test(org.junit.Test)

Example 13 with UndertowFraction

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

the class UndertowSocketBindingsCustomizerTest method testExplicitHttpPort.

@Test
public void testExplicitHttpPort() {
    UndertowSocketBindingsCustomizer customizer = new UndertowSocketBindingsCustomizer();
    customizer.fraction = new UndertowFraction();
    customizer.fraction.httpPort(8675);
    customizer.group = new SocketBindingGroup("standard-sockets", "public", "0");
    customizer.customize();
    assertThat(customizer.group.socketBindings()).hasSize(2);
    SocketBinding http = customizer.group.socketBinding("http");
    assertThat(http).isNotNull();
    assertThat(http.portExpression()).isEqualTo("8675");
    SocketBinding https = customizer.group.socketBinding("https");
    assertThat(https).isNotNull();
    assertThat(https.portExpression()).isEqualTo("8443");
}
Also used : SocketBinding(org.wildfly.swarm.spi.api.SocketBinding) UndertowFraction(org.wildfly.swarm.undertow.UndertowFraction) SocketBindingGroup(org.wildfly.swarm.spi.api.SocketBindingGroup) 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