From 01b5aac7d72173bf4e14152f7d8bf119ef758dc5 Mon Sep 17 00:00:00 2001 From: Paul Ferraro Date: Thu, 5 Dec 2024 12:02:25 +0000 Subject: [PATCH 1/2] WFCORE-7083 ModuleNameValidator fails if module name contains a dash --- .../controller/operations/validation/ModuleNameValidator.java | 2 +- .../operation/validation/ModuleNameValidatorTestCase.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/controller/src/main/java/org/jboss/as/controller/operations/validation/ModuleNameValidator.java b/controller/src/main/java/org/jboss/as/controller/operations/validation/ModuleNameValidator.java index 456642abc95..1597fa14c2b 100644 --- a/controller/src/main/java/org/jboss/as/controller/operations/validation/ModuleNameValidator.java +++ b/controller/src/main/java/org/jboss/as/controller/operations/validation/ModuleNameValidator.java @@ -20,7 +20,7 @@ public class ModuleNameValidator extends ModelTypeValidator { public static final ParameterValidator INSTANCE = new ModuleNameValidator(); // Ensure module name is valid with filesystem module repository, permitting deprecated slot, if present - private static final Predicate MODULE_NAME_TESTER = Pattern.compile("(?:^\\w+|\\w+\\.\\w+|\\w+\\Q\\:\\E\\w+)+(?:\\:(?:\\w+|\\w+\\.\\w+))?$").asMatchPredicate(); + private static final Predicate MODULE_NAME_TESTER = Pattern.compile("(?:^\\w+|\\w+[\\.\\-]\\w+|\\w+\\Q\\:\\E\\w+)+(?:\\:(?:\\w+|\\w+[\\.\\-]\\w+))?$").asMatchPredicate(); private ModuleNameValidator() { super(ModelType.STRING); diff --git a/controller/src/test/java/org/jboss/as/controller/operation/validation/ModuleNameValidatorTestCase.java b/controller/src/test/java/org/jboss/as/controller/operation/validation/ModuleNameValidatorTestCase.java index 3bdc165c85d..89249d538df 100644 --- a/controller/src/test/java/org/jboss/as/controller/operation/validation/ModuleNameValidatorTestCase.java +++ b/controller/src/test/java/org/jboss/as/controller/operation/validation/ModuleNameValidatorTestCase.java @@ -25,6 +25,7 @@ public void test() throws OperationFailedException { validator.validateParameter("valid", new ModelNode("org.jboss.modules:main")); validator.validateParameter("valid", new ModelNode("org.jboss.modules:1.9")); validator.validateParameter("escaped", new ModelNode("org.jboss.modules.foo\\:bar:main")); + validator.validateParameter("dash", new ModelNode("org.infinispan.hibernate-cache")); Assert.assertThrows(OperationFailedException.class, () -> validator.validateParameter("invalid", new ModelNode(".foo.bar"))); Assert.assertThrows(OperationFailedException.class, () -> validator.validateParameter("invalid", new ModelNode("foo..bar"))); From d4f13c77c6a3b18b94812c0ab9ca9198fdc0d9f5 Mon Sep 17 00:00:00 2001 From: Paul Ferraro Date: Thu, 5 Dec 2024 12:07:11 +0000 Subject: [PATCH 2/2] Align package name of tests with their source package. --- .../global/AbstractCollectionOperationsTestCase.java | 4 +--- .../global/CollectionOperationsTestCase.java | 2 +- .../global/EnhancedSyntaxTestCase.java | 4 +--- .../global/StorageRuntimeCollectionOperationsTestCase.java | 2 +- .../validation/ModelTypeValidatorUnitTestCase.java | 3 +-- .../validation/ModuleNameValidatorTestCase.java | 4 +--- 6 files changed, 6 insertions(+), 13 deletions(-) rename controller/src/test/java/org/jboss/as/controller/{operation => operations}/global/AbstractCollectionOperationsTestCase.java (98%) rename controller/src/test/java/org/jboss/as/controller/{operation => operations}/global/CollectionOperationsTestCase.java (99%) rename controller/src/test/java/org/jboss/as/controller/{operation => operations}/global/EnhancedSyntaxTestCase.java (99%) rename controller/src/test/java/org/jboss/as/controller/{operation => operations}/global/StorageRuntimeCollectionOperationsTestCase.java (99%) rename controller/src/test/java/org/jboss/as/controller/{operation => operations}/validation/ModelTypeValidatorUnitTestCase.java (98%) rename controller/src/test/java/org/jboss/as/controller/{operation => operations}/validation/ModuleNameValidatorTestCase.java (88%) diff --git a/controller/src/test/java/org/jboss/as/controller/operation/global/AbstractCollectionOperationsTestCase.java b/controller/src/test/java/org/jboss/as/controller/operations/global/AbstractCollectionOperationsTestCase.java similarity index 98% rename from controller/src/test/java/org/jboss/as/controller/operation/global/AbstractCollectionOperationsTestCase.java rename to controller/src/test/java/org/jboss/as/controller/operations/global/AbstractCollectionOperationsTestCase.java index 80e42e4f265..a4cfa956b92 100644 --- a/controller/src/test/java/org/jboss/as/controller/operation/global/AbstractCollectionOperationsTestCase.java +++ b/controller/src/test/java/org/jboss/as/controller/operations/global/AbstractCollectionOperationsTestCase.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.jboss.as.controller.operation.global; +package org.jboss.as.controller.operations.global; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.COMPOSITE; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.STEPS; @@ -19,8 +19,6 @@ import org.jboss.as.controller.PropertiesAttributeDefinition; import org.jboss.as.controller.ResourceDefinition; import org.jboss.as.controller.StringListAttributeDefinition; -import org.jboss.as.controller.operations.global.GlobalNotifications; -import org.jboss.as.controller.operations.global.GlobalOperationHandlers; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.test.AbstractControllerTestBase; import org.jboss.dmr.ModelNode; diff --git a/controller/src/test/java/org/jboss/as/controller/operation/global/CollectionOperationsTestCase.java b/controller/src/test/java/org/jboss/as/controller/operations/global/CollectionOperationsTestCase.java similarity index 99% rename from controller/src/test/java/org/jboss/as/controller/operation/global/CollectionOperationsTestCase.java rename to controller/src/test/java/org/jboss/as/controller/operations/global/CollectionOperationsTestCase.java index 202c681e158..a9901098181 100644 --- a/controller/src/test/java/org/jboss/as/controller/operation/global/CollectionOperationsTestCase.java +++ b/controller/src/test/java/org/jboss/as/controller/operations/global/CollectionOperationsTestCase.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.jboss.as.controller.operation.global; +package org.jboss.as.controller.operations.global; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE; diff --git a/controller/src/test/java/org/jboss/as/controller/operation/global/EnhancedSyntaxTestCase.java b/controller/src/test/java/org/jboss/as/controller/operations/global/EnhancedSyntaxTestCase.java similarity index 99% rename from controller/src/test/java/org/jboss/as/controller/operation/global/EnhancedSyntaxTestCase.java rename to controller/src/test/java/org/jboss/as/controller/operations/global/EnhancedSyntaxTestCase.java index 43a90e25403..ce02dc223c9 100644 --- a/controller/src/test/java/org/jboss/as/controller/operation/global/EnhancedSyntaxTestCase.java +++ b/controller/src/test/java/org/jboss/as/controller/operations/global/EnhancedSyntaxTestCase.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.jboss.as.controller.operation.global; +package org.jboss.as.controller.operations.global; import static org.jboss.as.controller.SimpleAttributeDefinitionBuilder.create; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.COMPOSITE; @@ -33,8 +33,6 @@ import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.StringListAttributeDefinition; import org.jboss.as.controller.descriptions.NonResolvingResourceDescriptionResolver; -import org.jboss.as.controller.operations.global.GlobalNotifications; -import org.jboss.as.controller.operations.global.GlobalOperationHandlers; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.test.AbstractControllerTestBase; import org.jboss.dmr.ModelNode; diff --git a/controller/src/test/java/org/jboss/as/controller/operation/global/StorageRuntimeCollectionOperationsTestCase.java b/controller/src/test/java/org/jboss/as/controller/operations/global/StorageRuntimeCollectionOperationsTestCase.java similarity index 99% rename from controller/src/test/java/org/jboss/as/controller/operation/global/StorageRuntimeCollectionOperationsTestCase.java rename to controller/src/test/java/org/jboss/as/controller/operations/global/StorageRuntimeCollectionOperationsTestCase.java index e87e3325778..aa713ca2a62 100644 --- a/controller/src/test/java/org/jboss/as/controller/operation/global/StorageRuntimeCollectionOperationsTestCase.java +++ b/controller/src/test/java/org/jboss/as/controller/operations/global/StorageRuntimeCollectionOperationsTestCase.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.jboss.as.controller.operation.global; +package org.jboss.as.controller.operations.global; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE; diff --git a/controller/src/test/java/org/jboss/as/controller/operation/validation/ModelTypeValidatorUnitTestCase.java b/controller/src/test/java/org/jboss/as/controller/operations/validation/ModelTypeValidatorUnitTestCase.java similarity index 98% rename from controller/src/test/java/org/jboss/as/controller/operation/validation/ModelTypeValidatorUnitTestCase.java rename to controller/src/test/java/org/jboss/as/controller/operations/validation/ModelTypeValidatorUnitTestCase.java index 4b5253c7a8d..f80b60845c1 100644 --- a/controller/src/test/java/org/jboss/as/controller/operation/validation/ModelTypeValidatorUnitTestCase.java +++ b/controller/src/test/java/org/jboss/as/controller/operations/validation/ModelTypeValidatorUnitTestCase.java @@ -2,7 +2,7 @@ * Copyright The WildFly Authors * SPDX-License-Identifier: Apache-2.0 */ -package org.jboss.as.controller.operation.validation; +package org.jboss.as.controller.operations.validation; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -12,7 +12,6 @@ import java.math.BigInteger; import org.jboss.as.controller.OperationFailedException; -import org.jboss.as.controller.operations.validation.ModelTypeValidator; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.jboss.dmr.ValueExpression; diff --git a/controller/src/test/java/org/jboss/as/controller/operation/validation/ModuleNameValidatorTestCase.java b/controller/src/test/java/org/jboss/as/controller/operations/validation/ModuleNameValidatorTestCase.java similarity index 88% rename from controller/src/test/java/org/jboss/as/controller/operation/validation/ModuleNameValidatorTestCase.java rename to controller/src/test/java/org/jboss/as/controller/operations/validation/ModuleNameValidatorTestCase.java index 89249d538df..98ce1a9f230 100644 --- a/controller/src/test/java/org/jboss/as/controller/operation/validation/ModuleNameValidatorTestCase.java +++ b/controller/src/test/java/org/jboss/as/controller/operations/validation/ModuleNameValidatorTestCase.java @@ -3,11 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.jboss.as.controller.operation.validation; +package org.jboss.as.controller.operations.validation; import org.jboss.as.controller.OperationFailedException; -import org.jboss.as.controller.operations.validation.ModuleNameValidator; -import org.jboss.as.controller.operations.validation.ParameterValidator; import org.jboss.dmr.ModelNode; import org.junit.Assert; import org.junit.Test;