Skip to content

Commit

Permalink
WFLY-19229 The OpenAPI BasicRuntimeIT is ineffective and passes even …
Browse files Browse the repository at this point in the history
…on non-OpenAPI compliant runtime

Fix BasicRuntimeIT does not add /context-path when SERVER_HOST/server.host is overriden.
  • Loading branch information
rhusar committed Jun 17, 2024
1 parent 741125f commit d2e1b69
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@
import java.time.Duration;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
* The very basic runtime integration testing.
* The very basic runtime integration test to verify that /openapi context is registered by the OpenAPI subsystem.
*
* @author emartins
* @author Radoslav Husar
*/
public class BasicRuntimeIT {

private static final String DEFAULT_SERVER_HOST = "http://localhost:8080/microprofile-openapi";
private static final String DEFAULT_SERVER_HOST = "http://localhost:8080";

@Test
public void testHTTPEndpointIsAvailable() throws IOException, InterruptedException, URISyntaxException {
Expand All @@ -45,7 +48,9 @@ public void testHTTPEndpointIsAvailable() throws IOException, InterruptedExcepti
serverHost = DEFAULT_SERVER_HOST;
}
final HttpRequest request = HttpRequest.newBuilder()
.uri(new URI(serverHost))
// Check the /openapi context being available (rather than checking dummy /microprofile-openapi response)
// This test would thus correctly fail (404) if run against a server without an OpenAPI subsystem
.uri(new URI(serverHost + "/openapi"))
.GET()
.build();
final HttpClient client = HttpClient.newBuilder()
Expand All @@ -54,5 +59,9 @@ public void testHTTPEndpointIsAvailable() throws IOException, InterruptedExcepti
.build();
final HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
assertEquals(200, response.statusCode());

// First line are just dashes, so lets check the second line with OpenAPI version key for the prefix
String[] bodyLines = response.body().split("\n");
assertTrue(bodyLines[1].startsWith("openapi:"));
}
}

0 comments on commit d2e1b69

Please sign in to comment.