Search in sources :

Example 16 with Http2SslContextSpec

use of reactor.netty.http.Http2SslContextSpec in project reactor-netty by reactor.

the class HttpServerTests method testIssue1286ErrorResponse_ServerHTTP11AndH2ClientHTTP11AndH2.

@Test
void testIssue1286ErrorResponse_ServerHTTP11AndH2ClientHTTP11AndH2() throws Exception {
    Http2SslContextSpec serverCtx = Http2SslContextSpec.forServer(ssc.certificate(), ssc.privateKey());
    Http2SslContextSpec clientCtx = Http2SslContextSpec.forClient().configure(builder -> builder.trustManager(InsecureTrustManagerFactory.INSTANCE));
    doTestIssue1286(server -> server.protocol(HttpProtocol.H2, HttpProtocol.HTTP11).secure(spec -> spec.sslContext(serverCtx)), client -> client.protocol(HttpProtocol.H2, HttpProtocol.HTTP11).secure(spec -> spec.sslContext(clientCtx)), false, true);
}
Also used : Http2SslContextSpec(reactor.netty.http.Http2SslContextSpec) AttributeKey(io.netty.util.AttributeKey) HttpHeaders(io.netty.handler.codec.http.HttpHeaders) StepVerifier(reactor.test.StepVerifier) SNIHostName(javax.net.ssl.SNIHostName) AbortedException(reactor.netty.channel.AbortedException) DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) ChannelInboundHandlerAdapter(io.netty.channel.ChannelInboundHandlerAdapter) HttpMessage(io.netty.handler.codec.http.HttpMessage) ByteBufHolder(io.netty.buffer.ByteBufHolder) HttpClientCodec(io.netty.handler.codec.http.HttpClientCodec) TcpClient(reactor.netty.tcp.TcpClient) ConnectionObserver(reactor.netty.ConnectionObserver) Future(java.util.concurrent.Future) DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) BeforeAll(org.junit.jupiter.api.BeforeAll) Duration(java.time.Duration) DEFAULT_FORM_DECODER_SPEC(reactor.netty.http.server.HttpServerFormDecoderProvider.DEFAULT_FORM_DECODER_SPEC) Path(java.nio.file.Path) LoopResources(reactor.netty.resources.LoopResources) HttpObjectDecoder(io.netty.handler.codec.http.HttpObjectDecoder) HttpRequest(io.netty.handler.codec.http.HttpRequest) Context(reactor.util.context.Context) Executors(java.util.concurrent.Executors) CountDownLatch(java.util.concurrent.CountDownLatch) LineBasedFrameDecoder(io.netty.handler.codec.LineBasedFrameDecoder) Assertions.fail(org.assertj.core.api.Assertions.fail) NettyOutbound(reactor.netty.NettyOutbound) ReferenceCountUtil(io.netty.util.ReferenceCountUtil) GZIPOutputStream(java.util.zip.GZIPOutputStream) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) HttpClient(reactor.netty.http.client.HttpClient) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ChannelOption(io.netty.channel.ChannelOption) HttpProtocol(reactor.netty.http.HttpProtocol) Nullable(reactor.util.annotation.Nullable) ArrayList(java.util.ArrayList) InsecureTrustManagerFactory(io.netty.handler.ssl.util.InsecureTrustManagerFactory) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) ValueSource(org.junit.jupiter.params.provider.ValueSource) PrematureCloseException(reactor.netty.http.client.PrematureCloseException) SslContext(io.netty.handler.ssl.SslContext) Publisher(org.reactivestreams.Publisher) IOException(java.io.IOException) Mono(reactor.core.publisher.Mono) Field(java.lang.reflect.Field) ReferenceCounted(io.netty.util.ReferenceCounted) Channel(io.netty.channel.Channel) DefaultHttpContent(io.netty.handler.codec.http.DefaultHttpContent) DefaultEventExecutor(io.netty.util.concurrent.DefaultEventExecutor) Flux(reactor.core.publisher.Flux) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) FutureMono(reactor.netty.FutureMono) Paths(java.nio.file.Paths) SslContextBuilder(io.netty.handler.ssl.SslContextBuilder) HttpHeaderNames(io.netty.handler.codec.http.HttpHeaderNames) ConnectionProvider(reactor.netty.resources.ConnectionProvider) ServerCookieEncoder(io.netty.handler.codec.http.cookie.ServerCookieEncoder) HttpUtil(io.netty.handler.codec.http.HttpUtil) SocketAddress(java.net.SocketAddress) Http11SslContextSpec(reactor.netty.http.Http11SslContextSpec) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) ByteBufAllocator(io.netty.buffer.ByteBufAllocator) URISyntaxException(java.net.URISyntaxException) BiFunction(java.util.function.BiFunction) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Http2SslContextSpec(reactor.netty.http.Http2SslContextSpec) TimeoutException(java.util.concurrent.TimeoutException) BaseHttpTest(reactor.netty.BaseHttpTest) Random(java.util.Random) Unpooled(io.netty.buffer.Unpooled) GlobalEventExecutor(io.netty.util.concurrent.GlobalEventExecutor) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) TransportConfig(reactor.netty.transport.TransportConfig) ServerCookieDecoder(io.netty.handler.codec.http.cookie.ServerCookieDecoder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ByteBufFlux(reactor.netty.ByteBufFlux) NettyPipeline(reactor.netty.NettyPipeline) MethodSource(org.junit.jupiter.params.provider.MethodSource) ChannelGroup(io.netty.channel.group.ChannelGroup) HttpResponseStatus(io.netty.handler.codec.http.HttpResponseStatus) SignalType(reactor.core.publisher.SignalType) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) ChannelBindException(reactor.netty.ChannelBindException) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) List(java.util.List) DisposableServer(reactor.netty.DisposableServer) HttpVersion(io.netty.handler.codec.http.HttpVersion) Tuple3(reactor.util.function.Tuple3) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) WebSocketCloseStatus(io.netty.handler.codec.http.websocketx.WebSocketCloseStatus) Tuple2(reactor.util.function.Tuple2) HttpClientRequest(reactor.netty.http.client.HttpClientRequest) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) SniCompletionEvent(io.netty.handler.ssl.SniCompletionEvent) Charset(java.nio.charset.Charset) ByteBuf(io.netty.buffer.ByteBuf) Connection(reactor.netty.Connection) ExecutorService(java.util.concurrent.ExecutorService) HttpHeaderValues(io.netty.handler.codec.http.HttpHeaderValues) Assumptions.assumeThat(org.assertj.core.api.Assumptions.assumeThat) SelfSignedCertificate(io.netty.handler.ssl.util.SelfSignedCertificate) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) HttpMethod(io.netty.handler.codec.http.HttpMethod) CertificateException(java.security.cert.CertificateException) TimeUnit(java.util.concurrent.TimeUnit) HttpServerCodec(io.netty.handler.codec.http.HttpServerCodec) FullHttpResponse(io.netty.handler.codec.http.FullHttpResponse) TcpServer(reactor.netty.tcp.TcpServer) HttpContentDecompressor(io.netty.handler.codec.http.HttpContentDecompressor) Comparator(java.util.Comparator) Timeout(org.junit.jupiter.api.Timeout) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) BaseHttpTest(reactor.netty.BaseHttpTest) Test(org.junit.jupiter.api.Test)

