Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplications #2925

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import io.netty.handler.ssl.util.SelfSignedCertificate;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import reactor.core.publisher.Hooks;
Expand All @@ -54,29 +56,40 @@ class ContextPropagationTest {
static final ConnectionProvider provider = ConnectionProvider.create("testContextPropagation", 1);
static final ContextRegistry registry = ContextRegistry.getInstance();

static SelfSignedCertificate ssc;

HttpServer baseServer;
DisposableServer disposableServer;
SelfSignedCertificate ssc;
Http2SslContextSpec serverCtx;


@BeforeAll
static void createSelfSignedCertificate() throws Exception {
ssc = new SelfSignedCertificate();
}

@AfterAll
static void disposePool() {
provider.disposeLater()
.block(Duration.ofSeconds(30));
}

@ParameterizedTest
@MethodSource("httpClientCombinations")
void testContextPropagation(HttpClient client) throws Exception {
ssc = new SelfSignedCertificate();
Http2SslContextSpec serverCtxHttp = Http2SslContextSpec.forServer(ssc.certificate(), ssc.privateKey());
HttpServer server =
@BeforeEach
void setUp() {
serverCtx = Http2SslContextSpec.forServer(ssc.certificate(), ssc.privateKey());
baseServer =
HttpServer.create()
.wiretap(true)
.httpRequestDecoder(spec -> spec.h2cMaxContentLength(256))
.handle((in, out) -> out.send(in.receive().retain()));
}

server = client.configuration().sslProvider() != null ?
server.secure(spec -> spec.sslContext(serverCtxHttp)).protocol(HttpProtocol.HTTP11, HttpProtocol.H2) :
server.protocol(HttpProtocol.HTTP11, HttpProtocol.H2C);
@ParameterizedTest
@MethodSource("httpClientCombinations")
void testContextPropagation(HttpClient client) {
HttpServer server = client.configuration().sslProvider() != null ?
baseServer.secure(spec -> spec.sslContext(serverCtx)).protocol(HttpProtocol.HTTP11, HttpProtocol.H2) :
baseServer.protocol(HttpProtocol.HTTP11, HttpProtocol.H2C);

disposableServer = server.bindNow();

Expand Down Expand Up @@ -108,25 +121,17 @@ void testContextPropagation(HttpClient client) throws Exception {

@ParameterizedTest
@MethodSource("httpClientCombinations")
void testAutomaticContextPropagation(HttpClient client) throws Exception {
void testAutomaticContextPropagation(HttpClient client) {
String reactorCoreVersionMinor = System.getProperty("reactorCoreVersionMinor");
String contextPropagationVersionMicro = System.getProperty("contextPropagationVersionMicro");

boolean enableAutomaticContextPropagation =
reactorCoreVersionMinor != null && !reactorCoreVersionMinor.isEmpty() && Integer.parseInt(reactorCoreVersionMinor) >= 6 && // 3.6.x
contextPropagationVersionMicro != null && !contextPropagationVersionMicro.isEmpty() && Integer.parseInt(contextPropagationVersionMicro) >= 5; // 1.0.5 or above

ssc = new SelfSignedCertificate();
Http2SslContextSpec serverCtxHttp = Http2SslContextSpec.forServer(ssc.certificate(), ssc.privateKey());
HttpServer server =
HttpServer.create()
.wiretap(true)
.httpRequestDecoder(spec -> spec.h2cMaxContentLength(256))
.handle((in, out) -> out.send(in.receive().retain()));

server = client.configuration().sslProvider() != null ?
server.secure(spec -> spec.sslContext(serverCtxHttp)).protocol(HttpProtocol.HTTP11, HttpProtocol.H2) :
server.protocol(HttpProtocol.HTTP11, HttpProtocol.H2C);
HttpServer server = client.configuration().sslProvider() != null ?
baseServer.secure(spec -> spec.sslContext(serverCtx)).protocol(HttpProtocol.HTTP11, HttpProtocol.H2) :
baseServer.protocol(HttpProtocol.HTTP11, HttpProtocol.H2C);

disposableServer = server.bindNow();

Expand Down