private void verifySignedUrl(AmbryUrlSigningService signer, String url, RestMethod restMethod, String randomHeaderVal,
      long maxUploadSize, long blobTtl, boolean chunkUploadSet) throws Exception {
    RestRequest signedRequest = getRequestFromUrl(restMethod, url);
    assertTrue("Request should be declared as signed", signer.isRequestSigned(signedRequest));
    signer.verifySignedRequest(signedRequest);
    Map<String, Object> args = signedRequest.getArgs();
    assertEquals("URL type not as expected", restMethod.name(), args.get(RestUtils.Headers.URL_TYPE).toString());
    assertEquals("Random header value is not as expected", randomHeaderVal, args.get(RANDOM_AMBRY_HEADER).toString());
    Object blobTtlVal = args.get(RestUtils.Headers.TTL);
    Object chunkUploadVal = args.get(RestUtils.Headers.CHUNK_UPLOAD);
    Object sessionVal = args.get(RestUtils.Headers.SESSION);
    String reservedMetadataId = (String) args.get(RestUtils.Headers.RESERVED_METADATA_ID);
    if (restMethod.equals(RestMethod.POST)) {
      assertEquals("Max upload size not as expected", maxUploadSize,
          Long.parseLong(args.get(RestUtils.Headers.MAX_UPLOAD_SIZE).toString()));
      if (blobTtl != Utils.Infinite_Time) {
        assertEquals("Blob TTL not as expected", blobTtl, Long.parseLong(blobTtlVal.toString()));
      }
      if (chunkUploadSet) {
        assertTrue("Chunk upload should be set", Boolean.valueOf(chunkUploadVal.toString()));
        assertNotNull("Session should be set", sessionVal);
        // ensure that the x-ambry-chunk-upload-session value is a valid UUID.
        UUID.fromString(sessionVal.toString());
        if (isReservedMetadataEnabled) {
          assertNotNull("Reserved metadata should be set", reservedMetadataId);
          try {
            new BlobId(reservedMetadataId, mockClusterMap);
          } catch (Exception exception) {
            fail(String.format("Invalid metadata blob id reserved. Exception: %s", exception.getMessage()));
          }
        }
      } else {
        assertNull("Chunk upload should not be set", chunkUploadVal);
        assertNull("Session should not be set", sessionVal);
        assertNull("Reserved metadata should be set", reservedMetadataId);
      }
    } else {
      assertNull("Blob TTL should not be set", blobTtlVal);
      assertNull("Chunk upload should not be set", chunkUploadVal);
      assertNull("Session should not be set", sessionVal);
      assertNull("Reserved metadata should be set", reservedMetadataId);
    }
  }
Verifies that a signed URL contains parameters as provided and passes verification.
@param signer the {@link AmbryUrlSigningService} to use.
@param url the signed URL.
@param restMethod the {@link RestMethod} intended by {@code url}.
@param randomHeaderVal the expected value of {@link #RANDOM_AMBRY_HEADER}.
@param maxUploadSize the expected value of {@link RestUtils.Headers#MAX_UPLOAD_SIZE}.
@param chunkUploadSet {@code true} if the signed URL should be a chunk upload URL.
@throws Exception
ambry-frontend/src/test/java/com/github/ambry/frontend/AmbryUrlSigningServiceTest.java