Example 17 with Http2SslContextSpec

use of reactor.netty.http.Http2SslContextSpec in project reactor-netty by reactor.

the class HttpServerTests method testHttpServerWithDomainSockets_HTTP2.

@Test
void testHttpServerWithDomainSockets_HTTP2() {
    Http2SslContextSpec serverCtx = Http2SslContextSpec.forServer(ssc.certificate(), ssc.privateKey());
    Http2SslContextSpec clientCtx = Http2SslContextSpec.forClient().configure(builder -> builder.trustManager(InsecureTrustManagerFactory.INSTANCE));
    doTestHttpServerWithDomainSockets(HttpServer.create().protocol(HttpProtocol.H2).secure(spec -> spec.sslContext(serverCtx)), HttpClient.create().protocol(HttpProtocol.H2).secure(spec -> spec.sslContext(clientCtx)), "https");
}
Also used : Http2SslContextSpec(reactor.netty.http.Http2SslContextSpec) AttributeKey(io.netty.util.AttributeKey) HttpHeaders(io.netty.handler.codec.http.HttpHeaders) StepVerifier(reactor.test.StepVerifier) SNIHostName(javax.net.ssl.SNIHostName) AbortedException(reactor.netty.channel.AbortedException) DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) ChannelInboundHandlerAdapter(io.netty.channel.ChannelInboundHandlerAdapter) HttpMessage(io.netty.handler.codec.http.HttpMessage) ByteBufHolder(io.netty.buffer.ByteBufHolder) HttpClientCodec(io.netty.handler.codec.http.HttpClientCodec) TcpClient(reactor.netty.tcp.TcpClient) ConnectionObserver(reactor.netty.ConnectionObserver) Future(java.util.concurrent.Future) DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) BeforeAll(org.junit.jupiter.api.BeforeAll) Duration(java.time.Duration) DEFAULT_FORM_DECODER_SPEC(reactor.netty.http.server.HttpServerFormDecoderProvider.DEFAULT_FORM_DECODER_SPEC) Path(java.nio.file.Path) LoopResources(reactor.netty.resources.LoopResources) HttpObjectDecoder(io.netty.handler.codec.http.HttpObjectDecoder) HttpRequest(io.netty.handler.codec.http.HttpRequest) Context(reactor.util.context.Context) Executors(java.util.concurrent.Executors) CountDownLatch(java.util.concurrent.CountDownLatch) LineBasedFrameDecoder(io.netty.handler.codec.LineBasedFrameDecoder) Assertions.fail(org.assertj.core.api.Assertions.fail) NettyOutbound(reactor.netty.NettyOutbound) ReferenceCountUtil(io.netty.util.ReferenceCountUtil) GZIPOutputStream(java.util.zip.GZIPOutputStream) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) HttpClient(reactor.netty.http.client.HttpClient) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ChannelOption(io.netty.channel.ChannelOption) HttpProtocol(reactor.netty.http.HttpProtocol) Nullable(reactor.util.annotation.Nullable) ArrayList(java.util.ArrayList) InsecureTrustManagerFactory(io.netty.handler.ssl.util.InsecureTrustManagerFactory) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) ValueSource(org.junit.jupiter.params.provider.ValueSource) PrematureCloseException(reactor.netty.http.client.PrematureCloseException) SslContext(io.netty.handler.ssl.SslContext) Publisher(org.reactivestreams.Publisher) IOException(java.io.IOException) Mono(reactor.core.publisher.Mono) Field(java.lang.reflect.Field) ReferenceCounted(io.netty.util.ReferenceCounted) Channel(io.netty.channel.Channel) DefaultHttpContent(io.netty.handler.codec.http.DefaultHttpContent) DefaultEventExecutor(io.netty.util.concurrent.DefaultEventExecutor) Flux(reactor.core.publisher.Flux) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) FutureMono(reactor.netty.FutureMono) Paths(java.nio.file.Paths) SslContextBuilder(io.netty.handler.ssl.SslContextBuilder) HttpHeaderNames(io.netty.handler.codec.http.HttpHeaderNames) ConnectionProvider(reactor.netty.resources.ConnectionProvider) ServerCookieEncoder(io.netty.handler.codec.http.cookie.ServerCookieEncoder) HttpUtil(io.netty.handler.codec.http.HttpUtil) SocketAddress(java.net.SocketAddress) Http11SslContextSpec(reactor.netty.http.Http11SslContextSpec) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) ByteBufAllocator(io.netty.buffer.ByteBufAllocator) URISyntaxException(java.net.URISyntaxException) BiFunction(java.util.function.BiFunction) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Http2SslContextSpec(reactor.netty.http.Http2SslContextSpec) TimeoutException(java.util.concurrent.TimeoutException) BaseHttpTest(reactor.netty.BaseHttpTest) Random(java.util.Random) Unpooled(io.netty.buffer.Unpooled) GlobalEventExecutor(io.netty.util.concurrent.GlobalEventExecutor) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) TransportConfig(reactor.netty.transport.TransportConfig) ServerCookieDecoder(io.netty.handler.codec.http.cookie.ServerCookieDecoder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ByteBufFlux(reactor.netty.ByteBufFlux) NettyPipeline(reactor.netty.NettyPipeline) MethodSource(org.junit.jupiter.params.provider.MethodSource) ChannelGroup(io.netty.channel.group.ChannelGroup) HttpResponseStatus(io.netty.handler.codec.http.HttpResponseStatus) SignalType(reactor.core.publisher.SignalType) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) ChannelBindException(reactor.netty.ChannelBindException) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) List(java.util.List) DisposableServer(reactor.netty.DisposableServer) HttpVersion(io.netty.handler.codec.http.HttpVersion) Tuple3(reactor.util.function.Tuple3) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) WebSocketCloseStatus(io.netty.handler.codec.http.websocketx.WebSocketCloseStatus) Tuple2(reactor.util.function.Tuple2) HttpClientRequest(reactor.netty.http.client.HttpClientRequest) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) SniCompletionEvent(io.netty.handler.ssl.SniCompletionEvent) Charset(java.nio.charset.Charset) ByteBuf(io.netty.buffer.ByteBuf) Connection(reactor.netty.Connection) ExecutorService(java.util.concurrent.ExecutorService) HttpHeaderValues(io.netty.handler.codec.http.HttpHeaderValues) Assumptions.assumeThat(org.assertj.core.api.Assumptions.assumeThat) SelfSignedCertificate(io.netty.handler.ssl.util.SelfSignedCertificate) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) HttpMethod(io.netty.handler.codec.http.HttpMethod) CertificateException(java.security.cert.CertificateException) TimeUnit(java.util.concurrent.TimeUnit) HttpServerCodec(io.netty.handler.codec.http.HttpServerCodec) FullHttpResponse(io.netty.handler.codec.http.FullHttpResponse) TcpServer(reactor.netty.tcp.TcpServer) HttpContentDecompressor(io.netty.handler.codec.http.HttpContentDecompressor) Comparator(java.util.Comparator) Timeout(org.junit.jupiter.api.Timeout) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) BaseHttpTest(reactor.netty.BaseHttpTest) Test(org.junit.jupiter.api.Test)

