Set file permissions on all created test files

Closes gh-29551
pull/29667/head
Scott Frederick 3 years ago
parent 761bed6c48
commit 000cbfa2d9

@ -144,8 +144,9 @@ class DirectoryBuildpackTests {
} }
private void writeBuildpackDescriptor() throws IOException { private void writeBuildpackDescriptor() throws IOException {
File descriptor = new File(this.buildpackDir, "buildpack.toml"); Path descriptor = Files.createFile(Paths.get(this.buildpackDir.getAbsolutePath(), "buildpack.toml"),
try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(descriptor.toPath()))) { PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-r--r--")));
try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(descriptor))) {
writer.println("[buildpack]"); writer.println("[buildpack]");
writer.println("id = \"example/buildpack1\""); writer.println("id = \"example/buildpack1\"");
writer.println("version = \"0.0.1\""); writer.println("version = \"0.0.1\"");
@ -157,15 +158,16 @@ class DirectoryBuildpackTests {
} }
private void writeScripts() throws IOException { private void writeScripts() throws IOException {
File binDirectory = new File(this.buildpackDir, "bin"); Path binDirectory = Files.createDirectory(Paths.get(this.buildpackDir.getAbsolutePath(), "bin"),
binDirectory.mkdirs(); PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr-xr-x")));
Path detect = Files.createFile(Paths.get(binDirectory.getAbsolutePath(), "detect"), binDirectory.toFile().mkdirs();
Path detect = Files.createFile(Paths.get(binDirectory.toString(), "detect"),
PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr--r--"))); PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr--r--")));
try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(detect))) { try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(detect))) {
writer.println("#!/usr/bin/env bash"); writer.println("#!/usr/bin/env bash");
writer.println("echo \"---> detect\""); 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--"))); PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr--r--")));
try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(build))) { try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(build))) {
writer.println("#!/usr/bin/env bash"); writer.println("#!/usr/bin/env bash");

Loading…
Cancel
Save