|
31 | 31 | import java.util.Map;
|
32 | 32 |
|
33 | 33 | import static org.junit.Assert.assertFalse;
|
| 34 | +import static org.junit.Assert.assertThrows; |
34 | 35 | import static org.junit.Assert.assertTrue;
|
35 | 36 |
|
36 | 37 | public class SecurityMemberAccessProxyTest extends XWorkJUnit4TestCase {
|
@@ -87,4 +88,91 @@ public void allowAllProxyAccess() {
|
87 | 88 | assertTrue(sma.isAccessible(context, proxy.getAction(), proxyObjectProxyMember, ""));
|
88 | 89 | assertTrue(sma.isAccessible(context, proxy.getAction(), proxyObjectNonProxyMember, ""));
|
89 | 90 | }
|
| 91 | + |
| 92 | + @Test |
| 93 | + public void nullTargetAndTargetAndMemberNotAllowed() { |
| 94 | + sma.useDisallowProxyObjectAccess(Boolean.TRUE.toString()); |
| 95 | + sma.useDisallowProxyMemberAccess(Boolean.TRUE.toString()); |
| 96 | + assertTrue(sma.isAccessible(context, null, proxyObjectProxyMember, "")); |
| 97 | + } |
| 98 | + |
| 99 | + @Test |
| 100 | + public void nullTargetAndTargetAllowedAndMemberNotAllowed() { |
| 101 | + sma.useDisallowProxyObjectAccess(Boolean.FALSE.toString()); |
| 102 | + sma.useDisallowProxyMemberAccess(Boolean.TRUE.toString()); |
| 103 | + assertTrue(sma.isAccessible(context, null, proxyObjectProxyMember, "")); |
| 104 | + } |
| 105 | + |
| 106 | + @Test |
| 107 | + public void nullTargetAndTargetAndMemberAllowed() { |
| 108 | + sma.useDisallowProxyObjectAccess(Boolean.FALSE.toString()); |
| 109 | + sma.useDisallowProxyMemberAccess(Boolean.FALSE.toString()); |
| 110 | + assertTrue(sma.isAccessible(context, null, proxyObjectProxyMember, "")); |
| 111 | + } |
| 112 | + |
| 113 | + @Test |
| 114 | + public void nullMemberAndTargetAndMemberNotAllowed() { |
| 115 | + sma.useDisallowProxyObjectAccess(Boolean.TRUE.toString()); |
| 116 | + sma.useDisallowProxyMemberAccess(Boolean.TRUE.toString()); |
| 117 | + Object action = proxy.getAction(); |
| 118 | + assertThrows("Member cannot be null!", IllegalArgumentException.class, |
| 119 | + () -> sma.isAccessible(context, action, null, "")); |
| 120 | + } |
| 121 | + |
| 122 | + @Test |
| 123 | + public void nullMemberAndTargetAllowedAndMemberNotAllowed() { |
| 124 | + sma.useDisallowProxyObjectAccess(Boolean.FALSE.toString()); |
| 125 | + sma.useDisallowProxyMemberAccess(Boolean.TRUE.toString()); |
| 126 | + Object action = proxy.getAction(); |
| 127 | + assertThrows("Member cannot be null!", IllegalArgumentException.class, |
| 128 | + () -> sma.isAccessible(context, action, null, "")); |
| 129 | + } |
| 130 | + |
| 131 | + @Test |
| 132 | + public void nullMemberAndTargetNotAllowedAndMemberAllowed() { |
| 133 | + sma.useDisallowProxyObjectAccess(Boolean.TRUE.toString()); |
| 134 | + sma.useDisallowProxyMemberAccess(Boolean.FALSE.toString()); |
| 135 | + Object action = proxy.getAction(); |
| 136 | + assertThrows("Member cannot be null!", IllegalArgumentException.class, |
| 137 | + () -> sma.isAccessible(context, action, null, "")); |
| 138 | + } |
| 139 | + |
| 140 | + @Test |
| 141 | + public void nullTargetAndMemberAndTargetAndMemberNotAllowed() { |
| 142 | + sma.useDisallowProxyObjectAccess(Boolean.TRUE.toString()); |
| 143 | + sma.useDisallowProxyMemberAccess(Boolean.TRUE.toString()); |
| 144 | + assertThrows("Member cannot be null!", IllegalArgumentException.class, |
| 145 | + () -> sma.isAccessible(context, null, null, "")); |
| 146 | + } |
| 147 | + |
| 148 | + @Test |
| 149 | + public void nullTargetAndMemberAndTargetNotAllowedAndMemberAllowed() { |
| 150 | + sma.useDisallowProxyObjectAccess(Boolean.TRUE.toString()); |
| 151 | + sma.useDisallowProxyMemberAccess(Boolean.FALSE.toString()); |
| 152 | + assertThrows("Member cannot be null!", IllegalArgumentException.class, |
| 153 | + () -> sma.isAccessible(context, null, null, "")); |
| 154 | + } |
| 155 | + |
| 156 | + @Test |
| 157 | + public void nullTargetAndMemberAndTargetAllowedAndMemberNotAllowed() { |
| 158 | + sma.useDisallowProxyObjectAccess(Boolean.FALSE.toString()); |
| 159 | + sma.useDisallowProxyMemberAccess(Boolean.TRUE.toString()); |
| 160 | + assertThrows("Member cannot be null!", IllegalArgumentException.class, |
| 161 | + () -> sma.isAccessible(context, null, null, "")); |
| 162 | + } |
| 163 | + |
| 164 | + @Test |
| 165 | + public void nullTargetAndMemberAndTargetAndMemberAllowed() { |
| 166 | + sma.useDisallowProxyObjectAccess(Boolean.FALSE.toString()); |
| 167 | + sma.useDisallowProxyMemberAccess(Boolean.FALSE.toString()); |
| 168 | + assertThrows("Member cannot be null!", IllegalArgumentException.class, |
| 169 | + () -> sma.isAccessible(context, null, null, "")); |
| 170 | + } |
| 171 | + |
| 172 | + @Test |
| 173 | + public void nullPropertyName() { |
| 174 | + sma.useDisallowProxyMemberAccess(Boolean.FALSE.toString()); |
| 175 | + Object action = proxy.getAction(); |
| 176 | + assertTrue(sma.isAccessible(context, action, proxyObjectProxyMember, null)); |
| 177 | + } |
90 | 178 | }
|
0 commit comments