fix compile errors caused by cleanups in core
Original commit: elastic/x-pack-elasticsearch@a28d4b5ba0
This commit is contained in:
parent
3653bdc1b5
commit
ae66d4794a
|
@ -11,6 +11,8 @@ import org.elasticsearch.action.search.SearchPhaseExecutionException;
|
|||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.script.Template;
|
||||
import org.elasticsearch.script.mustache.MustacheScriptEngineService;
|
||||
import org.elasticsearch.shield.authc.support.SecuredString;
|
||||
import org.elasticsearch.test.ShieldIntegTestCase;
|
||||
import org.elasticsearch.test.ShieldSettingsSource;
|
||||
|
@ -104,9 +106,7 @@ public class ShieldCachePermissionTests extends ShieldIntegTestCase {
|
|||
@Test
|
||||
public void testThatScriptServiceDoesntLeakData() {
|
||||
SearchResponse response = client().prepareSearch("data").setTypes("a")
|
||||
.setTemplateType(ScriptService.ScriptType.INDEXED)
|
||||
.setTemplateName("testTemplate")
|
||||
.setTemplateParams(Collections.<String, Object>singletonMap("name", "token"))
|
||||
.setTemplate(new Template("testTemplate", ScriptService.ScriptType.INDEXED, MustacheScriptEngineService.NAME, null, Collections.<String, Object>singletonMap("name", "token")))
|
||||
.execute().actionGet();
|
||||
assertThat(response.isTimedOut(), is(false));
|
||||
assertThat(response.getHits().hits().length, is(1));
|
||||
|
@ -114,9 +114,7 @@ public class ShieldCachePermissionTests extends ShieldIntegTestCase {
|
|||
// Repeat with unauthorized user!!!!
|
||||
try {
|
||||
response = client().prepareSearch("data").setTypes("a")
|
||||
.setTemplateType(ScriptService.ScriptType.INDEXED)
|
||||
.setTemplateName("testTemplate")
|
||||
.setTemplateParams(Collections.<String, Object>singletonMap("name", "token"))
|
||||
.setTemplate(new Template("testTemplate", ScriptService.ScriptType.INDEXED, MustacheScriptEngineService.NAME, null, Collections.<String, Object>singletonMap("name", "token")))
|
||||
.putHeader("Authorization", basicAuthHeaderValue(READ_ONE_IDX_USER, new SecuredString("changeme".toCharArray())))
|
||||
.execute().actionGet();
|
||||
fail("search phase exception should have been thrown! response was:\n" + response.toString());
|
||||
|
|
|
@ -245,9 +245,8 @@ public final class WatcherUtils {
|
|||
searchRequest.searchType(searchType);
|
||||
searchRequest.indicesOptions(indicesOptions);
|
||||
if (searchBody != null) {
|
||||
// TODO (2.0 upgrade): move back to BytesReference instead of dealing with the array directly
|
||||
assert searchBody.hasArray();
|
||||
searchRequest.source(searchBody.array(), searchBody.arrayOffset(), searchBody.length());
|
||||
searchRequest.source(searchBody);
|
||||
}
|
||||
if (templateBody != null) {
|
||||
// Unfortunately because of SearchRequest#templateSource(BytesReference, boolean) has been removed in 1.6 and
|
||||
|
|
|
@ -105,7 +105,7 @@ public class WatcherUtilsTests extends ESTestCase {
|
|||
SearchSourceBuilder searchSourceBuilder = SearchSourceBuilder.searchSource().query(QueryBuilders.matchAllQuery()).size(11);
|
||||
XContentBuilder searchSourceJsonBuilder = jsonBuilder();
|
||||
searchSourceBuilder.toXContent(searchSourceJsonBuilder, ToXContent.EMPTY_PARAMS);
|
||||
String expectedSource = searchSourceJsonBuilder.string();
|
||||
BytesReference expectedSource = searchSourceJsonBuilder.bytes();
|
||||
expectedRequest.source(expectedSource);
|
||||
|
||||
if (randomBoolean()) {
|
||||
|
@ -135,7 +135,7 @@ public class WatcherUtilsTests extends ESTestCase {
|
|||
assertThat(result.types(), arrayContainingInAnyOrder(expectedRequest.types()));
|
||||
assertThat(result.indicesOptions(), equalTo(expectedRequest.indicesOptions()));
|
||||
assertThat(result.searchType(), equalTo(expectedRequest.searchType()));
|
||||
assertThat(result.source().toUtf8(), equalTo(expectedSource));
|
||||
assertThat(result.source().toUtf8(), equalTo(expectedSource.toUtf8()));
|
||||
assertThat(result.templateSource(), equalTo(expectedRequest.templateSource()));
|
||||
}
|
||||
|
||||
|
|
|
@ -122,9 +122,8 @@ public final class WatcherTestUtils {
|
|||
}
|
||||
|
||||
public static SearchRequest matchAllRequest(IndicesOptions indicesOptions) {
|
||||
// TODO (2.0 upgrade): move back to BytesReference, instead of converting to a string
|
||||
SearchRequest request = new SearchRequest(Strings.EMPTY_ARRAY)
|
||||
.source(SearchSourceBuilder.searchSource().query(matchAllQuery()).buildAsBytes(XContentType.JSON).toUtf8());
|
||||
.source(SearchSourceBuilder.searchSource().query(matchAllQuery()).buildAsBytes(XContentType.JSON));
|
||||
if (indicesOptions != null) {
|
||||
request.indicesOptions(indicesOptions);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ public class SearchTransformTests extends ESIntegTestCase {
|
|||
.startObject("query")
|
||||
.startObject("match_all").endObject()
|
||||
.endObject()
|
||||
.endObject());
|
||||
.endObject().bytes());
|
||||
SearchTransform searchTransform = TransformBuilders.searchTransform(request).build();
|
||||
ExecutableSearchTransform transform = new ExecutableSearchTransform(searchTransform, logger, ClientProxy.of(client()), null, new DynamicIndexName.Parser());
|
||||
|
||||
|
@ -163,7 +163,7 @@ public class SearchTransformTests extends ESIntegTestCase {
|
|||
.startObject("query")
|
||||
.startObject("_unknown_query_").endObject()
|
||||
.endObject()
|
||||
.endObject());
|
||||
.endObject().bytes());
|
||||
SearchTransform searchTransform = TransformBuilders.searchTransform(request).build();
|
||||
ExecutableSearchTransform transform = new ExecutableSearchTransform(searchTransform, logger, ClientProxy.of(client()), null, new DynamicIndexName.Parser());
|
||||
|
||||
|
|
Loading…
Reference in New Issue