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 java.util.ArrayList; |
23 |
|
import java.util.List; |
24 |
|
import java.util.Set; |
25 |
|
|
26 |
|
import org.junit.BeforeClass; |
27 |
|
import org.junit.runner.RunWith; |
28 |
|
import org.xwiki.model.EntityType; |
29 |
|
import org.xwiki.security.AbstractSecurityTestCase; |
30 |
|
import org.xwiki.test.isolation.IsolatedTestRunner; |
31 |
|
import org.xwiki.test.isolation.IsolatedClassPrefix; |
32 |
|
|
33 |
|
import static org.xwiki.security.authorization.RuleState.ALLOW; |
34 |
|
import static org.xwiki.security.authorization.RuleState.DENY; |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
@version |
40 |
|
@since |
41 |
|
|
42 |
|
@RunWith(IsolatedTestRunner.class) |
43 |
|
@IsolatedClassPrefix("org.xwiki.security") |
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 2 |
Complexity Density: 0.17 |
|
44 |
|
public abstract class AbstractAdditionalRightsTestCase extends AbstractSecurityTestCase |
45 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 9 |
Complexity Density: 0.69 |
|
46 |
|
private static class TestRightDescription implements RightDescription |
47 |
|
{ |
48 |
|
private String name; |
49 |
|
private RuleState defaultState; |
50 |
|
private RuleState tieResolution; |
51 |
|
private boolean override; |
52 |
|
private Set<Right> impliedRights; |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
54 |
11 |
TestRightDescription(String name, RuleState defaultState, RuleState tieResolution, boolean override)... |
55 |
|
{ |
56 |
11 |
this.name = name; |
57 |
11 |
this.defaultState = defaultState; |
58 |
11 |
this.tieResolution = tieResolution; |
59 |
11 |
this.override = override; |
60 |
|
} |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
62 |
2 |
TestRightDescription(String name, RuleState defaultState, RuleState tieResolution, boolean override,... |
63 |
|
Set<Right> impliedRights) |
64 |
|
{ |
65 |
2 |
this(name, defaultState, tieResolution, override); |
66 |
2 |
this.impliedRights = impliedRights; |
67 |
|
} |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
11 |
@Override... |
70 |
|
public String getName() |
71 |
|
{ |
72 |
11 |
return name; |
73 |
|
} |
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
75 |
11 |
@Override... |
76 |
|
public RuleState getDefaultState() |
77 |
|
{ |
78 |
11 |
return defaultState; |
79 |
|
} |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
81 |
11 |
@Override... |
82 |
|
public RuleState getTieResolutionPolicy() |
83 |
|
{ |
84 |
11 |
return tieResolution; |
85 |
|
} |
86 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
87 |
11 |
@Override... |
88 |
|
public boolean getInheritanceOverridePolicy() |
89 |
|
{ |
90 |
11 |
return override; |
91 |
|
} |
92 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
93 |
11 |
@Override... |
94 |
|
public Set<Right> getImpliedRights() |
95 |
|
{ |
96 |
11 |
return impliedRights; |
97 |
|
} |
98 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
99 |
11 |
@Override... |
100 |
|
public Set<EntityType> getTargetedEntityType() |
101 |
|
{ |
102 |
11 |
return Right.WIKI_SPACE_DOCUMENT; |
103 |
|
} |
104 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
105 |
11 |
@Override... |
106 |
|
public boolean isReadOnly() |
107 |
|
{ |
108 |
11 |
return false; |
109 |
|
} |
110 |
|
} |
111 |
|
|
112 |
|
protected static List<Right> allTestRights = new ArrayList<Right>(); |
113 |
|
|
114 |
|
protected static Right impliedTestRightsADT; |
115 |
|
protected static Right impliedTestRightsDAF; |
116 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
|
117 |
1 |
@BeforeClass... |
118 |
|
public static void oneTimeSetUp() |
119 |
|
{ |
120 |
1 |
allTestRights.add(getNewTestRight("AllowAllowTrue", ALLOW, ALLOW, true)); |
121 |
1 |
allTestRights.add(getNewTestRight("AllowAllowFalse", ALLOW, ALLOW, false)); |
122 |
1 |
allTestRights.add(getNewTestRight("AllowDenyTrue", ALLOW, DENY, true)); |
123 |
1 |
allTestRights.add(getNewTestRight("AllowDenyFalse", ALLOW, DENY, false)); |
124 |
1 |
allTestRights.add(getNewTestRight("DenyAllowTrue", DENY, ALLOW, true)); |
125 |
1 |
allTestRights.add(getNewTestRight("DenyAllowFalse", DENY, ALLOW, false)); |
126 |
1 |
allTestRights.add(getNewTestRight("DenyDenyTrue", DENY, DENY, true)); |
127 |
1 |
allTestRights.add(getNewTestRight("DenyDenyFalse", DENY, DENY, false)); |
128 |
|
|
129 |
1 |
Set<Right> allTestRightSet = new RightSet(allTestRights); |
130 |
|
|
131 |
1 |
impliedTestRightsADT = new Right(new TestRightDescription("impliedTestRightsADT", ALLOW, DENY, true, allTestRightSet)); |
132 |
1 |
impliedTestRightsDAF = new Right(new TestRightDescription("impliedTestRightsDAF", DENY, ALLOW, false, allTestRightSet)); |
133 |
|
} |
134 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
135 |
9 |
public static Right getNewTestRight(String name, RuleState defaultValue, RuleState tieResolution, boolean overridePolicy) {... |
136 |
9 |
return new Right(new TestRightDescription(name, defaultValue, tieResolution, overridePolicy)); |
137 |
|
} |
138 |
|
} |