Skip to content

Commit 8d1496b

Browse files
committed
Fix TokenBackwardsCompatibilityIT
1 parent ff242e8 commit 8d1496b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TokenBackwardsCompatibilityIT.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void testGeneratingTokenInOldCluster() throws Exception {
4949
}
5050
}
5151

52-
Request createTokenRequest = new Request("POST", "/_security/oauth2/token");
52+
Request createTokenRequest = new Request("POST", "/_xpack/security/oauth2/token");
5353
createTokenRequest.setJsonEntity(
5454
"{\n" +
5555
" \"username\": \"test_user\",\n" +
@@ -61,7 +61,7 @@ public void testGeneratingTokenInOldCluster() throws Exception {
6161
Map<String, Object> responseMap = entityAsMap(response);
6262
String token = (String) responseMap.get("access_token");
6363
assertNotNull(token);
64-
assertTokenWorks(token);
64+
assertTokenWorks(token, true);
6565

6666
Request indexRequest1 = new Request("PUT", "token_backwards_compatibility_it/doc/old_cluster_token1");
6767
indexRequest1.setJsonEntity(
@@ -70,13 +70,13 @@ public void testGeneratingTokenInOldCluster() throws Exception {
7070
"}");
7171
client().performRequest(indexRequest1);
7272

73-
Request createSecondTokenRequest = new Request("POST", "/_security/oauth2/token");
73+
Request createSecondTokenRequest = new Request("POST", "/_xpack/security/oauth2/token");
7474
createSecondTokenRequest.setEntity(createTokenRequest.getEntity());
7575
response = client().performRequest(createSecondTokenRequest);
7676
responseMap = entityAsMap(response);
7777
token = (String) responseMap.get("access_token");
7878
assertNotNull(token);
79-
assertTokenWorks(token);
79+
assertTokenWorks(token, true);
8080
Request indexRequest2 = new Request("PUT", "token_backwards_compatibility_it/doc/old_cluster_token2");
8181
indexRequest2.setJsonEntity(
8282
"{\n" +
@@ -91,7 +91,7 @@ public void testTokenWorksInMixedOrUpgradedCluster() throws Exception {
9191
Response getResponse = client().performRequest(new Request("GET", "token_backwards_compatibility_it/doc/old_cluster_token1"));
9292
assertOK(getResponse);
9393
Map<String, Object> source = (Map<String, Object>) entityAsMap(getResponse).get("_source");
94-
assertTokenWorks((String) source.get("token"));
94+
assertTokenWorks((String) source.get("token"), false);
9595
}
9696

9797
public void testMixedCluster() throws Exception {
@@ -109,7 +109,7 @@ public void testMixedCluster() throws Exception {
109109
assertTokenDoesNotWork(token);
110110

111111
// create token and refresh on version that supports it
112-
Request createTokenRequest = new Request("POST", "/_/security/oauth2/token");
112+
Request createTokenRequest = new Request("POST", "/_security/oauth2/token");
113113
createTokenRequest.setJsonEntity(
114114
"{\n" +
115115
" \"username\": \"test_user\",\n" +
@@ -198,7 +198,12 @@ public void testUpgradedCluster() throws Exception {
198198
}
199199

200200
private void assertTokenWorks(String token) throws IOException {
201-
Request request = new Request("GET", "/_security/_authenticate");
201+
assertTokenWorks(token, false);
202+
}
203+
204+
private void assertTokenWorks(String token, boolean oldCluster) throws IOException {
205+
Request request = oldCluster ? new Request("GET", "/_xpack/security/_authenticate") :
206+
new Request("GET", "/_security/_authenticate");
202207
RequestOptions.Builder options = request.getOptions().toBuilder();
203208
options.addHeader(HttpHeaders.AUTHORIZATION, "Bearer " + token);
204209
request.setOptions(options);

0 commit comments

Comments
 (0)