Skip to content

Commit

Permalink
Add test assertions for location header
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Matsuoka committed Jan 14, 2025
1 parent dc7f684 commit 64a7551
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions src/test/java/io/cryostat/reports/ReportsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,17 @@ void testGetReportByTargetAndRemoteId() {
.assertThat()
.statusCode(202)
.contentType(ContentType.TEXT)
.body(Matchers.any(String.class));
.body(Matchers.any(String.class))
.assertThat()
// 202 Indicates report generation is in progress and sends an intermediate
// response.
// Verify we get a location header from a 202.
.header(
"Location",
"http://localhost:8081/api/v4/targets/"
+ targetId
+ "/reports/"
+ remoteId);

given().log()
.all()
Expand Down Expand Up @@ -165,7 +175,12 @@ void testGetReportByUrl() {
.assertThat()
.statusCode(202)
.contentType(ContentType.TEXT)
.body(Matchers.any(String.class));
.body(Matchers.any(String.class))
.assertThat()
// 202 Indicates report generation is in progress and sends an intermediate
// response.
// Verify we get a location header from a 202.
.header("Location", "http://localhost:8081" + reportUrl);

given().log()
.all()
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/itest/RecordingWorkflowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ public void testWorkflow() throws Exception {
Matchers.matchesRegex(
TARGET_ALIAS + "_" + TEST_RECORDING_NAME + "_[\\d]{8}T[\\d]{6}Z.jfr"));
String savedDownloadUrl = recordingInfo.getString("downloadUrl");

Thread.sleep(3_000L); // wait for the dump to complete

// verify the in-memory recording list has not changed, except recording is now stopped
Expand Down Expand Up @@ -250,6 +249,7 @@ public void testWorkflow() throws Exception {
MatcherAssert.assertThat(
reportResponse.statusCode(),
Matchers.both(Matchers.greaterThanOrEqualTo(200)).and(Matchers.lessThan(300)));
MatcherAssert.assertThat(reportResponse.getHeader("Location"), Matchers.notNullValue());
MatcherAssert.assertThat(reportResponse.bodyAsString(), Matchers.notNullValue());

// Check that report generation concludes
Expand Down

0 comments on commit 64a7551

Please sign in to comment.