Example 18 with Http2SslContextSpec

use of reactor.netty.http.Http2SslContextSpec in project reactor-netty by reactor.

the class HttpServerTests method testIssue1286ConnectionCloseErrorResponse_ServerHTTP11AndH2ClientH2.

@Test
void testIssue1286ConnectionCloseErrorResponse_ServerHTTP11AndH2ClientH2() throws Exception {
    Http2SslContextSpec serverCtx = Http2SslContextSpec.forServer(ssc.certificate(), ssc.privateKey());
    Http2SslContextSpec clientCtx = Http2SslContextSpec.forClient().configure(builder -> builder.trustManager(InsecureTrustManagerFactory.INSTANCE));
    doTestIssue1286(server -> server.protocol(HttpProtocol.H2, HttpProtocol.HTTP11).secure(spec -> spec.sslContext(serverCtx)), client -> client.protocol(HttpProtocol.H2).secure(spec -> spec.sslContext(clientCtx)), true, true);
}
Also used : Http2SslContextSpec(reactor.netty.http.Http2SslContextSpec) AttributeKey(io.netty.util.AttributeKey) HttpHeaders(io.netty.handler.codec.http.HttpHeaders) StepVerifier(reactor.test.StepVerifier) SNIHostName(javax.net.ssl.SNIHostName) AbortedException(reactor.netty.channel.AbortedException) DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) ChannelInboundHandlerAdapter(io.netty.channel.ChannelInboundHandlerAdapter) HttpMessage(io.netty.handler.codec.http.HttpMessage) ByteBufHolder(io.netty.buffer.ByteBufHolder) HttpClientCodec(io.netty.handler.codec.http.HttpClientCodec) TcpClient(reactor.netty.tcp.TcpClient) ConnectionObserver(reactor.netty.ConnectionObserver) Future(java.util.concurrent.Future) DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) BeforeAll(org.junit.jupiter.api.BeforeAll) Duration(java.time.Duration) DEFAULT_FORM_DECODER_SPEC(reactor.netty.http.server.HttpServerFormDecoderProvider.DEFAULT_FORM_DECODER_SPEC) Path(java.nio.file.Path) LoopResources(reactor.netty.resources.LoopResources) HttpObjectDecoder(io.netty.handler.codec.http.HttpObjectDecoder) HttpRequest(io.netty.handler.codec.http.HttpRequest) Context(reactor.util.context.Context) Executors(java.util.concurrent.Executors) CountDownLatch(java.util.concurrent.CountDownLatch) LineBasedFrameDecoder(io.netty.handler.codec.LineBasedFrameDecoder) Assertions.fail(org.assertj.core.api.Assertions.fail) NettyOutbound(reactor.netty.NettyOutbound) ReferenceCountUtil(io.netty.util.ReferenceCountUtil) GZIPOutputStream(java.util.zip.GZIPOutputStream) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) HttpClient(reactor.netty.http.client.HttpClient) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ChannelOption(io.netty.channel.ChannelOption) HttpProtocol(reactor.netty.http.HttpProtocol) Nullable(reactor.util.annotation.Nullable) ArrayList(java.util.ArrayList) InsecureTrustManagerFactory(io.netty.handler.ssl.util.InsecureTrustManagerFactory) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) ValueSource(org.junit.jupiter.params.provider.ValueSource) PrematureCloseException(reactor.netty.http.client.PrematureCloseException) SslContext(io.netty.handler.ssl.SslContext) Publisher(org.reactivestreams.Publisher) IOException(java.io.IOException) Mono(reactor.core.publisher.Mono) Field(java.lang.reflect.Field) ReferenceCounted(io.netty.util.ReferenceCounted) Channel(io.netty.channel.Channel) DefaultHttpContent(io.netty.handler.codec.http.DefaultHttpContent) DefaultEventExecutor(io.netty.util.concurrent.DefaultEventExecutor) Flux(reactor.core.publisher.Flux) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) FutureMono(reactor.netty.FutureMono) Paths(java.nio.file.Paths) SslContextBuilder(io.netty.handler.ssl.SslContextBuilder) HttpHeaderNames(io.netty.handler.codec.http.HttpHeaderNames) ConnectionProvider(reactor.netty.resources.ConnectionProvider) ServerCookieEncoder(io.netty.handler.codec.http.cookie.ServerCookieEncoder) HttpUtil(io.netty.handler.codec.http.HttpUtil) SocketAddress(java.net.SocketAddress) Http11SslContextSpec(reactor.netty.http.Http11SslContextSpec) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) ByteBufAllocator(io.netty.buffer.ByteBufAllocator) URISyntaxException(java.net.URISyntaxException) BiFunction(java.util.function.BiFunction) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Http2SslContextSpec(reactor.netty.http.Http2SslContextSpec) TimeoutException(java.util.concurrent.TimeoutException) BaseHttpTest(reactor.netty.BaseHttpTest) Random(java.util.Random) Unpooled(io.netty.buffer.Unpooled) GlobalEventExecutor(io.netty.util.concurrent.GlobalEventExecutor) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) TransportConfig(reactor.netty.transport.TransportConfig) ServerCookieDecoder(io.netty.handler.codec.http.cookie.ServerCookieDecoder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ByteBufFlux(reactor.netty.ByteBufFlux) NettyPipeline(reactor.netty.NettyPipeline) MethodSource(org.junit.jupiter.params.provider.MethodSource) ChannelGroup(io.netty.channel.group.ChannelGroup) HttpResponseStatus(io.netty.handler.codec.http.HttpResponseStatus) SignalType(reactor.core.publisher.SignalType) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) ChannelBindException(reactor.netty.ChannelBindException) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) List(java.util.List) DisposableServer(reactor.netty.DisposableServer) HttpVersion(io.netty.handler.codec.http.HttpVersion) Tuple3(reactor.util.function.Tuple3) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) WebSocketCloseStatus(io.netty.handler.codec.http.websocketx.WebSocketCloseStatus) Tuple2(reactor.util.function.Tuple2) HttpClientRequest(reactor.netty.http.client.HttpClientRequest) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) SniCompletionEvent(io.netty.handler.ssl.SniCompletionEvent) Charset(java.nio.charset.Charset) ByteBuf(io.netty.buffer.ByteBuf) Connection(reactor.netty.Connection) ExecutorService(java.util.concurrent.ExecutorService) HttpHeaderValues(io.netty.handler.codec.http.HttpHeaderValues) Assumptions.assumeThat(org.assertj.core.api.Assumptions.assumeThat) SelfSignedCertificate(io.netty.handler.ssl.util.SelfSignedCertificate) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) HttpMethod(io.netty.handler.codec.http.HttpMethod) CertificateException(java.security.cert.CertificateException) TimeUnit(java.util.concurrent.TimeUnit) HttpServerCodec(io.netty.handler.codec.http.HttpServerCodec) FullHttpResponse(io.netty.handler.codec.http.FullHttpResponse) TcpServer(reactor.netty.tcp.TcpServer) HttpContentDecompressor(io.netty.handler.codec.http.HttpContentDecompressor) Comparator(java.util.Comparator) Timeout(org.junit.jupiter.api.Timeout) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) BaseHttpTest(reactor.netty.BaseHttpTest) Test(org.junit.jupiter.api.Test)

