forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#36544 from cescoffier/vertx-4.4.6
Update Vert.x version to 4.4.6
- Loading branch information
Showing
9 changed files
with
216 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
.../reactive-pg-client/deployment/src/test/java/io/quarkus/reactive/pg/client/MoneyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.quarkus.reactive.pg.client; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.math.BigDecimal; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.vertx.pgclient.data.Money; | ||
|
||
/** | ||
* Reproduce <a href="https://github.com/quarkusio/quarkus/issues/36144">PG Reactive Client: Cannot create Money value in Range | ||
* (-1.00, 0.00)</a>. | ||
*/ | ||
public class MoneyTest { | ||
|
||
@Test | ||
void testMoney() { | ||
Money money = new Money(new BigDecimal("-1.11")); | ||
assertEquals(BigDecimal.valueOf(-1.11), money.bigDecimalValue()); | ||
|
||
money = new Money(new BigDecimal("-0.11")); | ||
assertEquals(BigDecimal.valueOf(-0.11), money.bigDecimalValue()); | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/EmptyHostTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.quarkus.vertx.http; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.event.Observes; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
import io.vertx.ext.web.Router; | ||
|
||
/** | ||
* Reproduce <a href="https://github.com/quarkusio/quarkus/issues/36234">NullPointerException for request with empty Host | ||
* header</a>. | ||
*/ | ||
public class EmptyHostTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(BeanRegisteringRouteUsingObserves.class)); | ||
|
||
@Test | ||
public void testWithEmptyHost() { | ||
assertEquals(RestAssured | ||
.given() | ||
.header("Host", "") | ||
.get("/hello") | ||
.asString(), "Hello World! "); | ||
|
||
} | ||
|
||
@ApplicationScoped | ||
static class BeanRegisteringRouteUsingObserves { | ||
|
||
public void register(@Observes Router router) { | ||
|
||
router.route("/hello").handler(ctx -> ctx.response().end("Hello World! " + ctx.request().host())); | ||
} | ||
|
||
} | ||
|
||
} |
105 changes: 105 additions & 0 deletions
105
...ployment/src/test/java/io/quarkus/vertx/http/http2/Http2RSTFloodProtectionConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package io.quarkus.vertx.http.http2; | ||
|
||
import static io.vertx.core.http.HttpMethod.GET; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import java.io.File; | ||
import java.net.URL; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.event.Observes; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Assumptions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.quarkus.test.common.http.TestHTTPResource; | ||
import io.quarkus.vertx.core.runtime.VertxCoreRecorder; | ||
import io.vertx.core.http.HttpClient; | ||
import io.vertx.core.http.HttpClientOptions; | ||
import io.vertx.core.http.HttpClientRequest; | ||
import io.vertx.core.http.HttpVersion; | ||
import io.vertx.core.net.JdkSSLEngineOptions; | ||
import io.vertx.ext.web.Router; | ||
|
||
/** | ||
* Configuration of the RST flood protection (CVE-2023-44487) | ||
*/ | ||
public class Http2RSTFloodProtectionConfigTest { | ||
|
||
@TestHTTPResource(value = "/ping", ssl = true) | ||
URL sslUrl; | ||
|
||
@TestHTTPResource(value = "/ping") | ||
URL url; | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(MyBean.class) | ||
.addAsResource(new File("src/test/resources/conf/ssl-jks-rst-flood-protection.conf"), | ||
"application.properties") | ||
.addAsResource(new File("src/test/resources/conf/server-keystore.jks"), "server-keystore.jks")); | ||
|
||
@Test | ||
void testRstFloodProtectionWithTlsEnabled() throws Exception { | ||
Assumptions.assumeTrue(JdkSSLEngineOptions.isAlpnAvailable()); //don't run on JDK8 | ||
HttpClientOptions options = new HttpClientOptions() | ||
.setUseAlpn(true) | ||
.setProtocolVersion(HttpVersion.HTTP_2) | ||
.setSsl(true) | ||
.setTrustAll(true); | ||
|
||
var client = VertxCoreRecorder.getVertx().get().createHttpClient(options); | ||
int port = sslUrl.getPort(); | ||
run(client, port, false); | ||
} | ||
|
||
@Test | ||
public void testRstFloodProtection() throws InterruptedException { | ||
HttpClientOptions options = new HttpClientOptions() | ||
.setProtocolVersion(HttpVersion.HTTP_2) | ||
.setHttp2ClearTextUpgrade(true); | ||
var client = VertxCoreRecorder.getVertx().get().createHttpClient(options); | ||
run(client, url.getPort(), true); | ||
} | ||
|
||
void run(HttpClient client, int port, boolean plain) throws InterruptedException { | ||
CountDownLatch latch = new CountDownLatch(1); | ||
client.connectionHandler(conn -> conn.goAwayHandler(ga -> { | ||
Assertions.assertEquals(11, ga.getErrorCode()); | ||
latch.countDown(); | ||
})); | ||
|
||
if (plain) { | ||
// Emit a first request to establish a connection. | ||
// It's HTTP/1 so, does not count in the number of requests. | ||
client.request(GET, port, "localhost", "/ping") | ||
.compose(HttpClientRequest::send); | ||
} | ||
|
||
for (int i = 0; i < 20; i++) { | ||
client.request(GET, port, "localhost", "/ping") | ||
.onSuccess(req -> req.end().onComplete(v -> req.reset())); | ||
} | ||
|
||
if (!latch.await(10, TimeUnit.SECONDS)) { | ||
fail("RST flood protection failed"); | ||
} | ||
} | ||
|
||
@ApplicationScoped | ||
public static class MyBean { | ||
|
||
public void register(@Observes Router router) { | ||
router.get("/ping").handler(rc -> { | ||
// Do nothing. | ||
}); | ||
} | ||
|
||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
extensions/vertx-http/deployment/src/test/resources/conf/ssl-jks-rst-flood-protection.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
quarkus.http.ssl.certificate.key-store-file=server-keystore.jks | ||
quarkus.http.ssl.certificate.key-store-password=secret | ||
|
||
quarkus.http.limits.rst-flood-max-rst-frame-per-window=10 | ||
quarkus.http.limits.rst-flood-window-duration=10s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters