Repository: struts Updated Branches: refs/heads/master 857195c1b -> 0cc5fcaaa
WW-4596 Fixes bug with overriding global-allowed-methods Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/0cc5fcaa Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/0cc5fcaa Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/0cc5fcaa Branch: refs/heads/master Commit: 0cc5fcaaa3b2a5b100457a145ec67ba15a1845bc Parents: 857195c Author: Lukasz Lenart <lukaszlen...@apache.org> Authored: Thu Feb 4 11:00:04 2016 +0100 Committer: Lukasz Lenart <lukaszlen...@apache.org> Committed: Thu Feb 4 11:00:04 2016 +0100 ---------------------------------------------------------------------- .../providers/XmlConfigurationProvider.java | 1 - ...ConfigurationProviderAllowedMethodsTest.java | 38 +++++++++++++++----- .../providers/xwork-test-allowed-methods.xml | 6 ++-- 3 files changed, 33 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/0cc5fcaa/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java b/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java index b04cffb..c27f95b 100644 --- a/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java +++ b/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java @@ -862,7 +862,6 @@ public class XmlConfigurationProvider implements ConfigurationProvider { allowedMethods = packageContext.getGlobalAllowedMethods(); if (allowedMethodsEls.getLength() > 0) { - allowedMethods = new HashSet<>(); Node n = allowedMethodsEls.item(0).getFirstChild(); if (n != null) { String s = n.getNodeValue().trim(); http://git-wip-us.apache.org/repos/asf/struts/blob/0cc5fcaa/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderAllowedMethodsTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderAllowedMethodsTest.java b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderAllowedMethodsTest.java index 4b4460a..e5f397f 100644 --- a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderAllowedMethodsTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderAllowedMethodsTest.java @@ -29,38 +29,48 @@ public class XmlConfigurationProviderAllowedMethodsTest extends ConfigurationTes ActionConfig action = (ActionConfig) actionConfigs.get("Default"); assertEquals(1, action.getAllowedMethods().size()); assertTrue(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertTrue(action.isAllowedMethod("foo")); assertTrue(action.isAllowedMethod("bar")); assertTrue(action.isAllowedMethod("baz")); assertTrue(action.isAllowedMethod("xyz")); action = (ActionConfig) actionConfigs.get("Boring"); - assertEquals(0, action.getAllowedMethods().size()); + assertEquals(2, action.getAllowedMethods().size()); assertTrue(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertFalse(action.isAllowedMethod("foo")); assertFalse(action.isAllowedMethod("bar")); assertFalse(action.isAllowedMethod("baz")); assertFalse(action.isAllowedMethod("xyz")); action = (ActionConfig) actionConfigs.get("Foo"); - assertEquals(1, action.getAllowedMethods().size()); + assertEquals(3, action.getAllowedMethods().size()); assertTrue(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertTrue(action.isAllowedMethod("foo")); assertFalse(action.isAllowedMethod("bar")); assertFalse(action.isAllowedMethod("baz")); assertFalse(action.isAllowedMethod("xyz")); action = (ActionConfig) actionConfigs.get("Bar"); - assertEquals(2, action.getAllowedMethods().size()); + assertEquals(4, action.getAllowedMethods().size()); assertTrue(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertTrue(action.isAllowedMethod("foo")); assertTrue(action.isAllowedMethod("bar")); assertFalse(action.isAllowedMethod("baz")); assertFalse(action.isAllowedMethod("xyz")); action = (ActionConfig) actionConfigs.get("Baz"); - assertEquals(3, action.getAllowedMethods().size()); + assertEquals(5, action.getAllowedMethods().size()); assertFalse(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertTrue(action.isAllowedMethod("foo")); assertTrue(action.isAllowedMethod("bar")); assertTrue(action.isAllowedMethod("baz")); @@ -82,40 +92,50 @@ public class XmlConfigurationProviderAllowedMethodsTest extends ConfigurationTes assertEquals(5, actionConfigs.size()); ActionConfig action = (ActionConfig) actionConfigs.get("Default"); - assertEquals(0, action.getAllowedMethods().size()); + assertEquals(2, action.getAllowedMethods().size()); assertTrue(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertFalse(action.isAllowedMethod("foo")); assertFalse(action.isAllowedMethod("bar")); assertFalse(action.isAllowedMethod("baz")); assertFalse(action.isAllowedMethod("xyz")); action = (ActionConfig) actionConfigs.get("Boring"); - assertEquals(0, action.getAllowedMethods().size()); + assertEquals(2, action.getAllowedMethods().size()); assertTrue(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertFalse(action.isAllowedMethod("foo")); assertFalse(action.isAllowedMethod("bar")); assertFalse(action.isAllowedMethod("baz")); assertFalse(action.isAllowedMethod("xyz")); action = (ActionConfig) actionConfigs.get("Foo"); - assertEquals(1, action.getAllowedMethods().size()); + assertEquals(3, action.getAllowedMethods().size()); assertTrue(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertTrue(action.isAllowedMethod("foo")); assertFalse(action.isAllowedMethod("bar")); assertFalse(action.isAllowedMethod("baz")); assertFalse(action.isAllowedMethod("xyz")); action = (ActionConfig) actionConfigs.get("Bar"); - assertEquals(2, action.getAllowedMethods().size()); + assertEquals(4, action.getAllowedMethods().size()); assertTrue(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertTrue(action.isAllowedMethod("foo")); assertTrue(action.isAllowedMethod("bar")); assertFalse(action.isAllowedMethod("baz")); assertFalse(action.isAllowedMethod("xyz")); action = (ActionConfig) actionConfigs.get("Baz"); - assertEquals(3, action.getAllowedMethods().size()); + assertEquals(5, action.getAllowedMethods().size()); assertFalse(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertTrue(action.isAllowedMethod("foo")); assertTrue(action.isAllowedMethod("bar")); assertTrue(action.isAllowedMethod("baz")); http://git-wip-us.apache.org/repos/asf/struts/blob/0cc5fcaa/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-allowed-methods.xml ---------------------------------------------------------------------- diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-allowed-methods.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-allowed-methods.xml index 6741e66..c19ef52 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-allowed-methods.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-allowed-methods.xml @@ -1,10 +1,11 @@ <!DOCTYPE xwork PUBLIC - "-//Apache Struts//XWork 2.3//EN" - "http://struts.apache.org/dtds/xwork-2.3.dtd" + "-//Apache Struts//XWork 2.5//EN" + "http://struts.apache.org/dtds/xwork-2.5.dtd" > <xwork> <package name="default" strict-method-invocation="false"> + <global-allowed-methods>input,cancel</global-allowed-methods> <action name="Default"> </action> @@ -26,6 +27,7 @@ </package> <package name="strict" strict-method-invocation="true"> + <global-allowed-methods>input,cancel</global-allowed-methods> <action name="Default"> </action>