Example 19 with Http2SslContextSpec

use of reactor.netty.http.Http2SslContextSpec in project reactor-netty by reactor.

the class HttpServerTests method testIssue1286_H2.

@Test
void testIssue1286_H2() throws Exception {
    Http2SslContextSpec serverCtx = Http2SslContextSpec.forServer(ssc.certificate(), ssc.privateKey());
    Http2SslContextSpec clientCtx = Http2SslContextSpec.forClient().configure(builder -> builder.trustManager(InsecureTrustManagerFactory.INSTANCE));
    doTestIssue1286(server -> server.protocol(HttpProtocol.H2).secure(spec -> spec.sslContext(serverCtx)), client -> client.protocol(HttpProtocol.H2).secure(spec -> spec.sslContext(clientCtx)), false, false);
}
Also used : Http2SslContextSpec(reactor.netty.http.Http2SslContextSpec) AttributeKey(io.netty.util.AttributeKey) HttpHeaders(io.netty.handler.codec.http.HttpHeaders) StepVerifier(reactor.test.StepVerifier) SNIHostName(javax.net.ssl.SNIHostName) AbortedException(reactor.netty.channel.AbortedException) DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) ChannelInboundHandlerAdapter(io.netty.channel.ChannelInboundHandlerAdapter) HttpMessage(io.netty.handler.codec.http.HttpMessage) ByteBufHolder(io.netty.buffer.ByteBufHolder) HttpClientCodec(io.netty.handler.codec.http.HttpClientCodec) TcpClient(reactor.netty.tcp.TcpClient) ConnectionObserver(reactor.netty.ConnectionObserver) Future(java.util.concurrent.Future) DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) BeforeAll(org.junit.jupiter.api.BeforeAll) Duration(java.time.Duration) DEFAULT_FORM_DECODER_SPEC(reactor.netty.http.server.HttpServerFormDecoderProvider.DEFAULT_FORM_DECODER_SPEC) Path(java.nio.file.Path) LoopResources(reactor.netty.resources.LoopResources) HttpObjectDecoder(io.netty.handler.codec.http.HttpObjectDecoder) HttpRequest(io.netty.handler.codec.http.HttpRequest) Context(reactor.util.context.Context) Executors(java.util.concurrent.Executors) CountDownLatch(java.util.concurrent.CountDownLatch) LineBasedFrameDecoder(io.netty.handler.codec.LineBasedFrameDecoder) Assertions.fail(org.assertj.core.api.Assertions.fail) NettyOutbound(reactor.netty.NettyOutbound) ReferenceCountUtil(io.netty.util.ReferenceCountUtil) GZIPOutputStream(java.util.zip.GZIPOutputStream) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) HttpClient(reactor.netty.http.client.HttpClient) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ChannelOption(io.netty.channel.ChannelOption) HttpProtocol(reactor.netty.http.HttpProtocol) Nullable(reactor.util.annotation.Nullable) ArrayList(java.util.ArrayList) InsecureTrustManagerFactory(io.netty.handler.ssl.util.InsecureTrustManagerFactory) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) ValueSource(org.junit.jupiter.params.provider.ValueSource) PrematureCloseException(reactor.netty.http.client.PrematureCloseException) SslContext(io.netty.handler.ssl.SslContext) Publisher(org.reactivestreams.Publisher) IOException(java.io.IOException) Mono(reactor.core.publisher.Mono) Field(java.lang.reflect.Field) ReferenceCounted(io.netty.util.ReferenceCounted) Channel(io.netty.channel.Channel) DefaultHttpContent(io.netty.handler.codec.http.DefaultHttpContent) DefaultEventExecutor(io.netty.util.concurrent.DefaultEventExecutor) Flux(reactor.core.publisher.Flux) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) FutureMono(reactor.netty.FutureMono) Paths(java.nio.file.Paths) SslContextBuilder(io.netty.handler.ssl.SslContextBuilder) HttpHeaderNames(io.netty.handler.codec.http.HttpHeaderNames) ConnectionProvider(reactor.netty.resources.ConnectionProvider) ServerCookieEncoder(io.netty.handler.codec.http.cookie.ServerCookieEncoder) HttpUtil(io.netty.handler.codec.http.HttpUtil) SocketAddress(java.net.SocketAddress) Http11SslContextSpec(reactor.netty.http.Http11SslContextSpec) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) ByteBufAllocator(io.netty.buffer.ByteBufAllocator) URISyntaxException(java.net.URISyntaxException) BiFunction(java.util.function.BiFunction) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Http2SslContextSpec(reactor.netty.http.Http2SslContextSpec) TimeoutException(java.util.concurrent.TimeoutException) BaseHttpTest(reactor.netty.BaseHttpTest) Random(java.util.Random) Unpooled(io.netty.buffer.Unpooled) GlobalEventExecutor(io.netty.util.concurrent.GlobalEventExecutor) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) TransportConfig(reactor.netty.transport.TransportConfig) ServerCookieDecoder(io.netty.handler.codec.http.cookie.ServerCookieDecoder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ByteBufFlux(reactor.netty.ByteBufFlux) NettyPipeline(reactor.netty.NettyPipeline) MethodSource(org.junit.jupiter.params.provider.MethodSource) ChannelGroup(io.netty.channel.group.ChannelGroup) HttpResponseStatus(io.netty.handler.codec.http.HttpResponseStatus) SignalType(reactor.core.publisher.SignalType) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) ChannelBindException(reactor.netty.ChannelBindException) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) List(java.util.List) DisposableServer(reactor.netty.DisposableServer) HttpVersion(io.netty.handler.codec.http.HttpVersion) Tuple3(reactor.util.function.Tuple3) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) WebSocketCloseStatus(io.netty.handler.codec.http.websocketx.WebSocketCloseStatus) Tuple2(reactor.util.function.Tuple2) HttpClientRequest(reactor.netty.http.client.HttpClientRequest) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) SniCompletionEvent(io.netty.handler.ssl.SniCompletionEvent) Charset(java.nio.charset.Charset) ByteBuf(io.netty.buffer.ByteBuf) Connection(reactor.netty.Connection) ExecutorService(java.util.concurrent.ExecutorService) HttpHeaderValues(io.netty.handler.codec.http.HttpHeaderValues) Assumptions.assumeThat(org.assertj.core.api.Assumptions.assumeThat) SelfSignedCertificate(io.netty.handler.ssl.util.SelfSignedCertificate) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) HttpMethod(io.netty.handler.codec.http.HttpMethod) CertificateException(java.security.cert.CertificateException) TimeUnit(java.util.concurrent.TimeUnit) HttpServerCodec(io.netty.handler.codec.http.HttpServerCodec) FullHttpResponse(io.netty.handler.codec.http.FullHttpResponse) TcpServer(reactor.netty.tcp.TcpServer) HttpContentDecompressor(io.netty.handler.codec.http.HttpContentDecompressor) Comparator(java.util.Comparator) Timeout(org.junit.jupiter.api.Timeout) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) BaseHttpTest(reactor.netty.BaseHttpTest) Test(org.junit.jupiter.api.Test)

