Permalink
Show file tree
Hide file tree
3 changes: 3 additions & 0 deletions
3
...tachment/xwiki-platform-attachment-api/src/main/resources/ApplicationResources.properties
7 changes: 3 additions & 4 deletions
7
...-attachment/xwiki-platform-attachment-api/src/main/resources/templates/attachment/move.vm
12 changes: 7 additions & 5 deletions
12
...hment/xwiki-platform-attachment-api/src/main/resources/templates/attachment/moveStatus.vm
62 changes: 44 additions & 18 deletions
62
...chment/xwiki-platform-attachment-api/src/main/resources/templates/attachment/moveStep1.vm
12 changes: 8 additions & 4 deletions
12
...iki-platform-attachment-api/src/main/resources/templates/attachment/refactoring_macros.vm
20 changes: 15 additions & 5 deletions
20
...chment/xwiki-platform-attachment-api/src/test/java/org/xwiki/attachment/MovePageTest.java
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
XWIKI-19667: The move attachment form is missing escaping and some tr…
…anslations
- Loading branch information
1 parent
55721e2
commit fbc4bfb
Showing
9 changed files
with
400 additions
and
36 deletions.
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
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
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
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
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
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
105 changes: 105 additions & 0 deletions
105
...xwiki-platform-attachment-api/src/test/java/org/xwiki/attachment/MoveStatusPagesTest.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,105 @@ | ||
| /* | ||
| * 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.attachment; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.jsoup.Jsoup; | ||
| import org.jsoup.nodes.Document; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.mockito.Mock; | ||
| import org.xwiki.job.Request; | ||
| import org.xwiki.job.event.status.JobProgress; | ||
| import org.xwiki.job.event.status.JobStatus; | ||
| import org.xwiki.job.script.JobScriptService; | ||
| import org.xwiki.script.service.ScriptService; | ||
| import org.xwiki.template.TemplateManager; | ||
| import org.xwiki.template.script.TemplateScriptService; | ||
| import org.xwiki.test.annotation.ComponentList; | ||
| import org.xwiki.test.page.HTML50ComponentList; | ||
| import org.xwiki.test.page.PageTest; | ||
| import org.xwiki.test.page.XWikiSyntax21ComponentList; | ||
| import org.xwiki.xml.internal.html.filter.ControlCharactersFilter; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.verify; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| /** | ||
| * Test of the macros provided by {@code moveStatus.vm}. | ||
| * | ||
| * @version $Id$ | ||
| * @since 14.4RC1 | ||
| */ | ||
| @HTML50ComponentList | ||
| @XWikiSyntax21ComponentList | ||
| @ComponentList({ | ||
| ControlCharactersFilter.class, | ||
| TemplateScriptService.class | ||
| }) | ||
| class MoveStatusPagesTest extends PageTest | ||
| { | ||
| private static final String MOVE_STATUS_TEMPLATE = "attachment/moveStatus.vm"; | ||
|
|
||
| private TemplateManager templateManager; | ||
|
|
||
| @Mock | ||
| private JobScriptService jobScriptService; | ||
|
|
||
| @BeforeEach | ||
| void setUp() throws Exception | ||
| { | ||
| this.templateManager = this.oldcore.getMocker().getInstance(TemplateManager.class); | ||
| this.componentManager.registerComponent(ScriptService.class, "job", this.jobScriptService); | ||
| } | ||
|
|
||
| @Test | ||
| void renderScriptStatusUnknown() throws Exception | ||
| { | ||
| this.request.put("moveId", "42"); | ||
| Document render = Jsoup.parse(this.templateManager.render(MOVE_STATUS_TEMPLATE)); | ||
| assertEquals("attachment.move.status.notFound", render.select(".errormessage").text()); | ||
| verify(this.jobScriptService).getJobStatus(List.of("refactoring", "moveAttachment", "42")); | ||
| } | ||
|
|
||
| @Test | ||
| void renderScriptActionGet() throws Exception | ||
| { | ||
| JobStatus jobStatus = mock(JobStatus.class); | ||
| Request request = mock(Request.class); | ||
| JobProgress jobProgress = mock(JobProgress.class); | ||
|
|
||
| when(request.getId()).thenReturn(List.of("rq", "id")); | ||
| when(jobProgress.getOffset()).thenReturn(10d); | ||
| when(jobStatus.getRequest()).thenReturn(request); | ||
| when(jobStatus.getState()).thenReturn(JobStatus.State.RUNNING); | ||
| when(jobStatus.getProgress()).thenReturn(jobProgress); | ||
| when(this.jobScriptService.getJobStatus(List.of("refactoring", "moveAttachment", "42"))) | ||
| .thenReturn(jobStatus); | ||
| this.request.put("moveId", "42"); | ||
| this.context.setAction("get"); | ||
| assertEquals( | ||
| "{\"id\":[\"rq\",\"id\"],\"state\":\"RUNNING\",\"progress\":{\"offset\":10.0}," | ||
| + "\"log\":{\"offset\":0,\"items\":[]},\"message\":\" \",\"questionTimeLeft\":0}", | ||
| this.templateManager.render(MOVE_STATUS_TEMPLATE).trim()); | ||
| } | ||
| } |
Oops, something went wrong.