Skip to content

Commit

Permalink
Merge pull request #6271 from pferraro/WFCORE-7083
Browse files Browse the repository at this point in the history
WFCORE-7083 ModuleNameValidator fails if module name contains a dash
  • Loading branch information
yersan authored Dec 9, 2024
2 parents 50f662c + d4f13c7 commit 6a42b91
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> MODULE_NAME_TESTER = Pattern.compile("(?:^\\w+|\\w+\\.\\w+|\\w+\\Q\\:\\E\\w+)+(?:\\:(?:\\w+|\\w+\\.\\w+))?$").asMatchPredicate();
private static final Predicate<String> MODULE_NAME_TESTER = Pattern.compile("(?:^\\w+|\\w+[\\.\\-]\\w+|\\w+\\Q\\:\\E\\w+)+(?:\\:(?:\\w+|\\w+[\\.\\-]\\w+))?$").asMatchPredicate();

private ModuleNameValidator() {
super(ModelType.STRING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,6 +23,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")));
Expand Down

0 comments on commit 6a42b91

Please sign in to comment.