diff --git a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/Constants.java b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/Constants.java index bd8ded7f30a1..beabef0e7f51 100644 --- a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/Constants.java +++ b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/Constants.java @@ -50,7 +50,7 @@ public class Constants { static final String TX = "TX"; static final String NON_TX = "NonTX"; - static final Boolean ELYTRON_MANAGED_SECURITY = Boolean.FALSE; + static final Boolean ELYTRON_MANAGED_SECURITY = Boolean.TRUE; static final String ELYTRON_ENABLED_NAME = "elytron-enabled"; diff --git a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/DistributedWorkManagerAdd.java b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/DistributedWorkManagerAdd.java index 5c8ea0b280e2..d424a5114fd3 100644 --- a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/DistributedWorkManagerAdd.java +++ b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/DistributedWorkManagerAdd.java @@ -67,11 +67,8 @@ public class DistributedWorkManagerAdd extends AbstractAddStepHandler { public static final DistributedWorkManagerAdd INSTANCE = new DistributedWorkManagerAdd(); - @Override - protected void populateModel(final ModelNode operation, final ModelNode model) throws OperationFailedException { - for (JcaDistributedWorkManagerDefinition.DWmParameters parameter : JcaDistributedWorkManagerDefinition.DWmParameters.values()) { - parameter.getAttribute().validateAndSet(operation, model); - } + private DistributedWorkManagerAdd() { + super(JcaDistributedWorkManagerDefinition.DWmParameters.getAttributes()); } @Override diff --git a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaDistributedWorkManagerDefinition.java b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaDistributedWorkManagerDefinition.java index 0d31d941fd7e..6b732d22db51 100644 --- a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaDistributedWorkManagerDefinition.java +++ b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaDistributedWorkManagerDefinition.java @@ -27,6 +27,7 @@ import static org.jboss.as.connector.subsystems.jca.Constants.ELYTRON_MANAGED_SECURITY; import static org.jboss.as.connector.subsystems.jca.JcaWorkManagerDefinition.registerSubModels; +import java.util.Arrays; import java.util.EnumSet; import org.jboss.as.connector.metadata.api.common.Security; @@ -131,7 +132,6 @@ enum DWmParameters { .setDefaultValue(new ModelNode(ELYTRON_MANAGED_SECURITY)) .build()); - public static AttributeDefinition[] getAttributeDefinitions() { final AttributeDefinition[] returnValue = new AttributeDefinition[DWmParameters.values().length]; int i = 0; @@ -167,6 +167,10 @@ public AttributeDefinition getAttribute() { } private AttributeDefinition attribute; + + static AttributeDefinition[] getAttributes() { + return Arrays.stream(DWmParameters.values()).map(DWmParameters::getAttribute).toArray(AttributeDefinition[]::new); + } } enum DWmCapabilities { diff --git a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaExtension.java b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaExtension.java index b7e2ab1b2d6b..dd6423e26e4e 100644 --- a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaExtension.java +++ b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaExtension.java @@ -80,7 +80,7 @@ public class JcaExtension implements Extension { public static final String SUBSYSTEM_NAME = "jca"; - private static final ModelVersion CURRENT_MODEL_VERSION = ModelVersion.create(5, 0, 0); + private static final ModelVersion CURRENT_MODEL_VERSION = ModelVersion.create(6, 0, 0); private static final String RESOURCE_NAME = JcaExtension.class.getPackage().getName() + ".LocalDescriptions"; @@ -113,6 +113,7 @@ public void initializeParsers(final ExtensionParsingContext context) { context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.JCA_3_0.getUriString(), () -> ConnectorSubsystemParser.INSTANCE); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.JCA_4_0.getUriString(), () -> ConnectorSubsystemParser.INSTANCE); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.JCA_5_0.getUriString(), () -> ConnectorSubsystemParser.INSTANCE); + context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.JCA_6_0.getUriString(), () -> ConnectorSubsystemParser.INSTANCE); } static final class ConnectorSubsystemParser implements XMLStreamConstants, XMLElementReader>, @@ -323,8 +324,9 @@ public void readElement(final XMLExtendedStreamReader reader, final List requiredElement = EnumSet.of(Element.DEFAULT_WORKMANAGER); boolean ccmAdded = false; while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { - - switch (Namespace.forUri(reader.getNamespaceURI())) { + Namespace readerNs = Namespace.forUri(reader.getNamespaceURI()); + switch (readerNs) { + case JCA_6_0: case JCA_5_0: case JCA_4_0: case JCA_3_0: @@ -345,7 +347,7 @@ public void readElement(final XMLExtendedStreamReader reader, final List list, final ModelNode node, boolean defaultWm) throws XMLStreamException { + final List list, boolean defaultWm, Namespace elementNs) throws XMLStreamException { final ModelNode workManagerOperation = new ModelNode(); workManagerOperation.get(OP).set(ADD); @@ -524,9 +528,17 @@ private void parseWorkManager(final XMLExtendedStreamReader reader, final ModelN } case ELYTRON_ENABLED: { switch (readerNS) { + case JCA_6_0: { + String value = rawElementText(reader); + JcaWorkManagerDefinition.WmParameters.ELYTRON_ENABLED.getAttribute().parseAndSetParameter(value, workManagerOperation, reader); + break; + } case JCA_5_0: { String value = rawElementText(reader); JcaWorkManagerDefinition.WmParameters.ELYTRON_ENABLED.getAttribute().parseAndSetParameter(value, workManagerOperation, reader); + if (!workManagerOperation.hasDefined(JcaWorkManagerDefinition.WmParameters.ELYTRON_ENABLED.getAttribute().getName())) { + workManagerOperation.get(JcaWorkManagerDefinition.WmParameters.ELYTRON_ENABLED.getAttribute().getName()).set(new ModelNode(false)); + } break; } default: { @@ -542,10 +554,12 @@ private void parseWorkManager(final XMLExtendedStreamReader reader, final ModelN } + // For older versions set 'elytron-enabled' to 'false' if not explicitly set, as that was the default in those xsds + handleLegacyWorkManagerSecurity(workManagerOperation, JcaWorkManagerDefinition.WmParameters.ELYTRON_ENABLED.getAttribute(), elementNs); } private void parseDistributedWorkManager(final XMLExtendedStreamReader reader, final ModelNode parentAddress, - final List list, final ModelNode node, boolean defaultWm) throws XMLStreamException { + final List list, Namespace elementNS) throws XMLStreamException { final ModelNode distributedWorkManagerOperation = new ModelNode(); distributedWorkManagerOperation.get(OP).set(ADD); @@ -603,7 +617,8 @@ private void parseDistributedWorkManager(final XMLExtendedStreamReader reader, f case JCA_2_0: case JCA_3_0: case JCA_4_0: - case JCA_5_0: { + case JCA_5_0: + case JCA_6_0:{ parsePolicy(reader, distributedWorkManagerOperation); break; } @@ -618,7 +633,8 @@ private void parseDistributedWorkManager(final XMLExtendedStreamReader reader, f case JCA_2_0: case JCA_3_0: case JCA_4_0: - case JCA_5_0: { + case JCA_5_0: + case JCA_6_0:{ parseSelector(reader, distributedWorkManagerOperation); break; } @@ -630,11 +646,21 @@ private void parseDistributedWorkManager(final XMLExtendedStreamReader reader, f } case ELYTRON_ENABLED: { switch (readerNS) { - case JCA_5_0: { + case JCA_6_0: + { String value = rawElementText(reader); ((SimpleAttributeDefinition) JcaDistributedWorkManagerDefinition.DWmParameters.ELYTRON_ENABLED.getAttribute()).parseAndSetParameter(value, distributedWorkManagerOperation, reader); break; } + case JCA_5_0: + { + String value = rawElementText(reader); + ((SimpleAttributeDefinition) JcaDistributedWorkManagerDefinition.DWmParameters.ELYTRON_ENABLED.getAttribute()).parseAndSetParameter(value, distributedWorkManagerOperation, reader); + if (!distributedWorkManagerOperation.hasDefined(JcaDistributedWorkManagerDefinition.DWmParameters.ELYTRON_ENABLED.getAttribute().getName())) { + distributedWorkManagerOperation.get(JcaDistributedWorkManagerDefinition.DWmParameters.ELYTRON_ENABLED.getAttribute().getName()).set(new ModelNode(false)); + } + break; + } default: { throw unexpectedElement(reader); } @@ -648,6 +674,8 @@ private void parseDistributedWorkManager(final XMLExtendedStreamReader reader, f } + // For older versions set 'elytron-enabled' to 'false' if not explicitly set, as that was the default in those xsds + handleLegacyWorkManagerSecurity(distributedWorkManagerOperation, JcaDistributedWorkManagerDefinition.DWmParameters.ELYTRON_ENABLED.getAttribute(), elementNS); } @@ -918,5 +946,25 @@ private void writeProperty(XMLExtendedStreamWriter writer, String name, String v writer.writeEndElement(); } + + private static void handleLegacyWorkManagerSecurity(ModelNode addOp, AttributeDefinition ad, Namespace ns) { + + if (!addOp.hasDefined(ad.getName())) { + switch (ns) { + case JCA_1_1: + case JCA_2_0: + case JCA_3_0: + case JCA_4_0: + case JCA_5_0: + // set the old default value from these xsd versions + addOp.get(ad.getName()).set(false); + break; + default: + // unconfigured value in later namespaces matches current AttributeDefinition default + break; + } + } + + } } } diff --git a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaTransformers.java b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaTransformers.java new file mode 100644 index 000000000000..edd8bc912f97 --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaTransformers.java @@ -0,0 +1,68 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2021, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.as.connector.subsystems.jca; + +import static org.jboss.as.connector.subsystems.jca.JcaDistributedWorkManagerDefinition.PATH_DISTRIBUTED_WORK_MANAGER; +import static org.jboss.as.connector.subsystems.jca.JcaExtension.SUBSYSTEM_NAME; +import static org.jboss.as.connector.subsystems.jca.JcaWorkManagerDefinition.PATH_WORK_MANAGER; + +import org.jboss.as.controller.ModelVersion; +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.ChainedTransformationDescriptionBuilder; +import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; +import org.jboss.as.controller.transform.description.TransformationDescriptionBuilder; + +public class JcaTransformers implements ExtensionTransformerRegistration { + + private static final ModelVersion EAP_7_4 = ModelVersion.create(5, 0, 0); + + @Override + public String getSubsystemName() { + return SUBSYSTEM_NAME; + } + + @Override + public void registerTransformers(SubsystemTransformerRegistration subsystemRegistration) { + ChainedTransformationDescriptionBuilder chainedBuilder = TransformationDescriptionBuilder.Factory.createChainedSubystemInstance(subsystemRegistration.getCurrentSubsystemVersion()); + get500TransformationDescription(chainedBuilder.createBuilder(subsystemRegistration.getCurrentSubsystemVersion(), EAP_7_4)); + + chainedBuilder.buildAndRegister(subsystemRegistration, new ModelVersion[]{ + EAP_7_4 + }); + } + + private static void get500TransformationDescription(ResourceTransformationDescriptionBuilder parentBuilder) { + parentBuilder.addChildResource(PATH_WORK_MANAGER) + .getAttributeBuilder() + .setValueConverter(AttributeConverter.DEFAULT_VALUE, + JcaWorkManagerDefinition.WmParameters.ELYTRON_ENABLED.getAttribute()) + .end(); + parentBuilder.addChildResource(PATH_DISTRIBUTED_WORK_MANAGER) + .getAttributeBuilder() + .setValueConverter(AttributeConverter.DEFAULT_VALUE, + JcaDistributedWorkManagerDefinition.DWmParameters.ELYTRON_ENABLED.getAttribute()) + .end(); + } + +} \ No newline at end of file diff --git a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaWorkManagerDefinition.java b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaWorkManagerDefinition.java index 00acdbbbabe1..8d061a68a7f0 100644 --- a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaWorkManagerDefinition.java +++ b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaWorkManagerDefinition.java @@ -29,10 +29,12 @@ import static org.jboss.as.connector.subsystems.jca.Constants.WORKMANAGER_SHORT_RUNNING; import static org.jboss.as.controller.OperationContext.Stage.MODEL; +import java.util.Arrays; import java.util.Set; import org.jboss.as.connector.logging.ConnectorLogger; import org.jboss.as.connector.metadata.api.common.Security; +import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.OperationStepHandler; @@ -157,12 +159,14 @@ public enum WmParameters { .setRestartAllServices() .setXmlName("name") .build()), + ELYTRON_ENABLED(new SimpleAttributeDefinitionBuilder(ELYTRON_ENABLED_NAME, ModelType.BOOLEAN, true) .setXmlName(Security.Tag.ELYTRON_ENABLED.getLocalName()) .setAllowExpression(true) .setDefaultValue(new ModelNode(ELYTRON_MANAGED_SECURITY)) .build()); + WmParameters(SimpleAttributeDefinition attribute) { this.attribute = attribute; } @@ -172,6 +176,10 @@ public SimpleAttributeDefinition getAttribute() { } private SimpleAttributeDefinition attribute; + + static AttributeDefinition[] getAttributes() { + return Arrays.stream(WmParameters.values()).map(WmParameters::getAttribute).toArray(AttributeDefinition[]::new); + } } } diff --git a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/Namespace.java b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/Namespace.java index f228f4a89eb2..0e4cea7d8cb3 100644 --- a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/Namespace.java +++ b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/Namespace.java @@ -42,13 +42,15 @@ public enum Namespace { JCA_4_0("urn:jboss:domain:jca:4.0"), - JCA_5_0("urn:jboss:domain:jca:5.0"); + JCA_5_0("urn:jboss:domain:jca:5.0"), + + JCA_6_0("urn:jboss:domain:jca:6.0"); /** * The current namespace version. */ - public static final Namespace CURRENT = JCA_5_0; + public static final Namespace CURRENT = JCA_6_0; private final String name; diff --git a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/WorkManagerAdd.java b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/WorkManagerAdd.java index 4c9fa1f12a3b..71dbebd6238e 100644 --- a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/WorkManagerAdd.java +++ b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/WorkManagerAdd.java @@ -53,12 +53,8 @@ public class WorkManagerAdd extends AbstractAddStepHandler { public static final WorkManagerAdd INSTANCE = new WorkManagerAdd(); - - @Override - protected void populateModel(final ModelNode operation, final ModelNode model) throws OperationFailedException { - for (JcaWorkManagerDefinition.WmParameters parameter : JcaWorkManagerDefinition.WmParameters.values()) { - parameter.getAttribute().validateAndSet(operation, model); - } + private WorkManagerAdd() { + super(JcaWorkManagerDefinition.WmParameters.getAttributes()); } @Override diff --git a/connector/src/main/resources/META-INF/services/org.jboss.as.controller.transform.ExtensionTransformerRegistration b/connector/src/main/resources/META-INF/services/org.jboss.as.controller.transform.ExtensionTransformerRegistration index ecc6f499c0cc..1a4f94ca061c 100644 --- a/connector/src/main/resources/META-INF/services/org.jboss.as.controller.transform.ExtensionTransformerRegistration +++ b/connector/src/main/resources/META-INF/services/org.jboss.as.controller.transform.ExtensionTransformerRegistration @@ -20,4 +20,5 @@ # 02110-1301 USA, or see the FSF site: http://www.fsf.org. # -org.jboss.as.connector.subsystems.datasources.DataSourcesTransformers \ No newline at end of file +org.jboss.as.connector.subsystems.datasources.DataSourcesTransformers +org.jboss.as.connector.subsystems.jca.JcaTransformers \ No newline at end of file diff --git a/connector/src/main/resources/schema/wildfly-jca_6_0.xsd b/connector/src/main/resources/schema/wildfly-jca_6_0.xsd new file mode 100644 index 000000000000..8d170bf1e594 --- /dev/null +++ b/connector/src/main/resources/schema/wildfly-jca_6_0.xsd @@ -0,0 +1,399 @@ + + + + + + + + + + + + + + + Toggle archive validation for the deployment + units. If it's not present it's considered true + with default attributes. + + + + + + + + Toggle bean validation (JSR-303) for the + deployment units. If it's not present it's + considered true + + + + + + + + Toggle Tracer for the + deployment units. If it's not present it's + considered false + + + + + + + + The default work manager and its thread pools + + + + + + + + A custom work manager definition and its thread pools + + + + + + + + A distributed work manager definition and its thread pools + + + + + + + + Definition of custom bootstrap contexts + + + + + + + + + + + + + Specify whether archive validation is enabled. Default: true + + + + + + + Should an archive validation error report fail the deployment. Default: true + + + + + + + Should an archive validation warning report fail the deployment. Default: false + + + + + + + + + + Specify whether bean validation is enabled. + + + + + + + + + + Specify whether tracer is enabled. + + + + + + + + + + + Thread pool for short running jobs. + Long running jobs are identified by the HintsContext.LONGRUNNING_HINT with a value of true. + + + + + + + Thread pool for long running jobs. + Long running jobs are identified by the HintsContext.LONGRUNNING_HINT with a value of true. + + + + + + + + + + + + + + + + + + + Thread pool for short running jobs. + Long running jobs are identified by the HintsContext.LONGRUNNING_HINT with a value of true. + + + + + + + Thread pool for long running jobs. + Long running jobs are identified by the HintsContext.LONGRUNNING_HINT with a value of true. + + + + + + + + + + + + + + + Specifies the name of the work manager. + + + + + + + + + + + Thread pool for short running jobs. + Long running jobs are identified by the HintsContext.LONGRUNNING_HINT with a value of true. + + + + + + + Thread pool for long running jobs. + Long running jobs are identified by the HintsContext.LONGRUNNING_HINT with a value of true. + + + + + + + + + + + + + + + + + Specifies the name of the work manager. Note, that custom work managers need + to have a name defined. + + + + + + + + + + + + + + + This provides a mechanism to pass a bootstrap context to a resource adapter instance when it is bootstrapped. + The bootstrap context contains references to useful facilities that could be used by the resource adapter instance. + + + + + + Specifies the name of the bootstrap context. + + + + + + + Specifies the name of the work manager to use for this context. + + + + + + + + + + Enable/disable debug information logging + + + + + + + Enable/disable error information logging + + + + + + + Do not cache unknown connections + + + + + + + + + + + + + + + + + + + + + + + + + + + + + When to distribute the work instance + Supported policies + - NEVER + Never distribute the Work instance to another node. + - ALWAYS + Always distribute the Work instance to another node. + - WATERMARK + Distribute the Work instance to another node based on how many free worker threads the current + node has available. + + Default is WATERMARK with a watermark of 0 + + + + + + + + + + + + + + + + + + + + + To which work manager instance should the Work instance be distributed to + Supported selectors + - FIRST_AVAILABLE + Select the first available node in the list + - PING_TIME + Select the node with the lowest ping time + - MAX_FREE_THREADS + Select the node with highest number of free worker threads + + Default is PING_TIME + + + + + + + + + + + + + + + + + Name of the option to be set + + + + + diff --git a/connector/src/test/java/org/jboss/as/connector/subsystems/jca/JcaSubsystemTestCase.java b/connector/src/test/java/org/jboss/as/connector/subsystems/jca/JcaSubsystemTestCase.java index 2313d714eebd..6c39ed52fbbc 100644 --- a/connector/src/test/java/org/jboss/as/connector/subsystems/jca/JcaSubsystemTestCase.java +++ b/connector/src/test/java/org/jboss/as/connector/subsystems/jca/JcaSubsystemTestCase.java @@ -21,19 +21,31 @@ */ package org.jboss.as.connector.subsystems.jca; +import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; +import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.util.HashSet; +import java.util.Set; +import org.jboss.as.connector.logging.ConnectorLogger; import org.jboss.as.connector.util.ConnectorServices; +import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.PathAddress; +import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.operations.common.Util; +import org.jboss.as.model.test.ModelTestControllerVersion; +import org.jboss.as.model.test.SingleClassFilter; import org.jboss.as.naming.service.NamingService; import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest; import org.jboss.as.subsystem.test.AdditionalInitialization; import org.jboss.as.subsystem.test.KernelServices; +import org.jboss.as.subsystem.test.KernelServicesBuilder; +import org.jboss.as.subsystem.test.LegacyKernelServicesInitializer; import org.jboss.dmr.ModelNode; +import org.junit.Assert; import org.junit.Test; import org.wildfly.clustering.server.service.ClusteringDefaultRequirement; @@ -54,7 +66,7 @@ protected String getSubsystemXml() throws IOException { @Override protected String getSubsystemXsdPath() throws Exception { - return "schema/wildfly-jca_5_0.xsd"; + return "schema/wildfly-jca_6_0.xsd"; } @Override @@ -180,10 +192,62 @@ public void testMultipleWorkManagers() throws Exception { services.executeForResult(composite); } + /** WFLY-16478. Test transformation of undefined elytron-enabled */ + @Test + public void testEAP74Transformation() throws Exception { + ModelTestControllerVersion eap74ControllerVersion = ModelTestControllerVersion.EAP_7_4_0; + ModelVersion eap74ModelVersion = ModelVersion.create(5, 0, 0); + KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()) + .setSubsystemXmlResource("jca-default-elytron.xml"); + KernelServices mainServices = initialKernelServices(builder, eap74ControllerVersion, eap74ModelVersion); + + ModelNode legacyModel = checkSubsystemModelTransformation(mainServices, eap74ModelVersion); + assertTrue(legacyModel.toString(), legacyModel.get("subsystem", "jca", "workmanager", "default", "elytron-enabled").asBoolean(false)); + assertTrue(legacyModel.toString(), legacyModel.get("subsystem", "jca", "workmanager", "anotherWm", "elytron-enabled").asBoolean(false)); + assertTrue(legacyModel.toString(), legacyModel.get("subsystem", "jca", "distributed-workmanager", "MyDWM", "elytron-enabled").asBoolean(false)); + mainServices.shutdown(); + } + + /** WFLY-16478 Test legacy parser sets old default value for elytron-enabled */ + @Test + public void testLegacyDefaultElytronEnabled() throws Exception { + Set required = new HashSet<>(); + PathAddress subsystem = PathAddress.pathAddress("subsystem", "jca"); + required.add(subsystem.append("workmanager", "default").toModelNode()); + required.add(subsystem.append("workmanager", "anotherWm").toModelNode()); + required.add(subsystem.append("distributed-workmanager", "MyDWM").toModelNode()); + + for (ModelNode op : parse(getSubsystemXml("jca_5_0.xml"))) { + if (ADD.equals(op.get(OP).asString()) && required.remove(op.get(ModelDescriptionConstants.OP_ADDR))) { + assertFalse(op.toString() + "\n did not correctly define elytron-enabled", op.get("elytron-enabled").asBoolean(true)); + } + } + + assertTrue("Not all expected ops were found\n" + required.toString(), required.isEmpty()); + } + @Override protected void compareXml(String configId, String original, String marshalled) throws Exception { super.compareXml(configId, original, marshalled, true); } + private KernelServices initialKernelServices(KernelServicesBuilder builder, ModelTestControllerVersion controllerVersion, final ModelVersion modelVersion) throws Exception { + LegacyKernelServicesInitializer initializer = builder.createLegacyKernelServicesBuilder(createAdditionalInitialization(), controllerVersion, modelVersion); + String mavenGroupId = controllerVersion.getMavenGroupId(); + String artifactId = "wildfly-connector"; + initializer.addMavenResourceURL(mavenGroupId + ":" + artifactId + ":" + controllerVersion.getMavenGavVersion()) + .addMavenResourceURL(mavenGroupId + ":wildfly-clustering-api:" + controllerVersion.getMavenGavVersion()) + .addMavenResourceURL(mavenGroupId + ":wildfly-clustering-spi:" + controllerVersion.getMavenGavVersion()) + .addMavenResourceURL("org.wildfly.core:wildfly-threads:" + controllerVersion.getCoreVersion()) + .setExtensionClassName("org.jboss.as.connector.subsystems.jca.JcaExtension") + .excludeFromParent(SingleClassFilter.createFilter(ConnectorLogger.class)); + KernelServices mainServices = builder.build(); + Assert.assertTrue(mainServices.isSuccessfulBoot()); + KernelServices legacyServices = mainServices.getLegacyServices(modelVersion); + Assert.assertTrue(legacyServices.isSuccessfulBoot()); + Assert.assertNotNull(legacyServices); + return mainServices; + } + } diff --git a/connector/src/test/resources/org/jboss/as/connector/subsystems/complextestcases/jca.xml b/connector/src/test/resources/org/jboss/as/connector/subsystems/complextestcases/jca.xml index 77a474e7e830..9a1e35aacf54 100644 --- a/connector/src/test/resources/org/jboss/as/connector/subsystems/complextestcases/jca.xml +++ b/connector/src/test/resources/org/jboss/as/connector/subsystems/complextestcases/jca.xml @@ -1,4 +1,4 @@ - + diff --git a/connector/src/test/resources/org/jboss/as/connector/subsystems/complextestcases/minimal-jca.xml b/connector/src/test/resources/org/jboss/as/connector/subsystems/complextestcases/minimal-jca.xml index 3b2a4703b171..60412e05259d 100644 --- a/connector/src/test/resources/org/jboss/as/connector/subsystems/complextestcases/minimal-jca.xml +++ b/connector/src/test/resources/org/jboss/as/connector/subsystems/complextestcases/minimal-jca.xml @@ -1,4 +1,4 @@ - + diff --git a/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca-default-elytron.xml b/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca-default-elytron.xml new file mode 100644 index 000000000000..af584cbb6f55 --- /dev/null +++ b/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca-default-elytron.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca-full-expression.xml b/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca-full-expression.xml index 7fc1d1aba48e..218ea3c9a977 100644 --- a/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca-full-expression.xml +++ b/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca-full-expression.xml @@ -1,4 +1,4 @@ - + diff --git a/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca-full.xml b/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca-full.xml index b9e5005d4449..86fc827602cf 100644 --- a/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca-full.xml +++ b/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca-full.xml @@ -1,4 +1,4 @@ - + diff --git a/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca-minimal.xml b/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca-minimal.xml index 82f18c668b6b..f77cf3e496db 100644 --- a/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca-minimal.xml +++ b/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca-minimal.xml @@ -1,4 +1,4 @@ - + diff --git a/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca.xml b/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca.xml index 6ed264053ce0..c8869a9a355c 100644 --- a/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca.xml +++ b/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca.xml @@ -1,4 +1,4 @@ - + diff --git a/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca_5_0.xml b/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca_5_0.xml new file mode 100644 index 000000000000..02596810f3da --- /dev/null +++ b/connector/src/test/resources/org/jboss/as/connector/subsystems/jca/jca_5_0.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index 483f498a5924..84096860a238 100644 --- a/pom.xml +++ b/pom.xml @@ -447,7 +447,7 @@ 2.0.10.Final 3.5.12.Final 1.0.2.Final - 1.5.5.Final + 1.5.6.Final 7.6.1.Final 1.0.3.Final @@ -548,7 +548,7 @@ 3.0.0 4.0.0 3.1.0 - 2.0.0 + 2.1.0 2.0.0 6.0.0 3.1.0 diff --git a/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/security/workmanager/WildFlyActivationRaWithWMElytronSecurityDomainWorkManagerElytronDisabledTestCase.java b/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/security/workmanager/WildFlyActivationRaWithWMElytronSecurityDomainWorkManagerElytronUnconfiguredTestCase.java similarity index 88% rename from testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/security/workmanager/WildFlyActivationRaWithWMElytronSecurityDomainWorkManagerElytronDisabledTestCase.java rename to testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/security/workmanager/WildFlyActivationRaWithWMElytronSecurityDomainWorkManagerElytronUnconfiguredTestCase.java index 035f5cdf9da8..ed909478d42b 100644 --- a/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/security/workmanager/WildFlyActivationRaWithWMElytronSecurityDomainWorkManagerElytronDisabledTestCase.java +++ b/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/security/workmanager/WildFlyActivationRaWithWMElytronSecurityDomainWorkManagerElytronUnconfiguredTestCase.java @@ -18,8 +18,6 @@ package org.jboss.as.test.integration.jca.security.workmanager; -import static org.hamcrest.CoreMatchers.containsString; - import java.util.function.Consumer; import org.jboss.arquillian.container.test.api.Deployer; @@ -35,9 +33,7 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.wildfly.test.security.common.AbstractElytronSetupTask; import org.wildfly.test.security.common.elytron.ConfigurableElement; @@ -45,16 +41,16 @@ /** * Test security inflow with Jakarta Connectors work manager where RA is configured with Elytron security domain - * and Workmanager is configured with legacy security (it doesn't have elytron-enabled=true), - * it is not allowed to mix security configuration and it should fail + * and Workmanager is configured with Elytron security explicitly configured (it doesn't have elytron-enabled=true). + * Default workmanager behavior if unconfigured is elytron is enabled so this should deploy successfully. */ @RunWith(Arquillian.class) @ServerSetup({ - WildFlyActivationRaWithWMElytronSecurityDomainWorkManagerElytronDisabledTestCase.ElytronSetup.class, - WildFlyActivationRaWithWMElytronSecurityDomainWorkManagerElytronDisabledTestCase.JcaSetup.class, - WildFlyActivationRaWithWMElytronSecurityDomainWorkManagerElytronDisabledTestCase.RaSetup.class}) + WildFlyActivationRaWithWMElytronSecurityDomainWorkManagerElytronUnconfiguredTestCase.ElytronSetup.class, + WildFlyActivationRaWithWMElytronSecurityDomainWorkManagerElytronUnconfiguredTestCase.JcaSetup.class, + WildFlyActivationRaWithWMElytronSecurityDomainWorkManagerElytronUnconfiguredTestCase.RaSetup.class}) @RunAsClient -public class WildFlyActivationRaWithWMElytronSecurityDomainWorkManagerElytronDisabledTestCase { +public class WildFlyActivationRaWithWMElytronSecurityDomainWorkManagerElytronUnconfiguredTestCase { private static final String ADMIN_OBJ_JNDI_NAME = "java:jboss/admObj"; private static final String WM_ELYTRON_SECURITY_DOMAIN_NAME = "RaRealmElytron"; private static final String BOOTSTRAP_CTX_NAME = "wrongContext"; @@ -131,15 +127,11 @@ public static Archive rarDeployment() { return rar; } - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @ArquillianResource private Deployer deployer; @Test - public void testMixedSecurity() throws Throwable { - expectedException.expectMessage(containsString("WFLYJCA0111")); + public void testUnconfiguredElytron() throws Throwable { deployer.deploy("wf-ra-wm-security-domain-rar"); try { deployer.undeploy("wf-ra-wm-security-domain-rar");