-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
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
When copying the local frontend files remove any read-only flags from the copies. fixes #12711 Co-authored-by: caalador <[email protected]>
- Loading branch information
1 parent
bbfd1b0
commit 41e5f87
Showing
2 changed files
with
63 additions
and
0 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
53 changes: 53 additions & 0 deletions
53
...-server/src/test/java/com/vaadin/flow/server/frontend/TaskCopyLocalFrontendFilesTest.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,53 @@ | ||
package com.vaadin.flow.server.frontend; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
public class TaskCopyLocalFrontendFilesTest { | ||
|
||
@Rule | ||
public final TemporaryFolder temporaryFolder = new TemporaryFolder(); | ||
|
||
@Test | ||
public void directoryWithReadOnlyFile_copyIsNotReadOnly() | ||
throws IOException { | ||
final File sourceFolder = createReadOnlySource(); | ||
|
||
final File outFolder = temporaryFolder.newFolder("out"); | ||
|
||
TaskCopyLocalFrontendFiles.copyLocalResources(sourceFolder, outFolder); | ||
|
||
final File copiedReadOnly = new File(outFolder, "readOnly.txt"); | ||
Assert.assertTrue( | ||
"Copied files should be writable even when source is readOnly", | ||
copiedReadOnly.canWrite()); | ||
|
||
} | ||
|
||
@Test | ||
public void directoryWithReadOnlyFile_canCopyMultipleTimesToSource() | ||
throws IOException { | ||
final File sourceFolder = createReadOnlySource(); | ||
|
||
final File outFolder = temporaryFolder.newFolder("out"); | ||
|
||
TaskCopyLocalFrontendFiles.copyLocalResources(sourceFolder, outFolder); | ||
|
||
TaskCopyLocalFrontendFiles.copyLocalResources(sourceFolder, outFolder); | ||
} | ||
|
||
private File createReadOnlySource() throws IOException { | ||
final File sourceFolder = temporaryFolder.newFolder("source"); | ||
File readOnly = new File(sourceFolder, "readOnly.txt"); | ||
readOnly.createNewFile(); | ||
Assert.assertTrue("Could not make file read-only", | ||
readOnly.setReadOnly()); | ||
|
||
return sourceFolder; | ||
} | ||
} |