private void testGetSubResource(BlobInfo blobInfo, RestUtils.SubResource subResource) throws Exception {
    MockRestResponseChannel restResponseChannel = new MockRestResponseChannel();
    RestRequest restRequest = createRestRequest(RestMethod.GET, "/sampleId/" + subResource, null);
    Pair<Account, Container> accountAndContainer = getAccountAndContainer(blobInfo.getBlobProperties());
    insertAccountAndContainer(restRequest, accountAndContainer.getFirst(), accountAndContainer.getSecond());
    securityService.processResponse(restRequest, restResponseChannel, blobInfo).get();
    Assert.assertEquals("ProcessResponse status should have been set ", ResponseStatus.Ok,
        restResponseChannel.getStatus());
    Assert.assertNotNull("Date has not been set", restResponseChannel.getHeader(RestUtils.Headers.DATE));
    Assert.assertEquals("Last Modified does not match creation time",
        RestUtils.toSecondsPrecisionInMs(blobInfo.getBlobProperties().getCreationTimeInMs()),
        RestUtils.getTimeFromDateString(restResponseChannel.getHeader(RestUtils.Headers.LAST_MODIFIED)).longValue());
    if (subResource.equals(RestUtils.SubResource.BlobInfo)) {
      verifyBlobPropertiesHeaders(blobInfo.getBlobProperties(), restResponseChannel);
      verifyAccountAndContainerHeaders(restResponseChannel, accountAndContainer.getFirst(),
          accountAndContainer.getSecond());
      Assert.assertEquals("LifeVersion mismatch", Short.toString(blobInfo.getLifeVersion()),
          restResponseChannel.getHeader(RestUtils.Headers.LIFE_VERSION));
    } else {
      verifyAbsenceOfHeaders(restResponseChannel, RestUtils.Headers.PRIVATE, RestUtils.Headers.TTL,
          RestUtils.Headers.SERVICE_ID, RestUtils.Headers.OWNER_ID, RestUtils.Headers.AMBRY_CONTENT_TYPE,
          RestUtils.Headers.CREATION_TIME, RestUtils.Headers.BLOB_SIZE, RestUtils.Headers.ACCEPT_RANGES,
          RestUtils.Headers.CONTENT_RANGE, RestUtils.Headers.LIFE_VERSION);
    }
    Map<String, String> userMetadata =
        blobInfo.getUserMetadata() != null ? RestUtils.buildUserMetadata(blobInfo.getUserMetadata()) : null;
    if (userMetadata == null && !(blobInfo.getUserMetadata().length == 0)) {
      Assert.assertTrue("Internal key " + RestUtils.InternalKeys.SEND_USER_METADATA_AS_RESPONSE_BODY + " should be set",
          (Boolean) restRequest.getArgs().get(RestUtils.InternalKeys.SEND_USER_METADATA_AS_RESPONSE_BODY));
    } else if (!(blobInfo.getUserMetadata().length == 0)) {
      Set<String> keysToNotPrefix = accountAndContainer.getSecond().getUserMetadataKeysToNotPrefixInResponse();
      for (Map.Entry<String, Object> entry : USER_METADATA.entrySet()) {
        String key = entry.getKey();
        String value = (String) entry.getValue();
        String keyWithoutPrefix = key.substring(RestUtils.Headers.USER_META_DATA_HEADER_PREFIX.length());
        if (keysToNotPrefix.contains(keyWithoutPrefix)) {
          Assert.assertEquals("Value of " + key + " not as expected", value,
              restResponseChannel.getHeader(keyWithoutPrefix));
        } else {
          Assert.assertEquals("Value of " + key + " not as expected", value, restResponseChannel.getHeader(key));
        }
      }
    }
  }
Tests GET of sub-resources.
@param subResource the {@link RestUtils.SubResource}  to test.
@throws Exception
ambry-frontend/src/test/java/com/github/ambry/frontend/AmbrySecurityServiceTest.java