From 000cbfa2d99c4778aef6906e4c8be3ef7a5a78fc Mon Sep 17 00:00:00 2001 From: Scott Frederick Date: Mon, 24 Jan 2022 16:19:20 -0600 Subject: [PATCH] Set file permissions on all created test files Closes gh-29551 --- .../platform/build/DirectoryBuildpackTests.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/DirectoryBuildpackTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/DirectoryBuildpackTests.java index 25c61a47b4..06da7e2499 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/DirectoryBuildpackTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/DirectoryBuildpackTests.java @@ -144,8 +144,9 @@ class DirectoryBuildpackTests { } private void writeBuildpackDescriptor() throws IOException { - File descriptor = new File(this.buildpackDir, "buildpack.toml"); - try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(descriptor.toPath()))) { + Path descriptor = Files.createFile(Paths.get(this.buildpackDir.getAbsolutePath(), "buildpack.toml"), + PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-r--r--"))); + try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(descriptor))) { writer.println("[buildpack]"); writer.println("id = \"example/buildpack1\""); writer.println("version = \"0.0.1\""); @@ -157,15 +158,16 @@ class DirectoryBuildpackTests { } private void writeScripts() throws IOException { - File binDirectory = new File(this.buildpackDir, "bin"); - binDirectory.mkdirs(); - Path detect = Files.createFile(Paths.get(binDirectory.getAbsolutePath(), "detect"), + Path binDirectory = Files.createDirectory(Paths.get(this.buildpackDir.getAbsolutePath(), "bin"), + PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr-xr-x"))); + binDirectory.toFile().mkdirs(); + Path detect = Files.createFile(Paths.get(binDirectory.toString(), "detect"), PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr--r--"))); try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(detect))) { writer.println("#!/usr/bin/env bash"); writer.println("echo \"---> detect\""); } - Path build = Files.createFile(Paths.get(binDirectory.getAbsolutePath(), "build"), + Path build = Files.createFile(Paths.get(binDirectory.toString(), "build"), PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr--r--"))); try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(build))) { writer.println("#!/usr/bin/env bash");