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 reactive modules from the project #7201

Merged
merged 28 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ed6281b
Remove reactive modules from the project
tomas-langer Jul 14, 2023
e20990d
- Build everything, copyright and checkstyle passing.
romain-grecourt Jul 14, 2023
eb16f12
Fix a few examples:
romain-grecourt Jul 17, 2023
8b4661a
- Fixed examples/security/webserver-digest-auth
romain-grecourt Jul 17, 2023
c9d165a
Fix mutual TLS tests (and bugs in implementation)
tomas-langer Jul 17, 2023
0e64aff
Fixed security integration with Jersey and tests.
tomas-langer Jul 17, 2023
cb11164
Fixed Microstream health
tomas-langer Jul 17, 2023
e899648
Fixed checkstyle
tomas-langer Jul 17, 2023
6f45607
- Fix examples/security/google-login
romain-grecourt Jul 17, 2023
f5e18f7
Fix examples/todo-app
romain-grecourt Jul 17, 2023
c1ddc4c
- Fix examples/webserver/basics
romain-grecourt Jul 17, 2023
afdfa00
Fix ErrorHandlersTest.testHandler
romain-grecourt Jul 17, 2023
368a6a5
First set of integration tests fixed.
tomas-langer Jul 17, 2023
933203d
- Fix examples/webserver/comment-aas
romain-grecourt Jul 18, 2023
a3a3fbc
- Add helidon-nima-testing-junit5-websocket to BOM
romain-grecourt Jul 18, 2023
200db51
Fix examples/webserver/mutual-tls
romain-grecourt Jul 18, 2023
659d093
- Fix examples/webserver/fault-tolerance
romain-grecourt Jul 18, 2023
c44c3b4
Fix examples/cors
romain-grecourt Jul 18, 2023
77880d4
- Fixes and disabled tests in examples/metrics/exemplar
romain-grecourt Jul 18, 2023
296aa46
- Fix FormParamsSupport (writer was mutating param value list_
romain-grecourt Jul 18, 2023
81b6d5e
- Fix TracingPropagationTest (tests/integration/webclient)
romain-grecourt Jul 18, 2023
e95f402
Second set of integration tests fixed.
tomas-langer Jul 18, 2023
36931f0
update examples/webserver/mutual-tls to not hard-code ports in tests
romain-grecourt Jul 18, 2023
3b7f390
Last set of integration tests fixed.
tomas-langer Jul 18, 2023
97e54cb
Tracing TCK fix
tomas-langer Jul 18, 2023
b9c3923
LRA TCK skipping tests
tomas-langer Jul 18, 2023
9c724c0
Add opens for MP security
tomas-langer Jul 18, 2023
4e2d5c7
Disabled test failing on pipeline.
tomas-langer Jul 18, 2023
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
Prev Previous commit
Next Next commit
Fix examples/cors
  • Loading branch information
romain-grecourt committed Jul 18, 2023
commit c44c3b4b4d970945913cac28cdb3245e0ce12a2c
12 changes: 12 additions & 0 deletions examples/cors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,22 @@
<groupId>io.helidon.nima.observe</groupId>
<artifactId>helidon-nima-observe</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.nima.observe</groupId>
<artifactId>helidon-nima-observe-health</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.nima.observe</groupId>
<artifactId>helidon-nima-observe-metrics</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config-yaml</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.nima.http.media</groupId>
<artifactId>helidon-nima-http-media-jsonp</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.health</groupId>
<artifactId>helidon-health-checks</artifactId>
Expand Down
11 changes: 5 additions & 6 deletions examples/cors/src/main/java/io/helidon/examples/cors/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.helidon.logging.common.LogConfig;
import io.helidon.nima.observe.ObserveFeature;
import io.helidon.nima.webserver.WebServer;
import io.helidon.nima.webserver.WebServerConfig;
import io.helidon.nima.webserver.cors.CorsSupport;
import io.helidon.nima.webserver.http.HttpRouting;

Expand Down Expand Up @@ -50,11 +51,10 @@ public static void main(final String[] args) {
Config config = Config.create();

// Get webserver config from the "server" section of application.yaml
WebServer server = WebServer.builder()
WebServerConfig.Builder builder = WebServer.builder();
WebServer server = builder
.config(config.get("server"))
.putSocket("@default", socket -> socket
.port(8080)
.routing(routing -> routing(routing, config)))
.routing(it -> routing(it, config))
.build()
.start();

Expand All @@ -71,10 +71,9 @@ static void routing(HttpRouting.Builder routing, Config config) {

GreetService greetService = new GreetService(config);


// Note: Add the CORS routing *before* registering the GreetService routing.
routing.register("/greet", corsSupportForGreeting(config), greetService)
.addFeature(ObserveFeature.create(config));
.addFeature(ObserveFeature.create());
}

private static CorsSupport corsSupportForGreeting(Config config) {
Expand Down
124 changes: 50 additions & 74 deletions examples/cors/src/test/java/io/helidon/examples/cors/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,80 +69,67 @@ public static void setup(WebServerConfig.Builder server) {
@Order(1) // Make sure this runs before the greeting message changes so responses are deterministic.
@Test
public void testHelloWorld() {

try (Http1ClientResponse response = client.get()
.path("/greet")
try (Http1ClientResponse response = client.get("/greet")
.accept(HttpMediaType.APPLICATION_JSON)
.request()) {

assertThat("HTTP response1", response.status().code(), is(200));
assertThat(response.status().code(), is(200));

String payload = GreetingMessage.fromRest(response.entity().as(JsonObject.class)).getMessage();
assertThat("default message", payload, is("Hello World!"));
assertThat(payload, is("Hello World!"));
}

try (Http1ClientResponse response = client.get()
.path("/greet/Joe")
try (Http1ClientResponse response = client.get("/greet/Joe")
.accept(HttpMediaType.APPLICATION_JSON)
.request()) {

assertThat("HTTP response2", response.status().code(), is(200));
assertThat(response.status().code(), is(200));

String payload = GreetingMessage.fromRest(response.entity().as(JsonObject.class)).getMessage();
assertThat("default message", payload, is("Hello Joe!"));
assertThat(payload, is("Hello Joe!"));
}

try (Http1ClientResponse response = client.put()
.path("/greet/greeting")
try (Http1ClientResponse response = client.put("/greet/greeting")
.accept(HttpMediaType.APPLICATION_JSON)
.submit(new GreetingMessage("Hola").forRest())) {

assertThat("HTTP response3", response.status().code(), is(204));
assertThat(response.status().code(), is(204));
}

try (Http1ClientResponse response = client.get()
.path("/greet/Jose")
try (Http1ClientResponse response = client.get("/greet/Jose")
.accept(HttpMediaType.APPLICATION_JSON)
.request()) {

assertThat("HTTP response4", response.status().code(), is(200));
assertThat(response.status().code(), is(200));

String payload = GreetingMessage.fromRest(response.entity().as(JsonObject.class)).getMessage();
assertThat("hola Jose message", payload, is("Hola Jose!"));
assertThat(payload, is("Hola Jose!"));
}

try (Http1ClientResponse response = client.get()
.path("/observe/health")
.request()) {

assertThat("HTTP response5", response.status().code(), is(200));
try (Http1ClientResponse response = client.get("/observe/health").request()) {
assertThat(response.status().code(), is(204));
}

try (Http1ClientResponse response = client.get()
.path("/observe/metrics")
.request()) {

assertThat("HTTP response6", response.status().code(), is(200));
try (Http1ClientResponse response = client.get("/observe/metrics").request()) {
assertThat(response.status().code(), is(200));
}
}

@Order(10)
// Run after the non-CORS tests (so the greeting is Hola) but before the CORS test that changes the greeting again.
@Test
void testAnonymousGreetWithCors() {
Http1ClientRequest request = client.get()
try (Http1ClientResponse response = client.get()
.path("/greet")
.accept(HttpMediaType.APPLICATION_JSON);
request.headers(headers -> {
headers.set(ORIGIN, "http://foo.com");
headers.set(HOST, "here.com");
return headers;
});
try (Http1ClientResponse response = request.request()) {
assertThat("HTTP response", response.status().code(), is(200));
String payload = GreetingMessage.fromRest(response.entity().as(JsonObject.class))
.getMessage();
assertThat("HTTP response payload was " + payload, payload, containsString("Hola World"));
.accept(HttpMediaType.APPLICATION_JSON)
.headers(it -> it
.set(ORIGIN, "http://foo.com")
.set(HOST, "here.com"))
.request()) {

assertThat(response.status().code(), is(200));
String payload = GreetingMessage.fromRest(response.entity().as(JsonObject.class)).getMessage();
assertThat(payload, containsString("Hola World"));
Headers responseHeaders = response.headers();
Optional<String> allowOrigin = responseHeaders.value(ACCESS_CONTROL_ALLOW_ORIGIN);
assertThat("Expected CORS header " + CrossOriginConfig.ACCESS_CONTROL_ALLOW_ORIGIN + " is absent",
Expand All @@ -154,20 +141,15 @@ void testAnonymousGreetWithCors() {
@Order(11) // Run after the non-CORS tests but before other CORS tests.
@Test
void testGreetingChangeWithCors() {

// Send the pre-flight request and check the response.

Http1ClientRequest request = client.options()
.path("/greet/greeting");
request.headers(headers -> {
headers.set(ORIGIN, "http://foo.com");
headers.set(HOST, "here.com");
headers.set(ACCESS_CONTROL_REQUEST_METHOD, "PUT");
return headers;
});

WritableHeaders<?> preFlightHeaders = WritableHeaders.create();
try (Http1ClientResponse response = request.request()) {
try (Http1ClientResponse response = client.options()
.path("/greet/greeting")
.headers(it -> it
.set(ORIGIN, "http://foo.com")
.set(HOST, "here.com")
.set(ACCESS_CONTROL_REQUEST_METHOD, "PUT"))
.request()) {
response.headers().forEach(preFlightHeaders::add);
List<String> allowMethods = preFlightHeaders.values(ACCESS_CONTROL_ALLOW_METHODS);
assertThat("pre-flight response does not include " + CrossOriginConfig.ACCESS_CONTROL_ALLOW_METHODS,
Expand All @@ -177,46 +159,40 @@ void testGreetingChangeWithCors() {
assertThat("pre-flight response does not include " + CrossOriginConfig.ACCESS_CONTROL_ALLOW_ORIGIN,
allowOrigins, not(empty()));
assertThat("Header " + CrossOriginConfig.ACCESS_CONTROL_ALLOW_ORIGIN
+ " should contain '*' but does not; " + allowOrigins,
+ " should contain '*' but does not; " + allowOrigins,
allowOrigins, hasItem("http://foo.com"));
}

// Send the follow-up request.
request = client.put("/greet/greeting")
.accept(HttpMediaType.APPLICATION_JSON);

request.headers(headers -> {
headers.set(ORIGIN, "http://foo.com");
headers.set(HOST, "here.com");
preFlightHeaders.forEach(headers::add);
return headers;
});

GreetingMessage payload = new GreetingMessage("Cheers");
try (Http1ClientResponse response = request.submit(payload.forRest())) {

assertThat("HTTP response3", response.status().code(), is(204));
try (Http1ClientResponse response = client.put("/greet/greeting")
.accept(HttpMediaType.APPLICATION_JSON)
.headers(headers -> {
headers.set(ORIGIN, "http://foo.com");
headers.set(HOST, "here.com");
preFlightHeaders.forEach(headers::add);
return headers;
}).submit(payload.forRest())) {

assertThat(response.status().code(), is(204));
List<String> allowOrigins = preFlightHeaders.values(ACCESS_CONTROL_ALLOW_ORIGIN);
assertThat("Expected CORS header " + CrossOriginConfig.ACCESS_CONTROL_ALLOW_ORIGIN + " has no value(s)",
allowOrigins, not(empty()));
assertThat("Header " + CrossOriginConfig.ACCESS_CONTROL_ALLOW_ORIGIN
+ " should contain '*' but does not; " + allowOrigins,
+ " should contain '*' but does not; " + allowOrigins,
allowOrigins, hasItem("http://foo.com"));
}
}

@Order(12) // Run after CORS test changes greeting to Cheers.
@Test
void testNamedGreetWithCors() {
Http1ClientRequest request = client.get()
.path("/greet/Maria");
request.headers(headers -> {
headers.set(ORIGIN, "http://foo.com");
headers.set(HOST, "here.com");
return headers;
});

try (Http1ClientResponse response = request.request()) {
try (Http1ClientResponse response = client.get()
.path("/greet/Maria")
.headers(headers -> headers
.set(ORIGIN, "http://foo.com")
.set(HOST, "here.com"))
.request()) {
assertThat("HTTP response", response.status().code(), is(200));
String payload = GreetingMessage.fromRest(response.entity().as(JsonObject.class)).getMessage();
assertThat(payload, containsString("Cheers Maria"));
Expand Down