Skip to content

Commit fba5ffc

Browse files
Fix FilePermissionsTests on Windows
See gh-26658
1 parent 8df6392 commit fba5ffc

File tree

1 file changed

+14
-0
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/io

1 file changed

+14
-0
lines changed

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/io/FilePermissionsTests.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@
2727
import java.util.Set;
2828

2929
import org.junit.jupiter.api.Test;
30+
import org.junit.jupiter.api.condition.DisabledOnOs;
31+
import org.junit.jupiter.api.condition.EnabledOnOs;
32+
import org.junit.jupiter.api.condition.OS;
3033
import org.junit.jupiter.api.io.TempDir;
3134

3235
import static org.assertj.core.api.Assertions.assertThat;
3336
import static org.assertj.core.api.Assertions.assertThatIOException;
3437
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
38+
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
3539

3640
/**
3741
* Tests for {@link FilePermissions}.
@@ -44,6 +48,7 @@ class FilePermissionsTests {
4448
Path tempDir;
4549

4650
@Test
51+
@DisabledOnOs(OS.WINDOWS)
4752
void umaskForPath() throws IOException {
4853
FileAttribute<Set<PosixFilePermission>> fileAttribute = PosixFilePermissions
4954
.asFileAttribute(PosixFilePermissions.fromString("rw-r-----"));
@@ -52,11 +57,20 @@ void umaskForPath() throws IOException {
5257
}
5358

5459
@Test
60+
@DisabledOnOs(OS.WINDOWS)
5561
void umaskForPathWithNonExistentFile() throws IOException {
5662
assertThatIOException()
5763
.isThrownBy(() -> FilePermissions.umaskForPath(Paths.get(this.tempDir.toString(), "does-not-exist")));
5864
}
5965

66+
@Test
67+
@EnabledOnOs(OS.WINDOWS)
68+
void umaskForPathOnWindowsFails() throws IOException {
69+
Path tempFile = Files.createTempFile("umask", null);
70+
assertThatIllegalStateException().isThrownBy(() -> FilePermissions.umaskForPath(tempFile))
71+
.withMessageContaining("Unsupported file type for retrieving Posix attributes");
72+
}
73+
6074
@Test
6175
void umaskForPathWithNullPath() throws IOException {
6276
assertThatIllegalArgumentException().isThrownBy(() -> FilePermissions.umaskForPath(null));

0 commit comments

Comments
 (0)