Repository: GoogleContainerTools/jib
File: jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/ZipUtilTest.java (Java)

Code before:
package com.google.cloud.tools.jib.plugins.common;

import static com.google.common.truth.Truth.assertThat;

import com.google.api.client.testing.http.FixedClock;
import com.google.common.io.Resources;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.FileTime;
import java.time.Instant;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;

/** Tests for {@link ZipUtil}. */
public class ZipUtilTest {

  @Rule public final TemporaryFolder tempFolder = new TemporaryFolder();
  public final FixedClock clock = new FixedClock();

  @Test
  public void testUnzip() throws URISyntaxException, IOException {
    verifyUnzip(tempFolder.getRoot().toPath());
  }

  @Test
  public void testUnzip_nonExistingDestination() throws URISyntaxException, IOException {
    Path destination = tempFolder.getRoot().toPath().resolve("non/exisiting");
    verifyUnzip(destination);

    Assert.assertTrue(Files.exists(destination));
  }

  @Test
  public void testZipSlipVulnerability_windows() throws URISyntaxException {
    Assume.assumeTrue(System.getProperty("os.name").startsWith("Windows"));

    Path archive =
        Paths.get(Resources.getResource("plugins-common/test-archives/zip-slip-win.zip").toURI());
    verifyZipSlipSafe(archive);
  }

  @Test
  public void testZipSlipVulnerability_unix() throws URISyntaxException {

Review comment (suggestion):
I don't think this is used? And not sure if `FixedCLock` from `com.google.api.client.testing.http` is a public API.

Code after:
package com.google.cloud.tools.jib.plugins.common;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;

import com.google.common.io.Resources;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.FileTime;
import java.time.Instant;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;

/** Tests for {@link ZipUtil}. */
public class ZipUtilTest {

  @Rule public final TemporaryFolder tempFolder = new TemporaryFolder();

  @Test
  public void testUnzip() throws URISyntaxException, IOException {
    verifyUnzip(tempFolder.getRoot().toPath());
  }

  @Test
  public void testUnzip_nonExistingDestination() throws URISyntaxException, IOException {
    Path destination = tempFolder.getRoot().toPath().resolve("non/exisiting");
    verifyUnzip(destination);

    Assert.assertTrue(Files.exists(destination));
  }

  @Test
  public void testZipSlipVulnerability_windows() throws URISyntaxException {
    Assume.assumeTrue(System.getProperty("os.name").startsWith("Windows"));

    Path archive =
        Paths.get(Resources.getResource("plugins-common/test-archives/zip-slip-win.zip").toURI());
    verifyZipSlipSafe(archive);
  }

  @Test
  public void testZipSlipVulnerability_unix() throws URISyntaxException {
    Assume.assumeFalse(System.getProperty("os.name").startsWith("Windows"));