diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java index 7fc958cfafb..5af99ffb19d 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java @@ -601,7 +601,9 @@ public class TokenServiceTests extends ESTestCase { final byte[] randomBytes = new byte[numBytes]; random().nextBytes(randomBytes); TokenService tokenService = createTokenService(tokenServiceEnabledSettings, systemUTC()); - + // mock another random token so that we don't find a token in TokenService#getUserTokenFromId + Authentication authentication = new Authentication(new User("joe", "admin"), new RealmRef("native_realm", "native", "node1"), null); + mockGetTokenFromId(tokenService, UUIDs.randomBase64UUID(), authentication, false); ThreadContext requestContext = new ThreadContext(Settings.EMPTY); storeTokenHeader(requestContext, Base64.getEncoder().encodeToString(randomBytes));