private void doSecurityServiceExceptionTest(FrontendTestSecurityServiceFactory securityFactory, String exceptionMsg)
      throws InstantiationException, JSONException, RestServiceException {
    for (FrontendTestSecurityServiceFactory.Mode mode : FrontendTestSecurityServiceFactory.Mode.values()) {
      securityFactory.mode = mode;
      RestMethod[] restMethods;
      if (mode.equals(FrontendTestSecurityServiceFactory.Mode.ProcessResponse)) {
        restMethods = new RestMethod[]{RestMethod.GET, RestMethod.HEAD, RestMethod.POST, RestMethod.OPTIONS};
      } else if (mode.equals(FrontendTestSecurityServiceFactory.Mode.ProcessRequest)) {
        restMethods =
            new RestMethod[]{RestMethod.GET, RestMethod.HEAD, RestMethod.POST, RestMethod.DELETE, RestMethod.OPTIONS};
      } else if (mode.equals(FrontendTestSecurityServiceFactory.Mode.PostProcessRequest)) {
        restMethods = new RestMethod[]{RestMethod.GET, RestMethod.HEAD, RestMethod.POST, RestMethod.DELETE};
      } else {
        restMethods = RestMethod.values();
      }
      Router testRouter = new FrontendTestRouter(idConverterFactory);
      frontendRestRequestService =
          new FrontendRestRequestService(frontendConfig, frontendMetrics, testRouter, clusterMap, idConverterFactory,
              securityFactory, urlSigningService, idSigningService, testRouter.getIdConverter().getNamedBlobDb(),
              accountService, accountAndContainerInjector, datacenterName, hostname, clusterName, accountStatsStore,
              QUOTA_MANAGER);
      frontendRestRequestService.setupResponseHandler(responseHandler);
      frontendRestRequestService.start();
      doExternalServicesBadInputTest(restMethods, exceptionMsg,
          mode == FrontendTestSecurityServiceFactory.Mode.ProcessResponse);
    }
  }
Does the exception pipelining test for {@link SecurityService}.
@param securityFactory the {@link SecurityServiceFactory} to use to while creating {@link FrontendRestRequestService}.
@param exceptionMsg the expected exception message.
@throws InstantiationException
@throws JSONException
ambry-frontend/src/test/java/com/github/ambry/frontend/FrontendRestRequestServiceTest.java