Skip to content

Commit 8a85798

Browse files
talevybleskes
authored andcommitted
[TEST] fix SecurityDocumentationIT#testGetUsers (#36622)
this test was failing because of two reason - it was creating invalid users with passwords shorter than 6 characters - it was expecting 7 total users to be returned, but it should be 9
1 parent 690b10a commit 8a85798

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ public class SecurityDocumentationIT extends ESRestHighLevelClientTestCase {
114114
public void testGetUsers() throws Exception {
115115
final RestHighLevelClient client = highLevelClient();
116116
String[] usernames = new String[] {"user1", "user2", "user3"};
117-
addUser(client, usernames[0], randomAlphaOfLength(4));
118-
addUser(client, usernames[1], randomAlphaOfLength(4));
119-
addUser(client, usernames[2], randomAlphaOfLength(4));
117+
addUser(client, usernames[0], randomAlphaOfLengthBetween(6, 10));
118+
addUser(client, usernames[1], randomAlphaOfLengthBetween(6, 10));
119+
addUser(client, usernames[2], randomAlphaOfLengthBetween(6, 10));
120120
{
121121
//tag::get-users-request
122122
GetUsersRequest request = new GetUsersRequest(usernames[0]);
@@ -131,7 +131,7 @@ public void testGetUsers() throws Exception {
131131

132132
assertNotNull(response);
133133
assertThat(users.size(), equalTo(1));
134-
assertThat(users.get(0), is(usernames[0]));
134+
assertThat(users.get(0).getUsername(), is(usernames[0]));
135135
}
136136

137137
{
@@ -159,8 +159,10 @@ public void testGetUsers() throws Exception {
159159
List<User> users = new ArrayList<>(3);
160160
users.addAll(response.getUsers());
161161
assertNotNull(response);
162-
// 4 system users plus the three we created
163-
assertThat(users.size(), equalTo(7));
162+
// 9 users are expected to be returned
163+
// test_users (3): user1, user2, user3
164+
// system_users (6): elastic, beats_system, apm_system, logstash_system, kibana, remote_monitoring_user
165+
assertThat(users.size(), equalTo(9));
164166
}
165167

166168
{

0 commit comments

Comments
 (0)