Skip to content

Commit fbb42f1

Browse files
authored
Fix ProfileIntegTests (#117888) (#118060)
The test setup for `ProfileIntegTests` is flawed, where the full name of a user can be a substring of other profile names (e.g., `SER` is a substring of `User <random-string>-space1`) -- when that's passed into suggest call with the `*` space, we get a match on all profiles, instead of only the one profile expected in the test, since we are matching on e.g. `SER*`. This PR restricts the setup to avoid the wildcard profile for that particular test. Closes: #117782
1 parent 7cb1cbe commit fbb42f1

File tree

1 file changed

+4
-1
lines changed
  • x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile

1 file changed

+4
-1
lines changed

x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ProfileIntegTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,11 @@ public void testSuggestProfilesWithHint() throws IOException {
557557
equalTo(profileHits4.subList(2, profileHits4.size()))
558558
);
559559

560+
// Exclude profile for "*" space since that can match _all_ profiles, if the full name is a substring of "user" or the name of
561+
// another profile
562+
final List<Profile> nonWildcardProfiles = profiles.stream().filter(p -> false == p.user().fullName().endsWith("*")).toList();
560563
// A record will not be included if name does not match even when it has matching hint
561-
final Profile hintedProfile5 = randomFrom(profiles);
564+
final Profile hintedProfile5 = randomFrom(nonWildcardProfiles);
562565
final List<Profile> profileHits5 = Arrays.stream(
563566
doSuggest(
564567
Set.of(),

0 commit comments

Comments
 (0)