@Test
  public void testRedirectionUrls()
      throws IOException, InterruptedException, GeneralSecurityException, URISyntaxException {
    // Sample query strings from
    // https://github.com/GoogleContainerTools/jib/issues/1986#issuecomment-547610104
    String url1 = "?id=301&_auth_=exp=1572285389~hmac=f0a387f0";
    String url2 = "?id=302&Signature=2wYOD0a%2BDAkK%2F9lQJUOuIpYti8o%3D&Expires=1569997614";
    String url3 = "?id=303&_auth_=exp=1572285389~hmac=f0a387f0";
    String url4 = "?id=307&Signature=2wYOD0a%2BDAkK%2F9lQJUOuIpYti8o%3D&Expires=1569997614";
    String url5 = "?id=308&_auth_=exp=1572285389~hmac=f0a387f0";

    String redirect301 =
        "HTTP/1.1 301 Moved Permanently\nLocation: " + url1 + "\nContent-Length: 0\n\n";
    String redirect302 = "HTTP/1.1 302 Found\nLocation: " + url2 + "\nContent-Length: 0\n\n";
    String redirect303 = "HTTP/1.1 303 See Other\nLocation: " + url3 + "\nContent-Length: 0\n\n";
    String redirect307 =
        "HTTP/1.1 307 Temporary Redirect\nLocation: " + url4 + "\nContent-Length: 0\n\n";
    String redirect308 =
        "HTTP/1.1 308 Permanent Redirect\nLocation: " + url5 + "\nContent-Length: 0\n\n";
    String ok200 = "HTTP/1.1 200 OK\nContent-Length:12\n\nHello World!";
    List<String> responses =
        Arrays.asList(redirect301, redirect302, redirect303, redirect307, redirect308, ok200);

    FailoverHttpClient httpClient = new FailoverHttpClient(true /*insecure*/, false, logger);
    try (TestWebServer server = new TestWebServer(false, responses, 1)) {
      httpClient.get(new URL(server.getEndpoint()), request);

      MatcherAssert.assertThat(
          server.getInputRead(),
          CoreMatchers.containsString("GET /?id=301&_auth_=exp=1572285389~hmac=f0a387f0 "));
      MatcherAssert.assertThat(
          server.getInputRead(),
          CoreMatchers.containsString(
              "GET /?id=302&Signature=2wYOD0a%2BDAkK%2F9lQJUOuIpYti8o%3D&Expires=1569997614 "));
      MatcherAssert.assertThat(
          server.getInputRead(),
          CoreMatchers.containsString("GET /?id=303&_auth_=exp=1572285389~hmac=f0a387f0 "));
      MatcherAssert.assertThat(
          server.getInputRead(),
          CoreMatchers.containsString(
              "GET /?id=307&Signature=2wYOD0a%2BDAkK%2F9lQJUOuIpYti8o%3D&Expires=1569997614 "));
      MatcherAssert.assertThat(
          server.getInputRead(),
          CoreMatchers.containsString("GET /?id=308&_auth_=exp=1572285389~hmac=f0a387f0 "));
    }
  }
Tests for {@link FailoverHttpClient} using an actual local server.
jib-core/src/test/java/com/google/cloud/tools/jib/http/WithServerFailoverHttpClientTest.java