|
18 | 18 |
|
19 | 19 | import java.util.concurrent.TimeUnit;
|
20 | 20 |
|
| 21 | +import com.jayway.jsonpath.JsonPath; |
21 | 22 | import org.junit.jupiter.api.Test;
|
22 | 23 | import org.slf4j.Logger;
|
23 | 24 | import org.slf4j.LoggerFactory;
|
|
26 | 27 | import org.springframework.cloud.dataflow.integration.test.db.AbstractDataflowTests;
|
27 | 28 | import org.springframework.cloud.dataflow.integration.test.tags.Oauth;
|
28 | 29 | import org.springframework.cloud.dataflow.integration.test.tags.TagNames;
|
| 30 | +import org.springframework.cloud.dataflow.rest.client.support.VersionUtils; |
29 | 31 | import org.springframework.test.context.ActiveProfiles;
|
30 | 32 |
|
31 | 33 | import static org.awaitility.Awaitility.with;
|
@@ -54,12 +56,26 @@ public void testSecuredSetup() throws Exception {
|
54 | 56 | .ignoreExceptions()
|
55 | 57 | .atMost(120, TimeUnit.SECONDS)
|
56 | 58 | .until(() -> {
|
57 |
| - log.debug("Checking auth using curl"); |
| 59 | + log.info("Checking auth using curl"); |
58 | 60 | ExecResult cmdResult = execInToolsContainer("curl", "-u", "janne:janne", "http://dataflow:9393/about");
|
59 | 61 | String response = cmdResult.getStdout();
|
60 | 62 | log.debug("Response is {}", response);
|
61 |
| - boolean ok = response.contains("\"authenticated\":true") && response.contains("\"username\":\"janne\""); |
| 63 | + Boolean authenticated = JsonPath.parse(response).read("$.securityInfo.authenticated", Boolean.class); |
| 64 | + String username = JsonPath.parse(response).read("$.securityInfo.username", String.class); |
| 65 | + boolean ok = Boolean.TRUE.equals(authenticated) && "janne".equals(username); |
62 | 66 | log.info("Check for oauth {}", ok);
|
| 67 | + if (ok) { |
| 68 | + String version = JsonPath.parse(response).read("$.versionInfo.core.version"); |
| 69 | + log.info("Version=[{}]", version); |
| 70 | + String api = "tasks/executions"; |
| 71 | + if (VersionUtils.isDataFlowServerVersionGreaterThanOrEqualToRequiredVersion( |
| 72 | + VersionUtils.getThreePartVersion(version), "2.11.3")) { |
| 73 | + api = "tasks/thinexecutions"; |
| 74 | + } |
| 75 | + cmdResult = execInToolsContainer("curl", "-u", "janne:janne", "http://dataflow:9393/" + api); |
| 76 | + response = cmdResult.getStdout(); |
| 77 | + ok = !JsonPath.parse(response).read("$._links.self.href", String.class).isEmpty(); |
| 78 | + } |
63 | 79 | return ok;
|
64 | 80 | });
|
65 | 81 | }
|
|
0 commit comments