-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow smallrye-health to return DOWN response compliant with rfc9457
- Loading branch information
Showing
5 changed files
with
105 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
44 changes: 44 additions & 0 deletions
44
...yment/src/test/java/io/quarkus/smallrye/health/test/ProblemDetailsConfigOverrideTest.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,44 @@ | ||
package io.quarkus.smallrye.health.test; | ||
|
||
import static org.hamcrest.Matchers.contains; | ||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
|
||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
import io.restassured.parsing.Parser; | ||
|
||
class ProblemDetailsConfigOverrideTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(FailingHealthCheck.class) | ||
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")) | ||
.overrideConfigKey("quarkus.smallrye-health.include-problem-details", "true"); | ||
|
||
@Test | ||
void testProblemDetailsOverride() { | ||
try { | ||
RestAssured.defaultParser = Parser.JSON; | ||
RestAssured.when().get("/q/health/live").then() | ||
.contentType("application/problem+json") | ||
.body("type", is("about:blank"), | ||
"status", is(503), | ||
"title", is("Health Check Failed: /q/health/live"), | ||
"detail", containsString("/q/health/live, invoked at"), | ||
"instance", notNullValue(), | ||
"health.checks.size()", is(1), | ||
"health.checks.status", contains("DOWN"), | ||
"health.checks.name", contains("failing")); | ||
} finally { | ||
RestAssured.reset(); | ||
} | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...time/src/main/java/io/quarkus/smallrye/health/runtime/SmallRyeHealthBuildFixedConfig.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,17 @@ | ||
package io.quarkus.smallrye.health.runtime; | ||
|
||
import io.quarkus.runtime.annotations.ConfigItem; | ||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
|
||
@ConfigRoot(name = "smallrye-health", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) | ||
public class SmallRyeHealthBuildFixedConfig { | ||
|
||
/** | ||
* Specify the reported DOWN responses should be aligned with RFC 9457 - Problem Details for HTTP APIs. | ||
* | ||
* @see <a href="https://tools.ietf.org/html/rfc7807">RFC 7807</a> | ||
*/ | ||
@ConfigItem(defaultValue = "false") | ||
boolean includeProblemDetails; | ||
} |
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