From c9c77212647f301ca876ac5b63941f90bea089c7 Mon Sep 17 00:00:00 2001 From: Corneil du Plessis Date: Fri, 17 May 2024 18:03:32 +0200 Subject: [PATCH] Added verification of tasks/thinexecutions in DataflowOAuthIT. --- .../test/oauth/DataflowOAuthIT.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/spring-cloud-dataflow-server/src/test/java/org/springframework/cloud/dataflow/integration/test/oauth/DataflowOAuthIT.java b/spring-cloud-dataflow-server/src/test/java/org/springframework/cloud/dataflow/integration/test/oauth/DataflowOAuthIT.java index 8fee3ff5a0..a8b2f486e0 100644 --- a/spring-cloud-dataflow-server/src/test/java/org/springframework/cloud/dataflow/integration/test/oauth/DataflowOAuthIT.java +++ b/spring-cloud-dataflow-server/src/test/java/org/springframework/cloud/dataflow/integration/test/oauth/DataflowOAuthIT.java @@ -18,6 +18,7 @@ import java.util.concurrent.TimeUnit; +import com.jayway.jsonpath.JsonPath; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,6 +27,7 @@ import org.springframework.cloud.dataflow.integration.test.db.AbstractDataflowTests; import org.springframework.cloud.dataflow.integration.test.tags.Oauth; import org.springframework.cloud.dataflow.integration.test.tags.TagNames; +import org.springframework.cloud.dataflow.rest.client.support.VersionUtils; import org.springframework.test.context.ActiveProfiles; import static org.awaitility.Awaitility.with; @@ -54,12 +56,26 @@ public void testSecuredSetup() throws Exception { .ignoreExceptions() .atMost(120, TimeUnit.SECONDS) .until(() -> { - log.debug("Checking auth using curl"); + log.info("Checking auth using curl"); ExecResult cmdResult = execInToolsContainer("curl", "-u", "janne:janne", "http://dataflow:9393/about"); String response = cmdResult.getStdout(); log.debug("Response is {}", response); - boolean ok = response.contains("\"authenticated\":true") && response.contains("\"username\":\"janne\""); + Boolean authenticated = JsonPath.parse(response).read("$.securityInfo.authenticated", Boolean.class); + String username = JsonPath.parse(response).read("$.securityInfo.username", String.class); + boolean ok = Boolean.TRUE.equals(authenticated) && "janne".equals(username); log.info("Check for oauth {}", ok); + if (ok) { + String version = JsonPath.parse(response).read("$.versionInfo.core.version"); + log.info("Version=[{}]", version); + String api = "tasks/executions"; + if (VersionUtils.isDataFlowServerVersionGreaterThanOrEqualToRequiredVersion( + VersionUtils.getThreePartVersion(version), "2.11.3")) { + api = "tasks/thinexecutions"; + } + cmdResult = execInToolsContainer("curl", "-u", "janne:janne", "http://dataflow:9393/" + api); + response = cmdResult.getStdout(); + ok = !JsonPath.parse(response).read("$._links.self.href", String.class).isEmpty(); + } return ok; }); }