@Test
  public void testBuild_permissions() throws IOException {
    Path testRoot = temporaryFolder.getRoot().toPath();
    Path folder = Files.createDirectories(testRoot.resolve("files1"));
    Path fileA = createFile(testRoot, "fileA", "abc", 54321);
    Path fileB = createFile(testRoot, "fileB", "def", 54321);

    Blob blob =
        new ReproducibleLayerBuilder(
                ImmutableList.of(
                    defaultLayerEntry(fileA, AbsoluteUnixPath.get("/somewhere/fileA")),
                    new FileEntry(
                        fileB,
                        AbsoluteUnixPath.get("/somewhere/fileB"),
                        FilePermissions.fromOctalString("123"),
                        FileEntriesLayer.DEFAULT_MODIFICATION_TIME),
                    new FileEntry(
                        folder,
                        AbsoluteUnixPath.get("/somewhere/folder"),
                        FilePermissions.fromOctalString("456"),
                        FileEntriesLayer.DEFAULT_MODIFICATION_TIME)))
            .build();

    Path tarFile = temporaryFolder.newFile().toPath();
    try (OutputStream out = new BufferedOutputStream(Files.newOutputStream(tarFile))) {
      blob.writeTo(out);
    }

    try (TarArchiveInputStream in = new TarArchiveInputStream(Files.newInputStream(tarFile))) {
      // Root folder (default folder permissions)
      assertThat(in.getNextTarEntry().getMode()).isEqualTo(040755);
      // fileA (default file permissions)
      assertThat(in.getNextTarEntry().getMode()).isEqualTo(0100644);
      // fileB (custom file permissions)
      assertThat(in.getNextTarEntry().getMode()).isEqualTo(0100123);
      // folder (custom folder permissions)
      assertThat(in.getNextTarEntry().getMode()).isEqualTo(040456);
    }
  }
Verifies that the next {@link TarArchiveEntry} in the {@link TarArchiveInputStream} is a
directory with correct permissions.

@param tarArchiveInputStream the {@link TarArchiveInputStream} to read from
@param expectedExtractionPath the expected extraction path of the next entry
@throws IOException if an I/O exception occurs
jib-core/src/test/java/com/google/cloud/tools/jib/image/ReproducibleLayerBuilderTest.java