WW-4596 Fixes bug with overriding global-allowed-methods

This commit is contained in:
Lukasz Lenart
2016-02-04 11:00:04 +01:00
parent 857195c1b1
commit 0cc5fcaaa3
3 changed files with 33 additions and 12 deletions
@@ -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();
@@ -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"));
@@ -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>