Example 20 with Http2SslContextSpec

use of reactor.netty.http.Http2SslContextSpec in project reactor-netty by reactor.

the class HttpClientTest method testConnectionLifeTimeFixedPoolHttp2_2.

@Test
void testConnectionLifeTimeFixedPoolHttp2_2() {
    Http2SslContextSpec serverCtx = Http2SslContextSpec.forServer(ssc.certificate(), ssc.privateKey());
    Http2SslContextSpec clientCtx = Http2SslContextSpec.forClient().configure(builder -> builder.trustManager(InsecureTrustManagerFactory.INSTANCE));
    disposableServer = createServer().protocol(HttpProtocol.H2).secure(spec -> spec.sslContext(serverCtx)).http2Settings(setting -> setting.maxConcurrentStreams(2)).handle((req, resp) -> resp.sendObject(ByteBufFlux.fromString(Mono.delay(Duration.ofMillis(30)).map(Objects::toString)))).bindNow();
    ConnectionProvider provider = ConnectionProvider.builder("testConnectionLifeTimeFixedPoolHttp2_2").maxConnections(1).maxLifeTime(Duration.ofMillis(30)).build();
    HttpClient client = createClient(provider, () -> disposableServer.address()).protocol(HttpProtocol.H2).secure(spec -> spec.sslContext(clientCtx));
    Flux<ChannelId> id = client.get().uri("/").responseConnection((res, conn) -> Mono.just(conn.channel().parent().id()).delayUntil(ch -> conn.inbound().receive()));
    try {
        // warmup
        id.blockLast(Duration.ofSeconds(5));
        List<ChannelId> ids = Flux.range(0, 3).flatMap(i -> id).collectList().block(Duration.ofSeconds(5));
        assertThat(ids).isNotNull().hasSize(3);
        assertThat(ids.get(0)).isEqualTo(ids.get(1));
        assertThat(ids.get(0)).isNotEqualTo(ids.get(2));
    } finally {
        provider.disposeLater().block(Duration.ofSeconds(5));
    }
}
Also used : Http2SslContextSpec(reactor.netty.http.Http2SslContextSpec) Arrays(java.util.Arrays) HttpHeaders(io.netty.handler.codec.http.HttpHeaders) StepVerifier(reactor.test.StepVerifier) DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) Tuples(reactor.util.function.Tuples) Disabled(org.junit.jupiter.api.Disabled) HttpClientCodec(io.netty.handler.codec.http.HttpClientCodec) HttpResources(reactor.netty.http.HttpResources) TcpClient(reactor.netty.tcp.TcpClient) Future(java.util.concurrent.Future) Loggers(reactor.util.Loggers) DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) BeforeAll(org.junit.jupiter.api.BeforeAll) Duration(java.time.Duration) CharsetUtil(io.netty.util.CharsetUtil) Path(java.nio.file.Path) LoopResources(reactor.netty.resources.LoopResources) HttpObjectDecoder(io.netty.handler.codec.http.HttpObjectDecoder) Context(reactor.util.context.Context) Set(java.util.Set) ConnectionPoolMetrics(reactor.netty.resources.ConnectionPoolMetrics) StandardCharsets(java.nio.charset.StandardCharsets) Executors(java.util.concurrent.Executors) CountDownLatch(java.util.concurrent.CountDownLatch) SSLException(javax.net.ssl.SSLException) AddressResolverGroup(io.netty.resolver.AddressResolverGroup) HttpServer(reactor.netty.http.server.HttpServer) LogLevel(io.netty.handler.logging.LogLevel) DefaultFullHttpResponse(io.netty.handler.codec.http.DefaultFullHttpResponse) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) SocketUtils(reactor.netty.SocketUtils) HttpProtocol(reactor.netty.http.HttpProtocol) Nullable(reactor.util.annotation.Nullable) ArrayList(java.util.ArrayList) InsecureTrustManagerFactory(io.netty.handler.ssl.util.InsecureTrustManagerFactory) SslProvider(reactor.netty.tcp.SslProvider) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) SslContext(io.netty.handler.ssl.SslContext) Files(java.nio.file.Files) Publisher(org.reactivestreams.Publisher) IOException(java.io.IOException) Mono(reactor.core.publisher.Mono) Field(java.lang.reflect.Field) Channel(io.netty.channel.Channel) AtomicLong(java.util.concurrent.atomic.AtomicLong) DefaultEventExecutor(io.netty.util.concurrent.DefaultEventExecutor) Flux(reactor.core.publisher.Flux) FutureMono(reactor.netty.FutureMono) Paths(java.nio.file.Paths) SslContextBuilder(io.netty.handler.ssl.SslContextBuilder) HttpHeaderNames(io.netty.handler.codec.http.HttpHeaderNames) ConnectionProvider(reactor.netty.resources.ConnectionProvider) DnsAddressResolverGroup(io.netty.resolver.dns.DnsAddressResolverGroup) Sinks(reactor.core.publisher.Sinks) SocketAddress(java.net.SocketAddress) Http11SslContextSpec(reactor.netty.http.Http11SslContextSpec) ByteBufAllocator(io.netty.buffer.ByteBufAllocator) URISyntaxException(java.net.URISyntaxException) BiFunction(java.util.function.BiFunction) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ChannelId(io.netty.channel.ChannelId) Http2SslContextSpec(reactor.netty.http.Http2SslContextSpec) TimeoutException(java.util.concurrent.TimeoutException) BaseHttpTest(reactor.netty.BaseHttpTest) ByteBuffer(java.nio.ByteBuffer) Unpooled(io.netty.buffer.Unpooled) TransportConfig(reactor.netty.transport.TransportConfig) SocketChannel(java.nio.channels.SocketChannel) HttpResponseEncoder(io.netty.handler.codec.http.HttpResponseEncoder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ByteBufFlux(reactor.netty.ByteBufFlux) NettyPipeline(reactor.netty.NettyPipeline) Logger(reactor.util.Logger) ByteBufMono(reactor.netty.ByteBufMono) URI(java.net.URI) ChannelDuplexHandler(io.netty.channel.ChannelDuplexHandler) ChannelGroup(io.netty.channel.group.ChannelGroup) ReadTimeoutHandler(io.netty.handler.timeout.ReadTimeoutHandler) StandardOpenOption(java.nio.file.StandardOpenOption) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HttpResponseStatus(io.netty.handler.codec.http.HttpResponseStatus) InetSocketAddress(java.net.InetSocketAddress) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) List(java.util.List) HttpVersion(io.netty.handler.codec.http.HttpVersion) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Tuple2(reactor.util.function.Tuple2) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) Queues(reactor.util.concurrent.Queues) Charset(java.nio.charset.Charset) ByteBuf(io.netty.buffer.ByteBuf) Connection(reactor.netty.Connection) ExecutorService(java.util.concurrent.ExecutorService) HttpHeaderValues(io.netty.handler.codec.http.HttpHeaderValues) SelfSignedCertificate(io.netty.handler.ssl.util.SelfSignedCertificate) HttpMethod(io.netty.handler.codec.http.HttpMethod) CertificateException(java.security.cert.CertificateException) ServerSocketChannel(java.nio.channels.ServerSocketChannel) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) TcpServer(reactor.netty.tcp.TcpServer) ChannelHandler(io.netty.channel.ChannelHandler) HttpContentDecompressor(io.netty.handler.codec.http.HttpContentDecompressor) ChannelId(io.netty.channel.ChannelId) ConnectionProvider(reactor.netty.resources.ConnectionProvider) BaseHttpTest(reactor.netty.BaseHttpTest) Test(org.junit.jupiter.api.Test)

Aggregations

Http2SslContextSpec (reactor.netty.http.Http2SslContextSpec)32 SelfSignedCertificate (io.netty.handler.ssl.util.SelfSignedCertificate)27 Test (org.junit.jupiter.api.Test)27 HttpProtocol (reactor.netty.http.HttpProtocol)27 InsecureTrustManagerFactory (io.netty.handler.ssl.util.InsecureTrustManagerFactory)26 Duration (java.time.Duration)26 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)26 Mono (reactor.core.publisher.Mono)26 BaseHttpTest (reactor.netty.BaseHttpTest)26 CertificateException (java.security.cert.CertificateException)25 BeforeAll (org.junit.jupiter.api.BeforeAll)25 List (java.util.List)24 TimeUnit (java.util.concurrent.TimeUnit)24 Flux (reactor.core.publisher.Flux)24 Http11SslContextSpec (reactor.netty.http.Http11SslContextSpec)24 Channel (io.netty.channel.Channel)22 HttpHeaderNames (io.netty.handler.codec.http.HttpHeaderNames)22 HttpResponseStatus (io.netty.handler.codec.http.HttpResponseStatus)22 SocketAddress (java.net.SocketAddress)22 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)22