Repository: struts
Updated Branches:
  refs/heads/master 23a0c9eb6 -> 954a29efc


WW-4596 Adds support to defined allowed methods with *


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/954a29ef
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/954a29ef
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/954a29ef

Branch: refs/heads/master
Commit: 954a29efcee7221bd00268857a98f833de4b5d60
Parents: 23a0c9e
Author: Lukasz Lenart <lukaszlen...@apache.org>
Authored: Wed Feb 3 10:38:13 2016 +0100
Committer: Lukasz Lenart <lukaszlen...@apache.org>
Committed: Wed Feb 3 10:38:13 2016 +0100

----------------------------------------------------------------------
 .../xwork2/config/entities/AllowedMethods.java       |  3 +++
 .../xwork2/config/entities/AllowedMethodsTest.java   | 15 +++++++++++++++
 2 files changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/954a29ef/core/src/main/java/com/opensymphony/xwork2/config/entities/AllowedMethods.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/com/opensymphony/xwork2/config/entities/AllowedMethods.java
 
b/core/src/main/java/com/opensymphony/xwork2/config/entities/AllowedMethods.java
index e8796b1..976117d 100644
--- 
a/core/src/main/java/com/opensymphony/xwork2/config/entities/AllowedMethods.java
+++ 
b/core/src/main/java/com/opensymphony/xwork2/config/entities/AllowedMethods.java
@@ -32,6 +32,9 @@ public class AllowedMethods {
             } else if (method.startsWith("regex:")) {
                 String pattern = method.substring(method.indexOf(":") + 1);
                 allowedMethods.add(new PatternAllowedMethod(pattern, method));
+            } else if (method.contains("*") && !method.startsWith("regex:")) {
+                String pattern = method.replaceAll("\\*", "(.*)");
+                allowedMethods.add(new PatternAllowedMethod(pattern, method));
             } else {
                 allowedMethods.add(new LiteralAllowedMethod(ret.toString()));
             }

http://git-wip-us.apache.org/repos/asf/struts/blob/954a29ef/core/src/test/java/com/opensymphony/xwork2/config/entities/AllowedMethodsTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/com/opensymphony/xwork2/config/entities/AllowedMethodsTest.java
 
b/core/src/test/java/com/opensymphony/xwork2/config/entities/AllowedMethodsTest.java
index 78f3094..607a9dc 100644
--- 
a/core/src/test/java/com/opensymphony/xwork2/config/entities/AllowedMethodsTest.java
+++ 
b/core/src/test/java/com/opensymphony/xwork2/config/entities/AllowedMethodsTest.java
@@ -37,6 +37,21 @@ public class AllowedMethodsTest extends TestCase {
         assertFalse(allowedMethods.isAllowed("someOtherMethod"));
     }
 
+    public void testWidlcardWithStarMethods() throws Exception {
+        // given
+        String method = "cancel*";
+        Set<String> literals = new HashSet<>();
+        literals.add(method);
+
+        // when
+        AllowedMethods allowedMethods = AllowedMethods.build(literals);
+
+        // then
+        assertEquals(1, allowedMethods.list().size());
+        assertTrue(allowedMethods.isAllowed("cancelAction"));
+        assertFalse(allowedMethods.isAllowed("startEvent"));
+    }
+
     public void testRegexMethods() throws Exception {
         // given
         String method = "regex:my([a-zA-Z].*)";

Reply via email to