Add metric for content-length header distribution

This commit is contained in:
Chris Eager
2021-08-05 17:21:48 -05:00
committed by Chris Eager
parent d1ada7f998
commit 3e01bc1174
3 changed files with 75 additions and 1 deletions

View File

@@ -0,0 +1,32 @@
/*
* Copyright 2021 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.whispersystems.textsecuregcm.filters;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import javax.ws.rs.container.ContainerRequestContext;
import org.junit.jupiter.api.Test;
import org.whispersystems.textsecuregcm.metrics.TrafficSource;
class ContentLengthFilterTest {
@Test
void testFilter() throws Exception {
final ContentLengthFilter contentLengthFilter = new ContentLengthFilter(TrafficSource.WEBSOCKET);
final ContainerRequestContext requestContext = mock(ContainerRequestContext.class);
when(requestContext.getLength()).thenReturn(-1);
when(requestContext.getLength()).thenReturn(Integer.MAX_VALUE);
when(requestContext.getLength()).thenThrow(RuntimeException.class);
contentLengthFilter.filter(requestContext);
contentLengthFilter.filter(requestContext);
contentLengthFilter.filter(requestContext);
}
}