diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java b/plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java index a9bb3a9b72d..7f6d718b222 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java @@ -56,6 +56,7 @@ import org.elasticsearch.index.shard.IndexSearcherWrapper; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardUtils; import org.elasticsearch.license.XPackLicenseState; +import org.elasticsearch.script.ExecutableScript; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptContext; import org.elasticsearch.script.ScriptService; @@ -274,7 +275,7 @@ public class SecurityIndexSearcherWrapper extends IndexSearcherWrapper { params.put("_user", userModel); // Always enforce mustache script lang: script = new Script(script.getType(), "mustache", script.getIdOrCode(), script.getOptions(), params); - CompiledTemplate compiledTemplate = scriptService.compileTemplate(script, ScriptContext.EXECUTABLE); + CompiledTemplate compiledTemplate = scriptService.compileTemplate(script, ExecutableScript.CONTEXT); return compiledTemplate.run(script.getParams()); } else { return querySource; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperUnitTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperUnitTests.java index a58cf80675a..a611e6358ef 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperUnitTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperUnitTests.java @@ -68,6 +68,7 @@ import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.TermsLookup; import org.elasticsearch.license.XPackLicenseState; +import org.elasticsearch.script.ExecutableScript; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptContext; import org.elasticsearch.script.ScriptService; @@ -458,7 +459,7 @@ public class SecurityIndexSearcherWrapperUnitTests extends ESTestCase { }; CompiledTemplate compiledScript = mock(CompiledTemplate.class); - when(scriptService.compileTemplate(any(Script.class), eq(ScriptContext.EXECUTABLE))).thenReturn(compiledScript); + when(scriptService.compileTemplate(any(Script.class), eq(ExecutableScript.CONTEXT))).thenReturn(compiledScript); XContentBuilder builder = jsonBuilder(); String query = new TermQueryBuilder("field", "{{_user.username}}").toXContent(builder, ToXContent.EMPTY_PARAMS).string(); @@ -469,7 +470,7 @@ public class SecurityIndexSearcherWrapperUnitTests extends ESTestCase { securityIndexSearcherWrapper.evaluateTemplate(querySource); ArgumentCaptor