| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.security.authorization; |
| 21 |
|
|
| 22 |
|
import org.junit.Before; |
| 23 |
|
import org.xwiki.security.authorization.internal.XWikiCachingRightService; |
| 24 |
|
import org.xwiki.test.annotation.AllComponents; |
| 25 |
|
|
| 26 |
|
import com.xpn.xwiki.XWikiContext; |
| 27 |
|
import com.xpn.xwiki.user.api.XWikiRightService; |
| 28 |
|
import com.xpn.xwiki.user.impl.xwiki.XWikiRightServiceImpl; |
| 29 |
|
|
| 30 |
|
import org.junit.Assert; |
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
@version |
| 37 |
|
@since |
| 38 |
|
|
| 39 |
|
@AllComponents |
| |
|
| 58.3% |
Uncovered Elements: 20 (48) |
Complexity: 13 |
Complexity Density: 0.37 |
|
| 40 |
|
public abstract class AbstractLegacyWikiTestCase extends AbstractWikiTestCase |
| 41 |
|
{ |
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
private XWikiRightServiceImpl legacyImpl; |
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
private XWikiCachingRightService cachingImpl; |
| 51 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 52 |
10 |
@Before... |
| 53 |
|
@Override |
| 54 |
|
public void setUp() throws Exception |
| 55 |
|
{ |
| 56 |
10 |
super.setUp(); |
| 57 |
|
|
| 58 |
10 |
this.legacyImpl = new XWikiRightServiceImpl(); |
| 59 |
10 |
this.cachingImpl = new XWikiCachingRightService(); |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
|
| 63 |
|
@param |
| 64 |
|
@param |
| 65 |
|
@param |
| 66 |
|
@param |
| 67 |
|
@param |
| 68 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 69 |
21 |
protected void assertAccessLevelTrue(String message, String accessLevel, String userName, String documentName,... |
| 70 |
|
XWikiContext ctx) throws Exception |
| 71 |
|
{ |
| 72 |
21 |
setContext(ctx); |
| 73 |
|
|
| 74 |
21 |
Assert.assertTrue("Old implementation: " + message, |
| 75 |
|
this.legacyImpl.hasAccessLevel(accessLevel, userName, documentName, ctx)); |
| 76 |
|
|
| 77 |
21 |
Assert.assertTrue("Caching implementation: " + message, |
| 78 |
|
this.cachingImpl.hasAccessLevel(accessLevel, userName, documentName, ctx)); |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
|
| 82 |
|
@param |
| 83 |
|
@param |
| 84 |
|
@param |
| 85 |
|
@param |
| 86 |
|
@param |
| 87 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 88 |
7 |
protected void assertAccessLevelFalse(String message, String accessLevel, String userName, String documentName,... |
| 89 |
|
XWikiContext ctx) throws Exception |
| 90 |
|
{ |
| 91 |
7 |
setContext(ctx); |
| 92 |
|
|
| 93 |
7 |
Assert.assertFalse("Old implementation: " + message, |
| 94 |
|
this.legacyImpl.hasAccessLevel(accessLevel, userName, documentName, ctx)); |
| 95 |
|
|
| 96 |
7 |
Assert.assertFalse("Caching implementation: " + message, |
| 97 |
|
this.cachingImpl.hasAccessLevel(accessLevel, userName, documentName, ctx)); |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
|
| 101 |
|
@param |
| 102 |
|
@param |
| 103 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 104 |
0 |
protected void assertAdminRightsTrue(String message, XWikiContext ctx) throws Exception... |
| 105 |
|
{ |
| 106 |
0 |
setContext(ctx); |
| 107 |
|
|
| 108 |
0 |
Assert.assertTrue("Old implementation: " + message, this.legacyImpl.hasAdminRights(ctx)); |
| 109 |
|
|
| 110 |
0 |
Assert.assertTrue("Caching implementation: " + message, this.cachingImpl.hasAdminRights(ctx)); |
| 111 |
|
} |
| 112 |
|
|
| 113 |
|
|
| 114 |
|
@param |
| 115 |
|
@param |
| 116 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 117 |
0 |
protected void assertAdminRightsFalse(String message, XWikiContext ctx) throws Exception... |
| 118 |
|
{ |
| 119 |
0 |
setContext(ctx); |
| 120 |
|
|
| 121 |
0 |
Assert.assertFalse("Old implementation: " + message, this.legacyImpl.hasAdminRights(ctx)); |
| 122 |
|
|
| 123 |
0 |
Assert.assertFalse("Caching implementation: " + message, this.cachingImpl.hasAdminRights(ctx)); |
| 124 |
|
} |
| 125 |
|
|
| 126 |
|
|
| 127 |
|
@param |
| 128 |
|
@param |
| 129 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 130 |
1 |
protected void assertAdminRightsFalseExpectedDifference(String message, XWikiContext ctx) throws Exception... |
| 131 |
|
{ |
| 132 |
1 |
setContext(ctx); |
| 133 |
|
|
| 134 |
1 |
Assert.assertTrue("Old implementation: " + message, this.legacyImpl.hasAdminRights(ctx)); |
| 135 |
|
|
| 136 |
1 |
Assert.assertFalse("Caching implementation: " + message, this.cachingImpl.hasAdminRights(ctx)); |
| 137 |
|
} |
| 138 |
|
|
| 139 |
|
|
| 140 |
|
@param |
| 141 |
|
@param |
| 142 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 143 |
0 |
protected void assertWikiAdminRightsTrue(String message, XWikiContext ctx) throws Exception... |
| 144 |
|
{ |
| 145 |
0 |
setContext(ctx); |
| 146 |
|
|
| 147 |
0 |
Assert.assertTrue("Old implementation: " + message, this.legacyImpl.hasWikiAdminRights(ctx)); |
| 148 |
|
|
| 149 |
0 |
Assert.assertTrue("Caching implementation: " + message, this.cachingImpl.hasWikiAdminRights(ctx)); |
| 150 |
|
} |
| 151 |
|
|
| 152 |
|
|
| 153 |
|
@param |
| 154 |
|
@param |
| 155 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 156 |
0 |
protected void assertWikiAdminRightsFalse(String message, XWikiContext ctx) throws Exception... |
| 157 |
|
{ |
| 158 |
0 |
setContext(ctx); |
| 159 |
|
|
| 160 |
0 |
Assert.assertFalse("Old implementation: " + message, this.legacyImpl.hasWikiAdminRights(ctx)); |
| 161 |
|
|
| 162 |
0 |
Assert.assertFalse("Caching implementation: " + message, this.cachingImpl.hasWikiAdminRights(ctx)); |
| 163 |
|
} |
| 164 |
|
|
| 165 |
|
|
| 166 |
|
@param |
| 167 |
|
@param |
| 168 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 169 |
1 |
protected void assertWikiAdminRightsFalseExpectedDifference(String message, XWikiContext ctx) throws Exception... |
| 170 |
|
{ |
| 171 |
1 |
setContext(ctx); |
| 172 |
|
|
| 173 |
1 |
Assert.assertTrue("Old implementation: " + message, this.legacyImpl.hasWikiAdminRights(ctx)); |
| 174 |
|
|
| 175 |
1 |
Assert.assertFalse("Caching implementation: " + message, this.cachingImpl.hasWikiAdminRights(ctx)); |
| 176 |
|
} |
| 177 |
|
|
| 178 |
|
|
| 179 |
|
@param |
| 180 |
|
@param |
| 181 |
|
@param |
| 182 |
|
@param |
| 183 |
|
@param |
| 184 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 185 |
0 |
protected void assertAccessLevelTrueExpectedDifference(String message, String accessLevel, String userName,... |
| 186 |
|
String documentName, XWikiContext ctx) throws Exception |
| 187 |
|
{ |
| 188 |
0 |
setContext(ctx); |
| 189 |
|
|
| 190 |
0 |
Assert.assertFalse("Old implementation is is expected to differ: " + message, |
| 191 |
|
this.legacyImpl.hasAccessLevel(accessLevel, userName, documentName, ctx)); |
| 192 |
|
|
| 193 |
0 |
Assert.assertTrue("Caching implementation: " + message, |
| 194 |
|
this.cachingImpl.hasAccessLevel(accessLevel, userName, documentName, ctx)); |
| 195 |
|
} |
| 196 |
|
|
| 197 |
|
|
| 198 |
|
@param |
| 199 |
|
@param |
| 200 |
|
@param |
| 201 |
|
@param |
| 202 |
|
@param |
| 203 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 204 |
2 |
protected void assertAccessLevelFalseExpectedDifference(String message, String accessLevel, String userName,... |
| 205 |
|
String documentName, XWikiContext ctx) throws Exception |
| 206 |
|
{ |
| 207 |
2 |
setContext(ctx); |
| 208 |
|
|
| 209 |
2 |
Assert.assertTrue("Old implementation is expected to differ: " + message, |
| 210 |
|
this.legacyImpl.hasAccessLevel(accessLevel, userName, documentName, ctx)); |
| 211 |
|
|
| 212 |
2 |
Assert.assertFalse("Caching implementation: " + message, |
| 213 |
|
this.cachingImpl.hasAccessLevel(accessLevel, userName, documentName, ctx)); |
| 214 |
|
} |
| 215 |
|
|
| 216 |
|
|
| 217 |
|
@return |
| 218 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 219 |
6 |
protected XWikiRightService getLegacyImpl()... |
| 220 |
|
{ |
| 221 |
6 |
return this.legacyImpl; |
| 222 |
|
} |
| 223 |
|
|
| 224 |
|
|
| 225 |
|
@return |
| 226 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 227 |
6 |
protected XWikiRightService getCachingImpl()... |
| 228 |
|
{ |
| 229 |
6 |
return this.cachingImpl; |
| 230 |
|
} |
| 231 |
|
} |