From e6c6167a1e720ba05f84efa8c659a6d6e7518247 Mon Sep 17 00:00:00 2001 From: baranowb Date: Tue, 2 Nov 2021 11:24:21 +0100 Subject: [PATCH 1/3] [WFLY-15452] - allow specifying AJP_ALLOWED_REQUEST_ATTRIBUTES_PATTERN --- .../org/wildfly/extension/undertow/AjpListenerAdd.java | 1 + .../undertow/AjpListenerResourceDefinition.java | 10 +++++++++- .../java/org/wildfly/extension/undertow/Constants.java | 1 + .../extension/undertow/LocalDescriptions.properties | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/undertow/src/main/java/org/wildfly/extension/undertow/AjpListenerAdd.java b/undertow/src/main/java/org/wildfly/extension/undertow/AjpListenerAdd.java index a932ae0102bc..79aeced1c878 100644 --- a/undertow/src/main/java/org/wildfly/extension/undertow/AjpListenerAdd.java +++ b/undertow/src/main/java/org/wildfly/extension/undertow/AjpListenerAdd.java @@ -29,6 +29,7 @@ AjpListenerService createService(final Consumer serviceConsumer } OptionMap.Builder listenerBuilder = OptionMap.builder().addAll(listenerOptions); AjpListenerResourceDefinition.MAX_AJP_PACKET_SIZE.resolveOption(context, model,listenerBuilder); + AjpListenerResourceDefinition.ALLOWED_REQUEST_ATTRIBUTES_PATTERN.resolveOption(context, model,listenerBuilder); return new AjpListenerService(serviceConsumer, context.getCurrentAddress(), scheme, listenerBuilder.getMap(), socketOptions); } diff --git a/undertow/src/main/java/org/wildfly/extension/undertow/AjpListenerResourceDefinition.java b/undertow/src/main/java/org/wildfly/extension/undertow/AjpListenerResourceDefinition.java index 54c8140cca50..71e015241ba7 100644 --- a/undertow/src/main/java/org/wildfly/extension/undertow/AjpListenerResourceDefinition.java +++ b/undertow/src/main/java/org/wildfly/extension/undertow/AjpListenerResourceDefinition.java @@ -5,6 +5,7 @@ package org.wildfly.extension.undertow; + import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -45,7 +46,14 @@ public class AjpListenerResourceDefinition extends ListenerResourceDefinition { .setValidator(new IntRangeValidator(1)) .build(); - static final List ATTRIBUTES = List.of(SCHEME, REDIRECT_SOCKET, MAX_AJP_PACKET_SIZE); + protected static final OptionAttributeDefinition ALLOWED_REQUEST_ATTRIBUTES_PATTERN = OptionAttributeDefinition + .builder(Constants.ALLOWED_REQUEST_ATTRIBUTES_PATTERN, UndertowOptions.AJP_ALLOWED_REQUEST_ATTRIBUTES_PATTERN) + .setRequired(false) + .setAllowExpression(true) + .setDefaultValue(null) + .build(); + + static final List ATTRIBUTES = List.of(SCHEME, REDIRECT_SOCKET, MAX_AJP_PACKET_SIZE, ALLOWED_REQUEST_ATTRIBUTES_PATTERN); AjpListenerResourceDefinition() { super(new SimpleResourceDefinition.Parameters(PATH_ELEMENT, UndertowExtension.getResolver(Constants.LISTENER)), new AjpListenerAdd(), Map.of()); diff --git a/undertow/src/main/java/org/wildfly/extension/undertow/Constants.java b/undertow/src/main/java/org/wildfly/extension/undertow/Constants.java index 17b9f9ae3e4c..667c9bd94826 100644 --- a/undertow/src/main/java/org/wildfly/extension/undertow/Constants.java +++ b/undertow/src/main/java/org/wildfly/extension/undertow/Constants.java @@ -130,6 +130,7 @@ public interface Constants { String CERTIFICATE_FORWARDING = "certificate-forwarding"; String OPTIONS = "options"; String IGNORE_FLUSH = "ignore-flush"; + String ALLOWED_REQUEST_ATTRIBUTES_PATTERN = "allowed-request-attributes-pattern"; String WEBSOCKETS = "websockets"; //mod_cluster diff --git a/undertow/src/main/resources/org/wildfly/extension/undertow/LocalDescriptions.properties b/undertow/src/main/resources/org/wildfly/extension/undertow/LocalDescriptions.properties index b66ccc34d31c..7579c8d22f29 100644 --- a/undertow/src/main/resources/org/wildfly/extension/undertow/LocalDescriptions.properties +++ b/undertow/src/main/resources/org/wildfly/extension/undertow/LocalDescriptions.properties @@ -261,6 +261,7 @@ undertow.listener.http2-max-header-list-size=The maximum size of request headers undertow.listener.http2-initial-window-size=The flow control window size that controls how quickly the client can send data to the server undertow.listener.http2-header-table-size=The size of the header table used for HPACK compression, in bytes. This amount of memory will be allocated per connection for compression. Larger values use more memory but may give better compression. undertow.listener.require-host-http11=Require that all HTTP/1.1 requests have a 'Host' header, as per the RFC. IF the request does not include this header it will be rejected with a 403. +undertow.listener.allowed-request-attributes-pattern=Pattern(regex) which specifies allowed custom AJP request attributes. undertow.host=An Undertow host undertow.host.add=Adds a new host undertow.host.remove=Removes a host From 31b82fe6f81e0fd9fb406c2076394b820746066b Mon Sep 17 00:00:00 2001 From: baranowb Date: Thu, 9 Nov 2023 13:54:42 +0100 Subject: [PATCH 2/3] [WFLY-15452] bump undertow version --- ...ertowExtensionTransformerRegistration.java | 17 +- .../undertow/UndertowSubsystemModel.java | 5 +- .../undertow/UndertowSubsystemSchema.java | 5 +- .../schema/wildfly-undertow_15_0.xsd | 1108 +++++++++++++++++ .../undertow/ServerServiceTestCase.java | 2 +- .../undertow/UndertowServiceTestCase.java | 2 +- .../extension/undertow/undertow-15.0.xml | 111 ++ 7 files changed, 1243 insertions(+), 7 deletions(-) create mode 100644 undertow/src/main/resources/schema/wildfly-undertow_15_0.xsd create mode 100644 undertow/src/test/resources/org/wildfly/extension/undertow/undertow-15.0.xml diff --git a/undertow/src/main/java/org/wildfly/extension/undertow/UndertowExtensionTransformerRegistration.java b/undertow/src/main/java/org/wildfly/extension/undertow/UndertowExtensionTransformerRegistration.java index 52f6a7661fd8..be80f7765c0f 100644 --- a/undertow/src/main/java/org/wildfly/extension/undertow/UndertowExtensionTransformerRegistration.java +++ b/undertow/src/main/java/org/wildfly/extension/undertow/UndertowExtensionTransformerRegistration.java @@ -13,6 +13,7 @@ import org.jboss.as.controller.transform.ExtensionTransformerRegistration; import org.jboss.as.controller.transform.SubsystemTransformerRegistration; import org.jboss.as.controller.transform.description.AttributeConverter; +import org.jboss.as.controller.transform.description.AttributeTransformationDescriptionBuilder; import org.jboss.as.controller.transform.description.DiscardAttributeChecker; import org.jboss.as.controller.transform.description.RejectAttributeChecker; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; @@ -39,7 +40,7 @@ public void registerTransformers(SubsystemTransformerRegistration registration) ResourceTransformationDescriptionBuilder subsystem = TransformationDescriptionBuilder.Factory.createSubsystemInstance(); ResourceTransformationDescriptionBuilder server = subsystem.addChildResource(ServerDefinition.PATH_ELEMENT); - for (PathElement listenerPath : Set.of(HttpListenerResourceDefinition.PATH_ELEMENT, HttpsListenerResourceDefinition.PATH_ELEMENT, AjpListenerResourceDefinition.PATH_ELEMENT)) { + for (PathElement listenerPath : Set.of(HttpListenerResourceDefinition.PATH_ELEMENT, HttpsListenerResourceDefinition.PATH_ELEMENT)) { if (UndertowSubsystemModel.VERSION_13_0_0.requiresTransformation(version)) { server.addChildResource(listenerPath).getAttributeBuilder() .setValueConverter(AttributeConverter.DEFAULT_VALUE, ListenerResourceDefinition.WRITE_TIMEOUT, ListenerResourceDefinition.READ_TIMEOUT) @@ -57,6 +58,20 @@ public void registerTransformers(SubsystemTransformerRegistration registration) servletContainer.rejectChildResource(AffinityCookieDefinition.PATH_ELEMENT); } + final ResourceTransformationDescriptionBuilder ajpListener = server.addChildResource(AjpListenerResourceDefinition.PATH_ELEMENT); + if (UndertowSubsystemModel.VERSION_14_0_0.requiresTransformation(version)) { + final AttributeTransformationDescriptionBuilder ajpListenerAttributeTransformationDescriptionBuilder = ajpListener.getAttributeBuilder(); + ajpListenerAttributeTransformationDescriptionBuilder.setDiscard(DiscardAttributeChecker.UNDEFINED, AjpListenerResourceDefinition.ALLOWED_REQUEST_ATTRIBUTES_PATTERN) + .addRejectCheck(RejectAttributeChecker.DEFINED, AjpListenerResourceDefinition.ALLOWED_REQUEST_ATTRIBUTES_PATTERN) + .end(); + + if (UndertowSubsystemModel.VERSION_13_0_0.requiresTransformation(version)) { + ajpListenerAttributeTransformationDescriptionBuilder + .setValueConverter(AttributeConverter.DEFAULT_VALUE, ListenerResourceDefinition.WRITE_TIMEOUT, ListenerResourceDefinition.READ_TIMEOUT) + .end(); + } + } + TransformationDescription.Tools.register(subsystem.build(), registration, version); } } diff --git a/undertow/src/main/java/org/wildfly/extension/undertow/UndertowSubsystemModel.java b/undertow/src/main/java/org/wildfly/extension/undertow/UndertowSubsystemModel.java index 47455ecb81d8..b6e390701a38 100644 --- a/undertow/src/main/java/org/wildfly/extension/undertow/UndertowSubsystemModel.java +++ b/undertow/src/main/java/org/wildfly/extension/undertow/UndertowSubsystemModel.java @@ -16,9 +16,10 @@ public enum UndertowSubsystemModel implements SubsystemModel { VERSION_11_0_0(11), // WildFly 23-26.x, EAP 7.4.x VERSION_12_0_0(12), // WildFly 27 - VERSION_13_0_0(13), // WildFly 28-present + VERSION_13_0_0(13), // WildFly 28 + VERSION_14_0_0(14), // WildFly 31-present ; - static final UndertowSubsystemModel CURRENT = VERSION_13_0_0; + static final UndertowSubsystemModel CURRENT = VERSION_14_0_0; private final ModelVersion version; diff --git a/undertow/src/main/java/org/wildfly/extension/undertow/UndertowSubsystemSchema.java b/undertow/src/main/java/org/wildfly/extension/undertow/UndertowSubsystemSchema.java index d616382f59e6..1871f3e3df1b 100644 --- a/undertow/src/main/java/org/wildfly/extension/undertow/UndertowSubsystemSchema.java +++ b/undertow/src/main/java/org/wildfly/extension/undertow/UndertowSubsystemSchema.java @@ -34,9 +34,10 @@ public enum UndertowSubsystemSchema implements PersistentSubsystemSchema namespace; diff --git a/undertow/src/main/resources/schema/wildfly-undertow_15_0.xsd b/undertow/src/main/resources/schema/wildfly-undertow_15_0.xsd new file mode 100644 index 000000000000..e8eb5eb050e8 --- /dev/null +++ b/undertow/src/main/resources/schema/wildfly-undertow_15_0.xsd @@ -0,0 +1,1108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Whether statistics are to be gathered for undertow subsystem. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + requires SSL transport, + undertow will automatically redirect the request to the socket binding port specified here. + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Reference to the SSLContext that should be used by this listener. + + If neither ssl-context or security-realm are set the JVM wide default SSLContext will be used instead. + + If this attribute is defined, the attributes 'verify-client', 'enabled-cipher-suites', 'enabled-protocols', + 'ssl-session-cache-size', and 'ssl-session-timeout' must not be set. + + + + + + + + + + + + + + + + + + + + + Deprecated: ssl-context should be set instead to reference a defined SSLContext. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + requires SSL transport, + undertow will automatically redirect the request to the socket binding port specified here. + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default response code should be set in case server should respond with nonstandard code( other than 404 ) for unavailable resource. + For instance, server behind load balancer might want to respond with 5xx code to avoid being dropped by it. + + + + + + + + + + + + + + Deprecated: The http-authentication-factory attribute should be used to configure authentication. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A collection of free-form meta-data properties. + + + + + + + + + + + + + + + The available attributes to be included in the structured access log output. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Deprecated: The ssl-context attribute should be used to reference a defined SSLContext. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Determines how a failover node is chosen, in the event that the node to which a session has affinity is not available. + + + + + + + + + + + + + + + + + Deprecated: The ssl-context attribute should be used to reference a defined SSLContext. + + + + + + + + + + + + + + + + + + + + + Web requests will not have an affinity for any particular server, routing information will be ignored. + Intended for use cases where web session state is not maintained within the application server. + + + + + + + Web requests have an affinity for the member that last handled a given session. + This option corresponds to traditional sticky session behavior. + + + + + + + Web requests will have an affinity for the first available node in a list typically comprised of: primary owner, backup nodes, local node (if not a primary nor backup owner). + + + + + + + + + + + The delimiter used to separate ranked routes within the session ID. + + + + + + + + + + + + + + + Failover target chosen via load balancing mechanism. + + + + + + + Failover target chosen deterministically from the associated session identifier. + + + + + + + + + + Listing of security domains from applications that should be mapped to an Elytron + backed authentication policy. + + + + + + + + + + + + + + + The name of the security domain as specified in deployments. + + + + + + + Reference to the HttpAuthenticationFactory that should be used. + + Exactly one of http-authentication-factory or security-domain must be defined. + + + + + + + The references HttpServerAuthenticationMechanismFactory contains it's own policy configuration + to control the authentication mechanisms it supports, if this attribute is set to 'true' + that policy will override the methods specified within the deployment. + + This attribute can only be specified if a http-authentication-factory is also specified. + + + + + + + Reference to the security-domain that should be associated with the deployment, where a + security-domain is referenced instead of a http-authentication-factory the authentication mechanisms + BASIC, DIGEST, FORM and CLIENT_CERT will be availble for the deployment to use - additionally the deployment + can make use of the programatic login API. + + Exactly one of http-authentication-factory or security-domain must be defined. + + + + + + + Enable authorization using JACC. + + + + + + + Should deployments matching against this 'application-security-domain' have + JASPI enabled, by setting to false JASPI will be completely disabled for the deployment. + + + + + + + When integrated-jaspi is enabled during JASPI authentication the resulting + identity will be loaded from the SecurityDomain referenced by the deployment, if + this is switched off AdHoc identities will be created instead. + + + + + + + + + + + + + + References key store containing the key used to sign and verify logout requests. + + + + + The alias of the key used to sign and verify logout requests. + + + + + The ssl context used to secure back-channel logout connections. + + + + + + + diff --git a/undertow/src/test/java/org/wildfly/extension/undertow/ServerServiceTestCase.java b/undertow/src/test/java/org/wildfly/extension/undertow/ServerServiceTestCase.java index bb4bb5b4ddd0..e09251dd15f0 100644 --- a/undertow/src/test/java/org/wildfly/extension/undertow/ServerServiceTestCase.java +++ b/undertow/src/test/java/org/wildfly/extension/undertow/ServerServiceTestCase.java @@ -34,7 +34,7 @@ public class ServerServiceTestCase extends AbstractUndertowSubsystemTestCase { private static final String UNDERTOW_SERVER = "undertow-server"; public ServerServiceTestCase() { - super(UndertowSubsystemSchema.VERSION_12_0); + super(UndertowSubsystemSchema.VERSION_15_0); } @Override diff --git a/undertow/src/test/java/org/wildfly/extension/undertow/UndertowServiceTestCase.java b/undertow/src/test/java/org/wildfly/extension/undertow/UndertowServiceTestCase.java index 773a98e1936f..1714b29c35e5 100644 --- a/undertow/src/test/java/org/wildfly/extension/undertow/UndertowServiceTestCase.java +++ b/undertow/src/test/java/org/wildfly/extension/undertow/UndertowServiceTestCase.java @@ -29,7 +29,7 @@ public class UndertowServiceTestCase extends AbstractUndertowSubsystemTestCase { private static final String DEFAULT_VIRTUAL_HOST = "default-host"; public UndertowServiceTestCase() { - super(UndertowSubsystemSchema.VERSION_14_0); + super(UndertowSubsystemSchema.CURRENT); } @Override diff --git a/undertow/src/test/resources/org/wildfly/extension/undertow/undertow-15.0.xml b/undertow/src/test/resources/org/wildfly/extension/undertow/undertow-15.0.xml new file mode 100644 index 000000000000..60e2b3460888 --- /dev/null +++ b/undertow/src/test/resources/org/wildfly/extension/undertow/undertow-15.0.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 1779c1daa79f00500aa864847f7b1e0c21b33ddf Mon Sep 17 00:00:00 2001 From: baranowb Date: Mon, 20 May 2024 10:50:11 +0200 Subject: [PATCH 3/3] [WFLY-15452] Switch to Stability.PREVIEW level --- .../AjpListenerResourceDefinition.java | 2 ++ .../extension/undertow/UndertowExtension.java | 16 +++----------- .../undertow/UndertowSubsystemSchema.java | 21 +++++++++++++++---- ....xsd => wildfly-undertow_preview_14_0.xsd} | 6 +++--- .../AbstractUndertowSubsystemTestCase.java | 12 ++++------- .../undertow/DefaultInitialization.java | 4 ++++ .../undertow/RuntimeInitialization.java | 3 ++- .../undertow/ServerServiceTestCase.java | 16 +++++++++++--- .../UndertowServerRemovalTestCase.java | 16 +++++++++++--- .../undertow/UndertowServiceTestCase.java | 16 +++++++++++--- ...tow-15.0.xml => undertow-preview-14.0.xml} | 2 +- 11 files changed, 75 insertions(+), 39 deletions(-) rename undertow/src/main/resources/schema/{wildfly-undertow_15_0.xsd => wildfly-undertow_preview_14_0.xsd} (99%) rename undertow/src/test/resources/org/wildfly/extension/undertow/{undertow-15.0.xml => undertow-preview-14.0.xml} (97%) diff --git a/undertow/src/main/java/org/wildfly/extension/undertow/AjpListenerResourceDefinition.java b/undertow/src/main/java/org/wildfly/extension/undertow/AjpListenerResourceDefinition.java index 71e015241ba7..fd76dce21b70 100644 --- a/undertow/src/main/java/org/wildfly/extension/undertow/AjpListenerResourceDefinition.java +++ b/undertow/src/main/java/org/wildfly/extension/undertow/AjpListenerResourceDefinition.java @@ -22,6 +22,7 @@ import org.jboss.as.controller.client.helpers.MeasurementUnit; import org.jboss.as.controller.operations.validation.IntRangeValidator; import org.jboss.as.controller.registry.AttributeAccess; +import org.jboss.as.version.Stability; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.extension.io.OptionAttributeDefinition; @@ -51,6 +52,7 @@ public class AjpListenerResourceDefinition extends ListenerResourceDefinition { .setRequired(false) .setAllowExpression(true) .setDefaultValue(null) + .setStability(Stability.PREVIEW) .build(); static final List ATTRIBUTES = List.of(SCHEME, REDIRECT_SOCKET, MAX_AJP_PACKET_SIZE, ALLOWED_REQUEST_ATTRIBUTES_PATTERN); diff --git a/undertow/src/main/java/org/wildfly/extension/undertow/UndertowExtension.java b/undertow/src/main/java/org/wildfly/extension/undertow/UndertowExtension.java index 246d9b9829d2..345e4e38ca8e 100644 --- a/undertow/src/main/java/org/wildfly/extension/undertow/UndertowExtension.java +++ b/undertow/src/main/java/org/wildfly/extension/undertow/UndertowExtension.java @@ -6,20 +6,15 @@ package org.wildfly.extension.undertow; import java.util.EnumSet; -import java.util.List; import org.jboss.as.controller.Extension; import org.jboss.as.controller.ExtensionContext; -import org.jboss.as.controller.PersistentResourceXMLDescription; -import org.jboss.as.controller.PersistentResourceXMLDescriptionReader; import org.jboss.as.controller.PersistentResourceXMLDescriptionWriter; import org.jboss.as.controller.SubsystemRegistration; import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver; import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler; import org.jboss.as.controller.parsing.ExtensionParsingContext; import org.jboss.as.controller.registry.ManagementResourceRegistration; -import org.jboss.dmr.ModelNode; -import org.jboss.staxmapper.XMLElementReader; /** @@ -38,14 +33,9 @@ public static StandardResourceDescriptionResolver getResolver(final String... ke return new StandardResourceDescriptionResolver(prefix.toString(), RESOURCE_NAME, UndertowExtension.class.getClassLoader(), true, false); } - private final PersistentResourceXMLDescription currentDescription = UndertowSubsystemSchema.CURRENT.getXMLDescription(); - @Override public void initializeParsers(ExtensionParsingContext context) { - for (UndertowSubsystemSchema schema : EnumSet.allOf(UndertowSubsystemSchema.class)) { - XMLElementReader> reader = (schema == UndertowSubsystemSchema.CURRENT) ? new PersistentResourceXMLDescriptionReader(this.currentDescription) : schema; - context.setSubsystemXmlMapping(SUBSYSTEM_NAME, schema.getNamespace().getUri(), reader); - } + context.setSubsystemXmlMappings(SUBSYSTEM_NAME, EnumSet.allOf(UndertowSubsystemSchema.class)); } @Override @@ -58,6 +48,6 @@ public void initialize(ExtensionContext context) { deployments.registerSubModel(new DeploymentServletDefinition()); deployments.registerSubModel(new DeploymentWebSocketDefinition()); - subsystem.registerXMLElementWriter(new PersistentResourceXMLDescriptionWriter(this.currentDescription)); + subsystem.registerXMLElementWriter(new PersistentResourceXMLDescriptionWriter(UndertowSubsystemSchema.CURRENT.get(context.getStability()))); } -} +} \ No newline at end of file diff --git a/undertow/src/main/java/org/wildfly/extension/undertow/UndertowSubsystemSchema.java b/undertow/src/main/java/org/wildfly/extension/undertow/UndertowSubsystemSchema.java index 1871f3e3df1b..62e4bf14d0cd 100644 --- a/undertow/src/main/java/org/wildfly/extension/undertow/UndertowSubsystemSchema.java +++ b/undertow/src/main/java/org/wildfly/extension/undertow/UndertowSubsystemSchema.java @@ -5,10 +5,15 @@ package org.wildfly.extension.undertow; +import java.util.EnumSet; +import java.util.Map; + +import org.jboss.as.controller.Feature; import org.jboss.as.controller.PersistentResourceXMLDescription; import org.jboss.as.controller.PersistentSubsystemSchema; import org.jboss.as.controller.SubsystemSchema; import org.jboss.as.controller.xml.VersionedNamespace; +import org.jboss.as.version.Stability; import org.jboss.staxmapper.IntVersion; /** @@ -35,10 +40,10 @@ public enum UndertowSubsystemSchema implements PersistentSubsystemSchema CURRENT = Feature.map(EnumSet.of(VERSION_14_0, VERSION_14_0_PREVIEW)); private final VersionedNamespace namespace; UndertowSubsystemSchema(int major) { @@ -50,7 +55,15 @@ public enum UndertowSubsystemSchema implements PersistentSubsystemSchema getNamespace() { public PersistentResourceXMLDescription getXMLDescription() { return UndertowPersistentResourceXMLDescriptionFactory.INSTANCE.apply(this); } -} +} \ No newline at end of file diff --git a/undertow/src/main/resources/schema/wildfly-undertow_15_0.xsd b/undertow/src/main/resources/schema/wildfly-undertow_preview_14_0.xsd similarity index 99% rename from undertow/src/main/resources/schema/wildfly-undertow_15_0.xsd rename to undertow/src/main/resources/schema/wildfly-undertow_preview_14_0.xsd index e8eb5eb050e8..53142ed5a834 100644 --- a/undertow/src/main/resources/schema/wildfly-undertow_15_0.xsd +++ b/undertow/src/main/resources/schema/wildfly-undertow_preview_14_0.xsd @@ -6,13 +6,13 @@ --> - + diff --git a/undertow/src/test/java/org/wildfly/extension/undertow/AbstractUndertowSubsystemTestCase.java b/undertow/src/test/java/org/wildfly/extension/undertow/AbstractUndertowSubsystemTestCase.java index cb77676ce413..3d4598a285c1 100644 --- a/undertow/src/test/java/org/wildfly/extension/undertow/AbstractUndertowSubsystemTestCase.java +++ b/undertow/src/test/java/org/wildfly/extension/undertow/AbstractUndertowSubsystemTestCase.java @@ -34,14 +34,10 @@ public abstract class AbstractUndertowSubsystemTestCase extends AbstractSubsystemSchemaTest { final Map> values = new ConcurrentHashMap<>(); - private final UndertowSubsystemSchema schema; - - AbstractUndertowSubsystemTestCase() { - this(UndertowSubsystemSchema.CURRENT); - } + protected final UndertowSubsystemSchema schema; AbstractUndertowSubsystemTestCase(UndertowSubsystemSchema schema) { - super(UndertowExtension.SUBSYSTEM_NAME, new UndertowExtension(), schema, UndertowSubsystemSchema.CURRENT); + super(UndertowExtension.SUBSYSTEM_NAME, new UndertowExtension(), schema, UndertowSubsystemSchema.CURRENT.get(schema.getStability())); this.schema = schema; } @@ -67,7 +63,7 @@ public void testRuntime() throws Exception { // Skip runtime tests for old versions - since legacy SSO is only allowed in admin-only mode if (!this.schema.since(UndertowSubsystemSchema.VERSION_14_0)) return; - KernelServicesBuilder builder = createKernelServicesBuilder(new RuntimeInitialization(this.values)).setSubsystemXml(getSubsystemXml()); + KernelServicesBuilder builder = createKernelServicesBuilder(new RuntimeInitialization(this.values, this.schema)).setSubsystemXml(getSubsystemXml()); KernelServices mainServices = builder.build(); if (!mainServices.isSuccessfulBoot()) { @@ -166,6 +162,6 @@ public void testRuntime() throws Exception { @Override protected AdditionalInitialization createAdditionalInitialization() { - return new DefaultInitialization(); + return new DefaultInitialization(this.schema); } } diff --git a/undertow/src/test/java/org/wildfly/extension/undertow/DefaultInitialization.java b/undertow/src/test/java/org/wildfly/extension/undertow/DefaultInitialization.java index 5c6489a47e49..a92c5e4bee1d 100644 --- a/undertow/src/test/java/org/wildfly/extension/undertow/DefaultInitialization.java +++ b/undertow/src/test/java/org/wildfly/extension/undertow/DefaultInitialization.java @@ -50,6 +50,10 @@ class DefaultInitialization extends AdditionalInitialization.ManagementAdditiona private static final long serialVersionUID = 1L; + public DefaultInitialization(final UndertowSubsystemSchema schema) { + super(schema); + } + @Override protected ControllerInitializer createControllerInitializer() { return new ControllerInitializer() { diff --git a/undertow/src/test/java/org/wildfly/extension/undertow/RuntimeInitialization.java b/undertow/src/test/java/org/wildfly/extension/undertow/RuntimeInitialization.java index b65e055313c2..b7a2a8e8db05 100644 --- a/undertow/src/test/java/org/wildfly/extension/undertow/RuntimeInitialization.java +++ b/undertow/src/test/java/org/wildfly/extension/undertow/RuntimeInitialization.java @@ -39,7 +39,8 @@ class RuntimeInitialization extends DefaultInitialization { private final Map> values; - RuntimeInitialization(Map> values) { + RuntimeInitialization(final Map> values, final UndertowSubsystemSchema schema) { + super(schema); this.values = values; } diff --git a/undertow/src/test/java/org/wildfly/extension/undertow/ServerServiceTestCase.java b/undertow/src/test/java/org/wildfly/extension/undertow/ServerServiceTestCase.java index e09251dd15f0..b1529807f2e1 100644 --- a/undertow/src/test/java/org/wildfly/extension/undertow/ServerServiceTestCase.java +++ b/undertow/src/test/java/org/wildfly/extension/undertow/ServerServiceTestCase.java @@ -16,6 +16,9 @@ import org.junit.Assert; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -26,6 +29,7 @@ * * @author Flavia Rainone */ +@RunWith(Parameterized.class) public class ServerServiceTestCase extends AbstractUndertowSubsystemTestCase { private static final String NODE_NAME = "node-name"; @@ -33,8 +37,14 @@ public class ServerServiceTestCase extends AbstractUndertowSubsystemTestCase { private static final String DEFAULT_VIRTUAL_HOST = "default-host"; private static final String UNDERTOW_SERVER = "undertow-server"; - public ServerServiceTestCase() { - super(UndertowSubsystemSchema.VERSION_15_0); + @Parameters + public static Iterable parameters() { + return UndertowSubsystemSchema.CURRENT.values(); + } + + public ServerServiceTestCase(UndertowSubsystemSchema schema) { + super(schema); + // TODO Auto-generated constructor stub } @Override @@ -44,7 +54,7 @@ public void setUp() { } private Server load(String xmlFile, String serverName) throws Exception { - KernelServicesBuilder builder = createKernelServicesBuilder(new RuntimeInitialization(this.values)).setSubsystemXml(readResource(xmlFile)); + KernelServicesBuilder builder = createKernelServicesBuilder(new RuntimeInitialization(this.values, super.schema)).setSubsystemXml(readResource(xmlFile)); KernelServices mainServices = builder.build(); if (!mainServices.isSuccessfulBoot()) { Throwable t = mainServices.getBootError(); diff --git a/undertow/src/test/java/org/wildfly/extension/undertow/UndertowServerRemovalTestCase.java b/undertow/src/test/java/org/wildfly/extension/undertow/UndertowServerRemovalTestCase.java index d687f920bfd7..9a6d5fe571bb 100644 --- a/undertow/src/test/java/org/wildfly/extension/undertow/UndertowServerRemovalTestCase.java +++ b/undertow/src/test/java/org/wildfly/extension/undertow/UndertowServerRemovalTestCase.java @@ -14,6 +14,9 @@ import org.jboss.msc.service.ServiceName; import org.junit.Assert; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -25,14 +28,21 @@ * * @author Lin Gao */ +@RunWith(Parameterized.class) public class UndertowServerRemovalTestCase extends AbstractUndertowSubsystemTestCase { private static final String NODE_NAME = "node-name"; private static final String SERVER_ABC = "abc"; private static final String HOST_ABC = "abc-host"; - public UndertowServerRemovalTestCase() { - super(UndertowSubsystemSchema.CURRENT); + @Parameters + public static Iterable parameters() { + return UndertowSubsystemSchema.CURRENT.values(); + } + + public UndertowServerRemovalTestCase(UndertowSubsystemSchema schema) { + super(schema); + // TODO Auto-generated constructor stub } @Override @@ -42,7 +52,7 @@ public void setUp() { } private KernelServices load(String subsystemXml) throws Exception { - KernelServicesBuilder builder = createKernelServicesBuilder(new RuntimeInitialization(this.values)).setSubsystemXml(subsystemXml); + KernelServicesBuilder builder = createKernelServicesBuilder(new RuntimeInitialization(this.values, super.schema)).setSubsystemXml(subsystemXml); KernelServices mainServices = builder.build(); if (!mainServices.isSuccessfulBoot()) { Throwable t = mainServices.getBootError(); diff --git a/undertow/src/test/java/org/wildfly/extension/undertow/UndertowServiceTestCase.java b/undertow/src/test/java/org/wildfly/extension/undertow/UndertowServiceTestCase.java index 1714b29c35e5..2aa18290e066 100644 --- a/undertow/src/test/java/org/wildfly/extension/undertow/UndertowServiceTestCase.java +++ b/undertow/src/test/java/org/wildfly/extension/undertow/UndertowServiceTestCase.java @@ -10,6 +10,9 @@ import org.junit.Assert; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -21,6 +24,7 @@ * * @author Flavia Rainone */ +@RunWith(Parameterized.class) public class UndertowServiceTestCase extends AbstractUndertowSubsystemTestCase { private static final String NODE_NAME = "node-name"; @@ -28,8 +32,14 @@ public class UndertowServiceTestCase extends AbstractUndertowSubsystemTestCase { private static final String DEFAULT_SERVLET_CONTAINER = "default"; private static final String DEFAULT_VIRTUAL_HOST = "default-host"; - public UndertowServiceTestCase() { - super(UndertowSubsystemSchema.CURRENT); + @Parameters + public static Iterable parameters() { + return UndertowSubsystemSchema.CURRENT.values(); + } + + public UndertowServiceTestCase(UndertowSubsystemSchema schema) { + super(schema); + // TODO Auto-generated constructor stub } @Override @@ -39,7 +49,7 @@ public void setUp() { } private UndertowService load(String xmlFile) throws Exception { - KernelServicesBuilder builder = createKernelServicesBuilder(new RuntimeInitialization(this.values)).setSubsystemXml(readResource(xmlFile)); + KernelServicesBuilder builder = createKernelServicesBuilder(new RuntimeInitialization(this.values, super.schema)).setSubsystemXml(readResource(xmlFile)); KernelServices mainServices = builder.build(); if (!mainServices.isSuccessfulBoot()) { Throwable t = mainServices.getBootError(); diff --git a/undertow/src/test/resources/org/wildfly/extension/undertow/undertow-15.0.xml b/undertow/src/test/resources/org/wildfly/extension/undertow/undertow-preview-14.0.xml similarity index 97% rename from undertow/src/test/resources/org/wildfly/extension/undertow/undertow-15.0.xml rename to undertow/src/test/resources/org/wildfly/extension/undertow/undertow-preview-14.0.xml index 60e2b3460888..d0089074bf2e 100644 --- a/undertow/src/test/resources/org/wildfly/extension/undertow/undertow-15.0.xml +++ b/undertow/src/test/resources/org/wildfly/extension/undertow/undertow-preview-14.0.xml @@ -3,7 +3,7 @@ ~ SPDX-License-Identifier: Apache-2.0 --> - +