@Test
  public void postProcessQuotaManagerTest() throws Exception {
    HostLevelThrottler quotaManager = Mockito.mock(HostLevelThrottler.class);
    FrontendConfig frontendConfig = new FrontendConfig(new VerifiableProperties(new Properties()));
    AmbrySecurityService ambrySecurityService =
        new AmbrySecurityService(frontendConfig, new FrontendMetrics(new MetricRegistry(), frontendConfig),
            URL_SIGNING_SERVICE_FACTORY.getUrlSigningService(), quotaManager, QUOTA_MANAGER);
    // Everything should be good.
    Mockito.when(quotaManager.shouldThrottle(any())).thenReturn(false);
    for (int i = 0; i < 100; i++) {
      for (RestMethod restMethod : RestMethod.values()) {
        RestRequest restRequest = createRestRequest(restMethod, "/", null);
        ambrySecurityService.postProcessRequest(restRequest).get();
      }
    }
    // Requests should be denied.
    Mockito.when(quotaManager.shouldThrottle(any())).thenReturn(true);
    for (RestMethod restMethod : RestMethod.values()) {
      RestRequest restRequest = createRestRequest(restMethod, "/", null);
      try {
        ambrySecurityService.postProcessRequest(restRequest).get();
        Assert.fail("Should have failed.");
      } catch (Exception e) {
        Assert.assertEquals("Exception should be TooManyRequests", RestServiceErrorCode.TooManyRequests,
            ((RestServiceException) e.getCause()).getErrorCode());
      }
    }
  }
{@link AmbrySecurityService#postProcessRequest(RestRequest, Callback)})} should throw RestServiceException if rate
is more than expected. RestServiceErrorCode.TooManyRequests is expected in this case.
ambry-frontend/src/test/java/com/github/ambry/frontend/AmbrySecurityServiceTest.java