1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.velocity.internal.util; |
21 |
|
|
22 |
|
import org.junit.Assert; |
23 |
|
import org.junit.Rule; |
24 |
|
import org.junit.Test; |
25 |
|
import org.xwiki.test.LogRule; |
26 |
|
|
27 |
|
|
28 |
|
@link |
29 |
|
|
30 |
|
@version |
31 |
|
@since |
32 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.5 |
|
33 |
|
public class RestrictParseLocationEventHandlerTest |
34 |
|
{ |
35 |
|
private RestrictParseLocationEventHandler handler = new RestrictParseLocationEventHandler(); |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
40 |
2 |
@Rule public LogRule logRule = new LogRule() {{... |
41 |
2 |
record(LogLevel.WARN); |
42 |
2 |
recordLoggingForType(RestrictParseLocationEventHandler.class); |
43 |
|
}}; |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
45 |
1 |
@Test... |
46 |
|
public void includeEventWhenAllowedPath() |
47 |
|
{ |
48 |
1 |
Assert.assertEquals("Wrong template returned", |
49 |
|
"/templates/xwikivars.vm", this.handler.includeEvent("xwikivars.vm", "xwiki:Main.WebHome", "parse")); |
50 |
|
} |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
52 |
1 |
@Test... |
53 |
|
public void includeEventWhenIllegalPath() |
54 |
|
{ |
55 |
1 |
Assert.assertNull("Template shouldn't have been returned", |
56 |
|
this.handler.includeEvent("../WEB-INF/xwiki.cfg", "xwiki:Main.WebHome", "parse")); |
57 |
|
|
58 |
1 |
Assert.assertEquals(1, this.logRule.size()); |
59 |
1 |
Assert.assertTrue(this.logRule.contains( |
60 |
|
"Direct access to template file [/WEB-INF/xwiki.cfg] refused. Possible break-in attempt!")); |
61 |
|
} |
62 |
|
} |