Skip to content

Commit e3373e3

Browse files
committed
[Test] Avoid use the same token name in different tests (elastic#74280)
The name token1 is used in both testGetServiceAccountCredentials and testCreateServiceAccountToken. There are times when the two tests are not fully isolated. This leads to test failure because indexing of the service token document must be an op_create. This PR fixes the failure by using a different token name in testGetServiceAccountCredentials.
1 parent 82a0344 commit e3373e3

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SecurityDocumentationIT.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,7 +2611,6 @@ public void onFailure(Exception e) {
26112611
}
26122612
}
26132613

2614-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/74278")
26152614
public void testCreateServiceAccountToken() throws IOException {
26162615
RestHighLevelClient client = highLevelClient();
26172616
{
@@ -2720,14 +2719,13 @@ public void onFailure(Exception e) {
27202719
}
27212720
}
27222721

2723-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/74278")
27242722
public void testGetServiceAccountCredentials() throws IOException {
27252723
RestHighLevelClient client = highLevelClient();
27262724
final CreateServiceAccountTokenRequest createServiceAccountTokenRequest =
2727-
new CreateServiceAccountTokenRequest("elastic", "fleet-server", "token1");
2725+
new CreateServiceAccountTokenRequest("elastic", "fleet-server", "token2");
27282726
final CreateServiceAccountTokenResponse createServiceAccountTokenResponse =
27292727
client.security().createServiceAccountToken(createServiceAccountTokenRequest, RequestOptions.DEFAULT);
2730-
assertThat(createServiceAccountTokenResponse.getName(), equalTo("token1"));
2728+
assertThat(createServiceAccountTokenResponse.getName(), equalTo("token2"));
27312729

27322730
{
27332731
// tag::get-service-account-credentials-request
@@ -2749,7 +2747,7 @@ public void testGetServiceAccountCredentials() throws IOException {
27492747
// end::get-service-account-credentials-response
27502748
assertThat(principal, equalTo("elastic/fleet-server"));
27512749
assertThat(serviceTokenInfos.size(), equalTo(1));
2752-
assertThat(tokenName, equalTo("token1"));
2750+
assertThat(tokenName, equalTo("token2"));
27532751
assertThat(tokenSource, equalTo("index"));
27542752
}
27552753

@@ -2783,7 +2781,7 @@ public void onFailure(Exception e) {
27832781
assertNotNull(future.actionGet());
27842782
assertThat(future.actionGet().getPrincipal(), equalTo("elastic/fleet-server"));
27852783
assertThat(future.actionGet().getServiceTokenInfos().size(), equalTo(1));
2786-
assertThat(future.actionGet().getServiceTokenInfos().get(0), equalTo(new ServiceTokenInfo("token1", "index")));
2784+
assertThat(future.actionGet().getServiceTokenInfos().get(0), equalTo(new ServiceTokenInfo("token2", "index")));
27872785
}
27882786
}
27892787

0 commit comments

Comments
 (0)