forked from apache/struts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a constant to control when proxy can be accessed
- Loading branch information
Showing
7 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
core/src/test/java/com/opensymphony/xwork2/ognl/SecurityMemberAccessProxyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.opensymphony.xwork2.ognl; | ||
|
||
import java.lang.reflect.Member; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import com.opensymphony.xwork2.ActionProxy; | ||
import com.opensymphony.xwork2.XWorkTestCase; | ||
import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; | ||
|
||
public class SecurityMemberAccessProxyTest extends XWorkTestCase { | ||
private Map<String, Object> context; | ||
|
||
@Override | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
|
||
context = new HashMap<>(); | ||
// Set up XWork | ||
XmlConfigurationProvider provider = new XmlConfigurationProvider("com/opensymphony/xwork2/spring/actionContext-xwork.xml"); | ||
container.inject(provider); | ||
loadConfigurationProviders(provider); | ||
} | ||
|
||
public void testProxyAccessIsBlocked() throws Exception { | ||
ActionProxy proxy = actionProxyFactory.createActionProxy(null, | ||
"chaintoAOPedTestSubBeanAction", null, context); | ||
|
||
SecurityMemberAccess sma = new SecurityMemberAccess(false); | ||
sma.setDisallowProxyMemberAccess(true); | ||
|
||
Member member = proxy.getAction().getClass().getMethod("isExposeProxy"); | ||
|
||
boolean accessible = sma.isAccessible(context, proxy.getAction(), member, ""); | ||
assertFalse(accessible); | ||
} | ||
|
||
public void testProxyAccessIsAccessible() throws Exception { | ||
ActionProxy proxy = actionProxyFactory.createActionProxy(null, | ||
"chaintoAOPedTestSubBeanAction", null, context); | ||
|
||
SecurityMemberAccess sma = new SecurityMemberAccess(false); | ||
|
||
Member member = proxy.getAction().getClass().getMethod("isExposeProxy"); | ||
|
||
boolean accessible = sma.isAccessible(context, proxy.getAction(), member, ""); | ||
assertTrue(accessible); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters