From 64a75517117d980516d3b55cad0fe02f9d8f412e Mon Sep 17 00:00:00 2001 From: jmatsuok Date: Tue, 14 Jan 2025 13:11:54 -0500 Subject: [PATCH] Add test assertions for location header --- .../java/io/cryostat/reports/ReportsTest.java | 19 +++++++++++++++++-- .../java/itest/RecordingWorkflowTest.java | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/test/java/io/cryostat/reports/ReportsTest.java b/src/test/java/io/cryostat/reports/ReportsTest.java index 9669d2f4e..87cf9a79e 100644 --- a/src/test/java/io/cryostat/reports/ReportsTest.java +++ b/src/test/java/io/cryostat/reports/ReportsTest.java @@ -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() @@ -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() diff --git a/src/test/java/itest/RecordingWorkflowTest.java b/src/test/java/itest/RecordingWorkflowTest.java index 3e6abc9a6..c42a5d028 100644 --- a/src/test/java/itest/RecordingWorkflowTest.java +++ b/src/test/java/itest/RecordingWorkflowTest.java @@ -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 @@ -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