mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 15:48:03 +01:00
Include HTTP/2 stream idle timeouts in IOExceptionMapper
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.whispersystems.textsecuregcm.mappers;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.stream.Stream;
|
||||
import javax.ws.rs.core.Response;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
class IOExceptionMapperTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource
|
||||
void testExceptionParsing(final IOException exception, final int expectedStatus) {
|
||||
|
||||
try (Response response = new IOExceptionMapper().toResponse(exception)) {
|
||||
assertEquals(expectedStatus, response.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
static Stream<Arguments> testExceptionParsing() {
|
||||
return Stream.of(
|
||||
Arguments.of(new IOException(), 503),
|
||||
Arguments.of(new IOException(new TimeoutException("A timeout")), 503),
|
||||
Arguments.of(new IOException(new TimeoutException()), 503),
|
||||
Arguments.of(new IOException(new TimeoutException("Idle timeout 30000 ms elapsed")), 408),
|
||||
Arguments.of(new IOException(new TimeoutException("Idle timeout expired")), 408),
|
||||
Arguments.of(new IOException(new RuntimeException(new TimeoutException("Idle timeout expired"))), 503),
|
||||
Arguments.of(new IOException(new TimeoutException("Idle timeout of another kind expired")), 503)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user