This is an automated email from the ASF dual-hosted git repository. kusal pushed a commit to branch WW-5343-sec-extend in repository https://gitbox.apache.org/repos/asf/struts.git
commit 68f5584d9fbdedd3809f3267ded6f2b230145bdb Author: Kusal Kithul-Godage <g...@kusal.io> AuthorDate: Fri Nov 17 15:42:36 2023 +1100 WW-5343 Remove defunct test now that constant is required --- .../xwork2/ognl/OgnlValueStackTest.java | 48 ++-------------------- 1 file changed, 3 insertions(+), 45 deletions(-) diff --git a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java index 210f7ea8b..42cc4b110 100644 --- a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java @@ -118,7 +118,7 @@ public class OgnlValueStackTest extends XWorkTestCase { * @param allowStaticField new allowStaticField configuration * @return a new OgnlValueStackFactory with specified new configuration */ - private OgnlValueStackFactory reloadValueStackFactory(Boolean allowStaticField) { + private OgnlValueStackFactory reloadValueStackFactory(boolean allowStaticField) { try { reloadTestContainerConfiguration(allowStaticField); } catch (Exception ex) { @@ -1178,43 +1178,6 @@ public class OgnlValueStackTest extends XWorkTestCase { assertNull("accessed private field (result not null) ?", accessedValue); } - /** - * Test a raw OgnlValueStackFactory and OgnlValueStack generated by it - * when no static access flags are set (not present in configuration). - */ - public void testOgnlValueStackFromOgnlValueStackFactoryNoFlagsSet() { - OgnlValueStackFactory ognlValueStackFactory = reloadValueStackFactory(null); - OgnlValueStack ognlValueStack = (OgnlValueStack) ognlValueStackFactory.createValueStack(); - Object accessedValue; - - // An OgnlValueStackFactory using a container config with no static access flag values present - // (such as from a DefaultConfiguration vs. XWorkConfigurationProvider) should - // prevent staticMethodAccess AND prevent staticFieldAccess. - // Note: Under normal circumstances, explicit static access configuration flags should be present, - // but this specific check verifies what happens if those configuration flags are not present. - assertFalse("OgnlValueStackFactory staticFieldAccess (no flag present) not false?", ognlValueStackFactory.containerAllowsStaticFieldAccess()); - // An OgnlValueStack created from the above OgnlValueStackFactory should prevent public field access, - // and prevent non-public field access. It should also deny static method access. - accessedValue = ognlValueStack.findValue("@com.opensymphony.xwork2.ognl.OgnlValueStackTest@staticInteger100Method()"); - assertNull("able to access static method (result not null) ?", accessedValue); - accessedValue = ognlValueStack.findValue("@com.opensymphony.xwork2.ognl.OgnlValueStackTest@STATIC_FINAL_PUBLIC_ATTRIBUTE"); - assertNull("able to access static final public field (result not null) ?", accessedValue); - accessedValue = ognlValueStack.findValue("@com.opensymphony.xwork2.ognl.OgnlValueStackTest@STATIC_PUBLIC_ATTRIBUTE"); - assertNull("able to access static public field (result not null) ?", accessedValue); - accessedValue = ognlValueStack.findValue("@com.opensymphony.xwork2.ognl.OgnlValueStackTest@STATIC_FINAL_PACKAGE_ATTRIBUTE"); - assertNull("accessed final package field (result not null) ?", accessedValue); - accessedValue = ognlValueStack.findValue("@com.opensymphony.xwork2.ognl.OgnlValueStackTest@STATIC_PACKAGE_ATTRIBUTE"); - assertNull("accessed package field (result not null) ?", accessedValue); - accessedValue = ognlValueStack.findValue("@com.opensymphony.xwork2.ognl.OgnlValueStackTest@STATIC_FINAL_PROTECTED_ATTRIBUTE"); - assertNull("accessed final protected field (result not null) ?", accessedValue); - accessedValue = ognlValueStack.findValue("@com.opensymphony.xwork2.ognl.OgnlValueStackTest@STATIC_PROTECTED_ATTRIBUTE"); - assertNull("accessed protected field (result not null) ?", accessedValue); - accessedValue = ognlValueStack.findValue("@com.opensymphony.xwork2.ognl.OgnlValueStackTest@STATIC_FINAL_PRIVATE_ATTRIBUTE"); - assertNull("accessed final private field (result not null) ?", accessedValue); - accessedValue = ognlValueStack.findValue("@com.opensymphony.xwork2.ognl.OgnlValueStackTest@STATIC_PRIVATE_ATTRIBUTE"); - assertNull("accessed private field (result not null) ?", accessedValue); - } - /** * Test a raw OgnlValueStackFactory and OgnlValueStack generated by it * when static access flag is set to false. @@ -1283,17 +1246,12 @@ public class OgnlValueStackTest extends XWorkTestCase { assertNull("accessed private field (result not null) ?", accessedValue); } - private void reloadTestContainerConfiguration(Boolean allowStaticField) throws Exception { + private void reloadTestContainerConfiguration(boolean allowStaticField) throws Exception { loadConfigurationProviders(new StubConfigurationProvider() { @Override public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { - // null values simulate undefined (by removing). - // undefined values then should be evaluated to false - props.remove(StrutsConstants.STRUTS_ALLOW_STATIC_FIELD_ACCESS); - if (allowStaticField != null) { - props.setProperty(StrutsConstants.STRUTS_ALLOW_STATIC_FIELD_ACCESS, "" + allowStaticField); - } + props.setProperty(StrutsConstants.STRUTS_ALLOW_STATIC_FIELD_ACCESS, String.valueOf(allowStaticField)); } }); ognlUtil = container.getInstance(OgnlUtil.class);