@Test
  public void processRequestTest() throws Exception {
    //rest request being null
    TestUtils.assertException(IllegalArgumentException.class, () -> securityService.preProcessRequest(null).get(),
        null);
    TestUtils.assertException(IllegalArgumentException.class, () -> securityService.processRequest(null).get(), null);
    TestUtils.assertException(IllegalArgumentException.class, () -> securityService.postProcessRequest(null).get(),
        null);

    // without callbacks
    RestMethod[] methods =
        new RestMethod[]{RestMethod.POST, RestMethod.GET, RestMethod.DELETE, RestMethod.HEAD, RestMethod.OPTIONS,
            RestMethod.PUT};
    for (RestMethod restMethod : methods) {
      RestRequest restRequest = createRestRequest(restMethod, "/", null);
      securityService.preProcessRequest(restRequest).get();
      securityService.processRequest(restRequest).get();
      securityService.postProcessRequest(restRequest).get();
    }

    // with GET sub resources
    for (RestUtils.SubResource subResource : RestUtils.SubResource.values()) {
      RestRequest restRequest = createRestRequest(RestMethod.GET, "/sampleId/" + subResource, null);
      Account account = InMemAccountService.UNKNOWN_ACCOUNT;
      insertAccountAndContainer(restRequest, account, account.getContainerById(Container.UNKNOWN_CONTAINER_ID));
      securityService.preProcessRequest(restRequest).get();
      securityService.processRequest(restRequest).get();
      securityService.postProcessRequest(restRequest).get();
    }

    // with UrlSigningService denying the request
    URL_SIGNING_SERVICE_FACTORY.isRequestSigned = true;
    URL_SIGNING_SERVICE_FACTORY.verifySignedRequestException =
        new RestServiceException("Msg", RestServiceErrorCode.Unauthorized);
    testExceptionCasesProcessRequest(createRestRequest(RestMethod.GET, "/", null), RestServiceErrorCode.Unauthorized,
        false);

    URL_SIGNING_SERVICE_FACTORY.isRequestSigned = false;
    // security service closed
    securityService.close();
    for (RestMethod restMethod : methods) {
      testExceptionCasesProcessRequest(createRestRequest(restMethod, "/", null),
          RestServiceErrorCode.ServiceUnavailable, true);
    }
  }
Tests {@link AmbrySecurityService#processRequest(RestRequest, Callback)} for common as well as uncommon cases
@throws Exception
ambry-frontend/src/test/java/com/github/ambry/frontend/AmbrySecurityServiceTest.java