1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package org.xwiki.test.escaping; |
22 |
|
|
23 |
|
import java.io.IOException; |
24 |
|
import java.util.Map; |
25 |
|
|
26 |
|
import org.junit.AfterClass; |
27 |
|
import org.junit.BeforeClass; |
28 |
|
import org.junit.Test; |
29 |
|
import org.xwiki.test.escaping.framework.AbstractEscapingTest; |
30 |
|
import org.xwiki.test.escaping.framework.AbstractManualTest; |
31 |
|
import org.xwiki.test.escaping.framework.XMLEscapingValidator; |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
@version |
39 |
|
@since |
40 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (145) |
Complexity: 32 |
Complexity Density: 0.29 |
|
41 |
|
public class ManualTemplateTest extends AbstractManualTest |
42 |
|
{ |
43 |
|
|
44 |
|
|
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
46 |
1 |
@BeforeClass... |
47 |
|
public static void init() |
48 |
|
{ |
49 |
|
|
50 |
1 |
AbstractEscapingTest.setMultiLanguageMode(true); |
51 |
|
} |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
56 |
1 |
@AfterClass... |
57 |
|
public static void shutdown() |
58 |
|
{ |
59 |
|
|
60 |
1 |
AbstractEscapingTest.setMultiLanguageMode(false); |
61 |
|
} |
62 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
63 |
1 |
@Test... |
64 |
|
public void testVersionSummary() |
65 |
|
{ |
66 |
1 |
String space = "Test"; |
67 |
1 |
String page = "TestVersionSummary"; |
68 |
|
|
69 |
1 |
String url = createUrl("save", space, page, params(kv("title", "Test"), |
70 |
|
kv("content", "Test"), |
71 |
|
test("comment"), |
72 |
|
kv("action_save", "Save+%26+View"))); |
73 |
1 |
AbstractEscapingTest.getUrlContent(url); |
74 |
|
|
75 |
1 |
deleteAfterwards(space, page); |
76 |
|
|
77 |
|
|
78 |
1 |
checkUnderEscaping(createUrl(null, space, page, params(kv("viewer", "history"))), "Version summary"); |
79 |
|
} |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
81 |
1 |
@Test... |
82 |
|
public void testEditReflectedXSS() |
83 |
|
{ |
84 |
1 |
skipIfIgnored("templates/htmlheader.vm"); |
85 |
1 |
checkUnderEscaping(createUrl("edit", "Main", XMLEscapingValidator.getTestString(), null), "XWIKI-4758"); |
86 |
|
} |
87 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
88 |
1 |
@Test... |
89 |
|
public void testErrorTraceEscaping() |
90 |
|
{ |
91 |
1 |
skipIfIgnored("templates/exceptioninline.vm"); |
92 |
1 |
checkUnderEscaping(createUrl("viewrev", "Main", "WebHome", params(test("rev"))), "XWIKI-5170 error trace"); |
93 |
|
} |
94 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
95 |
1 |
@Test... |
96 |
|
public void testEditorEscaping() |
97 |
|
{ |
98 |
1 |
skipIfIgnored("templates/edit.vm"); |
99 |
|
|
100 |
1 |
checkUnderEscaping(createUrl("edit", "Main", "Page", params(test("editor"))), "XWIKI-5164 editor"); |
101 |
1 |
checkUnderEscaping(createUrl("edit", "Main", "Page", params(kv("editor", "wysiwyg"), test("section"))), |
102 |
|
"XWIKI-5164 section"); |
103 |
1 |
checkUnderEscaping(createUrl("edit", "Main", "Page", params(kv("editor", "wiki"), test("x-maximized"))), |
104 |
|
"XWIKI-5164 x-maximized"); |
105 |
|
} |
106 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
107 |
1 |
@Test... |
108 |
|
public void testAdminEditor() |
109 |
|
{ |
110 |
1 |
skipIfIgnored("templates/admin.vm"); |
111 |
1 |
checkUnderEscaping(createUrl("admin", "XWiki", "AdminSheet", params(test("editor"))), |
112 |
|
"XWIKI-5190 admin editor"); |
113 |
|
|
114 |
1 |
checkUnderEscaping(createUrl("view", "Main", "WebHome", params(kv("xpage", "admin"), test("editor"))), |
115 |
|
"XWIKI-5190 admin editor redirect"); |
116 |
|
} |
117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
118 |
1 |
@Test... |
119 |
|
public void testAdminSection() |
120 |
|
{ |
121 |
1 |
skipIfIgnored("templates/admin.vm"); |
122 |
|
|
123 |
1 |
checkUnderEscaping(createUrl("admin", "XWiki", "AdminSheet", params(test("section"))), |
124 |
|
"XWIKI-5190 admin section"); |
125 |
|
|
126 |
1 |
checkUnderEscaping(createUrl("view", "Main", "WebHome", params(kv("xpage", "admin"), test("section"))), |
127 |
|
"XWIKI-5190 admin section redirect"); |
128 |
|
} |
129 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
130 |
1 |
@Test... |
131 |
|
public void testAttachmentsInline() |
132 |
|
{ |
133 |
1 |
skipIfIgnored("templates/attachments*.vm"); |
134 |
|
|
135 |
1 |
checkUnderEscaping(createUrl("view", "Sandbox", "WebHome", params(kv("viewer", "attachments"), test("xredirect"))), |
136 |
|
"XWIKI-5191 attachments inline"); |
137 |
|
} |
138 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
139 |
1 |
@Test... |
140 |
|
public void testBrowseWysiwygSQL() throws IOException |
141 |
|
{ |
142 |
1 |
skipIfIgnored("templates/browsewysiwyg.vm"); |
143 |
|
|
144 |
1 |
String url = createUrl("view", "Sandbox", "WebHome", params(kv("xpage", "browsewysiwyg"), test("text"))); |
145 |
1 |
checkUnderEscaping(url, "XWIKI-5193 sql"); |
146 |
1 |
checkForErrorTrace(url); |
147 |
|
} |
148 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
149 |
1 |
@Test... |
150 |
|
public void testBrowseWysiwygPage() |
151 |
|
{ |
152 |
|
|
153 |
1 |
skipIfIgnored("templates/browsewysiwyg.vm"); |
154 |
|
|
155 |
1 |
createPage("Main", XMLEscapingValidator.getTestString(), XMLEscapingValidator.getTestString(), "Bla bla"); |
156 |
1 |
checkUnderEscaping(createUrl("view", "Main", "Test", params(template("browsewysiwyg"))), |
157 |
|
"XWIKI-5193 page"); |
158 |
|
} |
159 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
160 |
1 |
@Test... |
161 |
|
public void testWysiwygRecentViewsPage() |
162 |
|
{ |
163 |
1 |
skipIfIgnored("templates/recentdocwysiwyg.vm"); |
164 |
|
|
165 |
1 |
createPage("Main", XMLEscapingValidator.getTestString(), XMLEscapingValidator.getTestString(), "Bla bla"); |
166 |
1 |
checkUnderEscaping(createUrl("view", "Main", "Test", params(template("recentdocwysiwyg"))), |
167 |
|
"XWIKI-5193 recent docs"); |
168 |
|
} |
169 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
170 |
1 |
@Test... |
171 |
|
public void testSearchWysiwygSQL() throws IOException |
172 |
|
{ |
173 |
1 |
skipIfIgnored("templates/searchwysiwyg.vm"); |
174 |
|
|
175 |
1 |
String spaceUrl = createUrl("view", "Main", "Test", params(kv("xpage", "searchwysiwyg"), test("space"))); |
176 |
1 |
checkUnderEscaping(spaceUrl, "XWIKI-5344 sql space"); |
177 |
1 |
checkForErrorTrace(spaceUrl); |
178 |
|
|
179 |
1 |
String pageUrl = createUrl("view", "Main", "Test", params(kv("xpage", "searchwysiwyg"), test("page"))); |
180 |
1 |
checkUnderEscaping(pageUrl, "XWIKI-5344 sql page"); |
181 |
1 |
checkForErrorTrace(pageUrl); |
182 |
|
} |
183 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
184 |
1 |
@Test... |
185 |
|
public void testSearchWysiwygPageLink() |
186 |
|
{ |
187 |
1 |
skipIfIgnored("templates/searchwysiwyg.vm"); |
188 |
|
|
189 |
1 |
createPage("Main", XMLEscapingValidator.getTestString(), XMLEscapingValidator.getTestString(), "Bla bla"); |
190 |
1 |
checkUnderEscaping(createUrl("view", "Main", "Test", params(template("searchwysiwyg"))), |
191 |
|
"XWIKI-5344 page link"); |
192 |
|
} |
193 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
194 |
1 |
@Test... |
195 |
|
public void testLoginRedirect() |
196 |
|
{ |
197 |
1 |
skipIfIgnored("templates/login.vm"); |
198 |
|
|
199 |
1 |
setLoggedIn(false); |
200 |
1 |
try { |
201 |
1 |
checkUnderEscaping(createUrl("login", "XWiki", "XWikiLogin", params(test("xredirect"))), |
202 |
|
"XWIKI-5246 xredirect"); |
203 |
|
} finally { |
204 |
1 |
setLoggedIn(true); |
205 |
|
} |
206 |
|
} |
207 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
208 |
1 |
@Test... |
209 |
|
public void testLoginSrid() |
210 |
|
{ |
211 |
1 |
skipIfIgnored("templates/login.vm"); |
212 |
|
|
213 |
1 |
setLoggedIn(false); |
214 |
1 |
try { |
215 |
1 |
checkUnderEscaping(createUrl("login", "XWiki", "XWikiLogin", params(test("srid"))), |
216 |
|
"XWIKI-5246 srid"); |
217 |
|
} finally { |
218 |
1 |
setLoggedIn(true); |
219 |
|
} |
220 |
|
} |
221 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
222 |
1 |
@Test... |
223 |
|
public void testEditActions() |
224 |
|
{ |
225 |
1 |
skipIfIgnored("edit comment"); |
226 |
|
|
227 |
1 |
createPage("Main", XMLEscapingValidator.getTestString(), XMLEscapingValidator.getTestString(), "Bla bla"); |
228 |
1 |
checkUnderEscaping(createUrl("edit", "Main", "WebHome", params(kv("editor", "wiki"), test("comment"))), |
229 |
|
"edit comment"); |
230 |
|
} |
231 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
232 |
1 |
@Test... |
233 |
|
public void testCreateEditMode() |
234 |
|
{ |
235 |
1 |
skipIfIgnored("templates/create.vm"); |
236 |
1 |
checkUnderEscaping(createUrl("edit", "Main", XMLEscapingValidator.getTestString(), |
237 |
|
params(template("createinline"))), "XWIKI-5207 create inline"); |
238 |
1 |
checkUnderEscaping(createUrl("edit", "Main", XMLEscapingValidator.getTestString(), |
239 |
|
params(template("create"), kv("ajax", "1"))), "XWIKI-5207 create ajax"); |
240 |
|
} |
241 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
242 |
1 |
@Test... |
243 |
|
public void testCopySourcedoc() |
244 |
|
{ |
245 |
1 |
testCopy("sourcedoc"); |
246 |
|
} |
247 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
248 |
1 |
@Test... |
249 |
|
public void testCopyLanguage() |
250 |
|
{ |
251 |
1 |
testCopy("language"); |
252 |
|
} |
253 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
254 |
1 |
@Test... |
255 |
|
public void testCopyExistingPage() |
256 |
|
{ |
257 |
1 |
skipIfIgnored("templates/copy.vm"); |
258 |
|
|
259 |
1 |
createPage("Main", XMLEscapingValidator.getTestString(), "", "Bla bla"); |
260 |
1 |
checkUnderEscaping(createUrl("view", "Main", XMLEscapingValidator.getTestString(), |
261 |
|
params(kv("xpage", "copy"))), "XWIKI-5206 copy existing page"); |
262 |
|
} |
263 |
|
|
264 |
|
|
265 |
|
|
266 |
|
|
267 |
|
@param |
268 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
269 |
2 |
private void testCopy(String parameter)... |
270 |
|
{ |
271 |
2 |
skipIfIgnored("templates/copy.vm"); |
272 |
|
|
273 |
|
|
274 |
2 |
String url = createUrl(null, null, null, params(template("copy"), test("targetdoc"), test(parameter))); |
275 |
|
|
276 |
2 |
deleteAfterwards(null, XMLEscapingValidator.getTestString()); |
277 |
2 |
checkUnderEscaping(url, "\"" + parameter + "\""); |
278 |
|
} |
279 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 2 |
Complexity Density: 0.17 |
1PASS
|
|
280 |
1 |
@Test... |
281 |
|
public void testRename() |
282 |
|
{ |
283 |
1 |
skipIfIgnored("templates/rename.vm"); |
284 |
|
|
285 |
1 |
String[] tested = new String[] {"language", "sourcedoc", "targetdoc", |
286 |
|
"newPageName", "newSpaceName", "parameterNames"}; |
287 |
|
|
288 |
1 |
deleteAfterwards(null, XMLEscapingValidator.getTestString()); |
289 |
1 |
for (String parameter : tested) { |
290 |
|
|
291 |
6 |
createPage(null, "testRenameSource" + System.nanoTime(), "test", "test"); |
292 |
6 |
Map<String, String> params = params(template("rename"), kv("step", "2"), test(parameter)); |
293 |
|
|
294 |
6 |
if (!params.containsKey("newPageName")) { |
295 |
5 |
String page = "testRename" + System.nanoTime(); |
296 |
5 |
params.put("newPageName", page); |
297 |
|
|
298 |
5 |
deleteAfterwards(null, page); |
299 |
|
} |
300 |
6 |
String url = createUrl(null, null, null, params); |
301 |
6 |
checkUnderEscaping(url, "\"" + parameter + "\""); |
302 |
|
} |
303 |
|
} |
304 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
305 |
1 |
@Test... |
306 |
|
public void testRenameExistingTarget() |
307 |
|
{ |
308 |
1 |
skipIfIgnored("templates/rename.vm"); |
309 |
|
|
310 |
|
|
311 |
1 |
String space = "Test"; |
312 |
1 |
String page = "RenameTest"; |
313 |
1 |
createPage(space, page, "Title", "Content"); |
314 |
1 |
createPage(XMLEscapingValidator.getTestString(), XMLEscapingValidator.getTestString(), "Title", "Content"); |
315 |
|
|
316 |
1 |
String url = createUrl(null, space, page, params(template("rename"), kv("step", "2"), test("newSpaceName"), |
317 |
|
test("newPageName"))); |
318 |
1 |
checkUnderEscaping(url, "XWIKI-5442"); |
319 |
|
} |
320 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
321 |
1 |
@Test... |
322 |
|
public void testRenameSuccess() |
323 |
|
{ |
324 |
1 |
skipIfIgnored("templates/rename.vm"); |
325 |
|
|
326 |
|
|
327 |
1 |
String space = "Test"; |
328 |
1 |
String page = "RenameTest"; |
329 |
1 |
createPage(space, page, "Title", "Content"); |
330 |
|
|
331 |
1 |
String testTarget = "Target" + XMLEscapingValidator.getTestString(); |
332 |
|
|
333 |
1 |
testTarget = testTarget.replaceAll(">", ""); |
334 |
|
|
335 |
|
|
336 |
1 |
deleteAfterwards(testTarget, testTarget); |
337 |
|
|
338 |
1 |
String url = createUrl(null, space, page, params(template("rename"), kv("step", "2"), |
339 |
|
kv("newSpaceName", testTarget), kv("newPageName", testTarget))); |
340 |
1 |
checkUnderEscaping(url, "XWIKI-5442"); |
341 |
|
} |
342 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
343 |
1 |
@Test... |
344 |
|
public void testDelete() |
345 |
|
{ |
346 |
1 |
skipIfIgnored("templates/delete.vm"); |
347 |
|
|
348 |
|
|
349 |
1 |
checkUnderEscaping(createUrl("view", null, null, params(template("delete"), kv("id", "bla"), test("xredirect"))), |
350 |
|
"XWIKI-5239"); |
351 |
|
} |
352 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
353 |
1 |
@Test... |
354 |
|
public void testDeleteVersionsConfirm() |
355 |
|
{ |
356 |
1 |
skipIfIgnored("templates/deleteversionsconfirm.vm"); |
357 |
|
|
358 |
1 |
checkUnderEscaping(createUrl("view", null, null, params(template("deleteversionsconfirm"), test("rev1"), |
359 |
|
test("rev2"))), "XWIKI-5238"); |
360 |
|
} |
361 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
362 |
1 |
@Test... |
363 |
|
public void testSuggestHibquery() throws IOException |
364 |
|
{ |
365 |
1 |
skipIfIgnored("templates/suggest.vm"); |
366 |
|
|
367 |
1 |
testSuggest("AnnotationCode.AnnotationConfig", "annotationClass", "Hibquery"); |
368 |
|
} |
369 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
370 |
1 |
@Test... |
371 |
|
public void testSuggestDBTree() throws IOException |
372 |
|
{ |
373 |
1 |
skipIfIgnored("templates/suggest.vm"); |
374 |
|
|
375 |
1 |
testSuggest("Blog.BlogPostClass", "category", "DBTree"); |
376 |
|
} |
377 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
378 |
1 |
@Test... |
379 |
|
public void testSuggestStaticList() throws IOException |
380 |
|
{ |
381 |
1 |
skipIfIgnored("templates/suggest.vm"); |
382 |
|
|
383 |
1 |
testSuggest("XWiki.ConfigurableClass", "propertiesToShow", "StaticList"); |
384 |
|
} |
385 |
|
|
386 |
|
|
387 |
|
|
388 |
|
|
389 |
|
@param |
390 |
|
@param |
391 |
|
@param |
392 |
|
@throws |
393 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
394 |
3 |
private void testSuggest(String classname, String fieldname, String description) throws IOException... |
395 |
|
{ |
396 |
3 |
String[] tested = new String[] {"firCol", "input"}; |
397 |
3 |
for (String parameter : tested) { |
398 |
6 |
String url = createUrl("view", "Main", null, params(template("suggest"), |
399 |
|
kv("classname", classname), kv("fieldname", fieldname), |
400 |
|
kv("secCol", "doc.fullName';"), test(parameter))); |
401 |
6 |
checkUnderEscaping(url, "XWIKI-5450: " + description + " (\"" + parameter + "\")"); |
402 |
6 |
checkForErrorTrace(url); |
403 |
|
} |
404 |
|
} |
405 |
|
} |
406 |
|
|