@@ -49,7 +49,7 @@ public void testGeneratingTokenInOldCluster() throws Exception {
49
49
}
50
50
}
51
51
52
- Request createTokenRequest = new Request ("POST" , "/_security /oauth2/token" );
52
+ Request createTokenRequest = new Request ("POST" , "/_xpack/security /oauth2/token" );
53
53
createTokenRequest .setJsonEntity (
54
54
"{\n " +
55
55
" \" username\" : \" test_user\" ,\n " +
@@ -61,7 +61,7 @@ public void testGeneratingTokenInOldCluster() throws Exception {
61
61
Map <String , Object > responseMap = entityAsMap (response );
62
62
String token = (String ) responseMap .get ("access_token" );
63
63
assertNotNull (token );
64
- assertTokenWorks (token );
64
+ assertTokenWorks (token , true );
65
65
66
66
Request indexRequest1 = new Request ("PUT" , "token_backwards_compatibility_it/doc/old_cluster_token1" );
67
67
indexRequest1 .setJsonEntity (
@@ -70,13 +70,13 @@ public void testGeneratingTokenInOldCluster() throws Exception {
70
70
"}" );
71
71
client ().performRequest (indexRequest1 );
72
72
73
- Request createSecondTokenRequest = new Request ("POST" , "/_security /oauth2/token" );
73
+ Request createSecondTokenRequest = new Request ("POST" , "/_xpack/security /oauth2/token" );
74
74
createSecondTokenRequest .setEntity (createTokenRequest .getEntity ());
75
75
response = client ().performRequest (createSecondTokenRequest );
76
76
responseMap = entityAsMap (response );
77
77
token = (String ) responseMap .get ("access_token" );
78
78
assertNotNull (token );
79
- assertTokenWorks (token );
79
+ assertTokenWorks (token , true );
80
80
Request indexRequest2 = new Request ("PUT" , "token_backwards_compatibility_it/doc/old_cluster_token2" );
81
81
indexRequest2 .setJsonEntity (
82
82
"{\n " +
@@ -91,7 +91,7 @@ public void testTokenWorksInMixedOrUpgradedCluster() throws Exception {
91
91
Response getResponse = client ().performRequest (new Request ("GET" , "token_backwards_compatibility_it/doc/old_cluster_token1" ));
92
92
assertOK (getResponse );
93
93
Map <String , Object > source = (Map <String , Object >) entityAsMap (getResponse ).get ("_source" );
94
- assertTokenWorks ((String ) source .get ("token" ));
94
+ assertTokenWorks ((String ) source .get ("token" ), false );
95
95
}
96
96
97
97
public void testMixedCluster () throws Exception {
@@ -109,7 +109,7 @@ public void testMixedCluster() throws Exception {
109
109
assertTokenDoesNotWork (token );
110
110
111
111
// 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" );
113
113
createTokenRequest .setJsonEntity (
114
114
"{\n " +
115
115
" \" username\" : \" test_user\" ,\n " +
@@ -198,7 +198,12 @@ public void testUpgradedCluster() throws Exception {
198
198
}
199
199
200
200
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" );
202
207
RequestOptions .Builder options = request .getOptions ().toBuilder ();
203
208
options .addHeader (HttpHeaders .AUTHORIZATION , "Bearer " + token );
204
209
request .setOptions (options );
0 commit comments