Skip to content

Added verification of tasks/thinexecutions in DataflowOAuthIT. #5817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,28 @@ 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";
}
log.info("Checking {}", api);
cmdResult = execInToolsContainer("curl", "-u", "janne:janne", "http://dataflow:9393/" + api);
response = cmdResult.getStdout();
log.debug("Response is {}", response);
ok = !JsonPath.parse(response).read("$._links.self.href", String.class).isEmpty();
}
return ok;
});
}
Expand Down
Loading