mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 00:38:02 +01:00
Add metric for content-length header distribution
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user