-
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.
When copying the local frontend files remove any read-only flags from the copies. fixes #12711
- Loading branch information
Showing
2 changed files
with
60 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
55 changes: 55 additions & 0 deletions
55
...-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,55 @@ | ||
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()); | ||
|
||
Assert.assertFalse("Should not be able to write read-only file", | ||
readOnly.canWrite()); | ||
return sourceFolder; | ||
} | ||
} |