-
-
Notifications
You must be signed in to change notification settings - Fork 537
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
XWIKI-19558: Only load vm templates in xpart.vm
* Add a page test for xpart.vm.
- Loading branch information
Showing
2 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...-platform-web/xwiki-platform-web-templates/src/test/java/org/xwiki/web/XPartPageTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /* | ||
| * See the NOTICE file distributed with this work for additional | ||
| * information regarding copyright ownership. | ||
| * | ||
| * This is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU Lesser General Public License as | ||
| * published by the Free Software Foundation; either version 2.1 of | ||
| * the License, or (at your option) any later version. | ||
| * | ||
| * This software is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this software; if not, write to the Free | ||
| * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
| */ | ||
| package org.xwiki.web; | ||
|
|
||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.xwiki.template.TemplateManager; | ||
| import org.xwiki.test.page.PageTest; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| /** | ||
| * Tests the {@code xpart.vm} template. | ||
| * | ||
| * @version $Id$ | ||
| * @since 14.3RC1 | ||
| * @since 13.10.5 | ||
| */ | ||
| class XPartPageTest extends PageTest | ||
| { | ||
| private static final String X_PART_VM = "xpart.vm"; | ||
|
|
||
| private static final String VM_PARAMETER = "vm"; | ||
|
|
||
| private TemplateManager templateManager; | ||
|
|
||
| @BeforeEach | ||
| void setUp() throws Exception | ||
| { | ||
| this.templateManager = this.componentManager.getInstance(TemplateManager.class); | ||
| this.request.put("xpage", "xpart"); | ||
| } | ||
|
|
||
| @Test | ||
| void renderRegisterTemplate() throws Exception | ||
| { | ||
| this.request.put(VM_PARAMETER, "register.vm"); | ||
| String result = this.templateManager.render(X_PART_VM); | ||
| assertTrue(result.contains("<form id=\"register\"")); | ||
| } | ||
|
|
||
| @Test | ||
| void renderForbiddenTemplate() throws Exception | ||
| { | ||
| this.request.put(VM_PARAMETER, "distribution/firstadminuser.wiki"); | ||
| String result = this.templateManager.render(X_PART_VM); | ||
| assertEquals("Invalid template.", result.trim()); | ||
| } | ||
| } |