diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java index 6253bf86c89..2cbafbfb4da 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java @@ -406,7 +406,7 @@ public class SecurityIndexSearcherWrapper extends IndexSearcherWrapper { } }; QueryRewriteContext copy = new QueryRewriteContext(original.getIndexSettings(), original.getMapperService(), scriptService, null, - client, original.getIndexReader(), original.getClusterState()); + client, original.getIndexReader(), original.getClusterState(), original::nowInMillis); queryBuilder.rewrite(copy); } } diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperIntegrationTests.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperIntegrationTests.java index 6e9a2eebc17..a919b32d723 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperIntegrationTests.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperIntegrationTests.java @@ -75,7 +75,7 @@ public class SecurityIndexSearcherWrapperIntegrationTests extends ESTestCase { Client client = mock(Client.class); when(client.settings()).thenReturn(Settings.EMPTY); final long nowInMillis = randomPositiveLong(); - QueryShardContext realQueryShardContext = new QueryShardContext(indexSettings, null, null, mapperService, null, + QueryShardContext realQueryShardContext = new QueryShardContext(shardId.id(), indexSettings, null, null, mapperService, null, null, indicesQueriesRegistry, client, null, null, () -> nowInMillis); QueryShardContext queryShardContext = spy(realQueryShardContext); QueryParseContext queryParseContext = mock(QueryParseContext.class); diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperUnitTests.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperUnitTests.java index 1a346ee4175..874f3e53373 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperUnitTests.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperUnitTests.java @@ -812,7 +812,9 @@ public class SecurityIndexSearcherWrapperUnitTests extends ESTestCase { public void testFailIfQueryUsesClient() throws Exception { Client client = mock(Client.class); when(client.settings()).thenReturn(Settings.EMPTY); - QueryRewriteContext context = new QueryRewriteContext(null, mapperService, scriptService, null, client, null, null); + final long nowInMillis = randomPositiveLong(); + QueryRewriteContext context = new QueryRewriteContext(null, mapperService, scriptService, null, client, null, null, + () -> nowInMillis); QueryBuilder queryBuilder1 = new TermsQueryBuilder("field", "val1", "val2"); SecurityIndexSearcherWrapper.failIfQueryUsesClient(scriptService, queryBuilder1, context);