Skip to content

Commit

Permalink
Added verification of tasks/thinexecutions in DataflowOAuthIT.
Browse files Browse the repository at this point in the history
  • Loading branch information
corneil authored and cppwfs committed Sep 6, 2024
1 parent d970ac1 commit c9c7721
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
});
}
Expand Down

0 comments on commit c9c7721

Please sign in to comment.