Followup from elastic/elasticsearchelastic/elasticsearch#23042 (elastic/elasticsearch#4895)
This change accomodates for the renamings done in elastic/elasticsearchelastic/elasticsearch#23042 Original commit: elastic/x-pack-elasticsearch@c290c8ecc4
This commit is contained in:
parent
734a4ee66d
commit
0e779b41de
|
@ -162,7 +162,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
.request();
|
||||
request.indicesOptions().ignoreUnavailable();
|
||||
InternalClient.fetchAllByEntity(client, request, listener, (hit) -> {
|
||||
UserAndPassword u = transformUser(hit.getId(), hit.getSource());
|
||||
UserAndPassword u = transformUser(hit.getId(), hit.getSourceAsMap());
|
||||
return u != null ? u.user() : null;
|
||||
});
|
||||
} catch (Exception e) {
|
||||
|
@ -674,7 +674,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
assert searchResponse.getHits().getTotalHits() <= 10 : "there are more than 10 reserved users we need to change " +
|
||||
"this to retrieve them all!";
|
||||
for (SearchHit searchHit : searchResponse.getHits().getHits()) {
|
||||
Map<String, Object> sourceMap = searchHit.getSource();
|
||||
Map<String, Object> sourceMap = searchHit.getSourceAsMap();
|
||||
String password = (String) sourceMap.get(User.Fields.PASSWORD.getPreferredName());
|
||||
Boolean enabled = (Boolean) sourceMap.get(Fields.ENABLED.getPreferredName());
|
||||
if (password == null || password.isEmpty()) {
|
||||
|
|
|
@ -133,12 +133,12 @@ public class WatcherService extends AbstractComponent {
|
|||
throw new ElasticsearchException("Partial response while loading watches");
|
||||
}
|
||||
|
||||
while (response.getHits().hits().length != 0) {
|
||||
while (response.getHits().getHits().length != 0) {
|
||||
for (SearchHit hit : response.getHits()) {
|
||||
String id = hit.getId();
|
||||
try {
|
||||
Watch watch = parser.parse(id, true, hit.getSourceRef(), XContentType.JSON);
|
||||
watch.version(hit.version());
|
||||
watch.version(hit.getVersion());
|
||||
watches.add(watch);
|
||||
} catch (Exception e) {
|
||||
logger.error((Supplier<?>) () -> new ParameterizedMessage("couldn't load watch [{}], ignoring it...", id), e);
|
||||
|
|
|
@ -201,12 +201,12 @@ public class TriggeredWatchStore extends AbstractComponent {
|
|||
response.getSuccessfulShards());
|
||||
}
|
||||
|
||||
while (response.getHits().hits().length != 0) {
|
||||
while (response.getHits().getHits().length != 0) {
|
||||
for (SearchHit sh : response.getHits()) {
|
||||
String id = sh.getId();
|
||||
try {
|
||||
TriggeredWatch triggeredWatch = triggeredWatchParser.parse(id, sh.version(), sh.getSourceRef());
|
||||
logger.trace("loaded triggered watch [{}/{}/{}]", sh.index(), sh.type(), sh.id());
|
||||
TriggeredWatch triggeredWatch = triggeredWatchParser.parse(id, sh.getVersion(), sh.getSourceRef());
|
||||
logger.trace("loaded triggered watch [{}/{}/{}]", sh.getIndex(), sh.getType(), sh.getId());
|
||||
triggeredWatches.add(triggeredWatch);
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
|
|
|
@ -81,7 +81,7 @@ public class TransportWatcherStatsAction extends WatcherTransportAction<WatcherS
|
|||
SearchRequest searchRequest =
|
||||
Requests.searchRequest(Watch.INDEX).types(Watch.DOC_TYPE).source(new SearchSourceBuilder().size(0));
|
||||
client.search(searchRequest, ActionListener.wrap(searchResponse -> {
|
||||
statsResponse.setWatchesCount(searchResponse.getHits().totalHits());
|
||||
statsResponse.setWatchesCount(searchResponse.getHits().getTotalHits());
|
||||
listener.onResponse(statsResponse);
|
||||
},
|
||||
e -> listener.onResponse(statsResponse)));
|
||||
|
|
|
@ -153,12 +153,12 @@ public class OldSecurityIndexBackwardsCompatibilityTests extends AbstractOldXPac
|
|||
// check that index permissions work as expected
|
||||
SearchResponse searchResponse = bwcTestUserClient.prepareSearch("index1", "index2").get();
|
||||
assertEquals(2, searchResponse.getHits().getTotalHits());
|
||||
assertEquals("foo", searchResponse.getHits().getHits()[0].getSource().get("title"));
|
||||
assertEquals("bwc_test_user should be able to see this field", searchResponse.getHits().getHits()[0].getSource().get("body"));
|
||||
assertNull(searchResponse.getHits().getHits()[0].getSource().get("secured_body"));
|
||||
assertEquals("foo", searchResponse.getHits().getHits()[1].getSource().get("title"));
|
||||
assertEquals("bwc_test_user should be able to see this field", searchResponse.getHits().getHits()[1].getSource().get("body"));
|
||||
assertNull(searchResponse.getHits().getHits()[1].getSource().get("secured_body"));
|
||||
assertEquals("foo", searchResponse.getHits().getHits()[0].getSourceAsMap().get("title"));
|
||||
assertEquals("bwc_test_user should be able to see this field", searchResponse.getHits().getHits()[0].getSourceAsMap().get("body"));
|
||||
assertNull(searchResponse.getHits().getHits()[0].getSourceAsMap().get("secured_body"));
|
||||
assertEquals("foo", searchResponse.getHits().getHits()[1].getSourceAsMap().get("title"));
|
||||
assertEquals("bwc_test_user should be able to see this field", searchResponse.getHits().getHits()[1].getSourceAsMap().get("body"));
|
||||
assertNull(searchResponse.getHits().getHits()[1].getSourceAsMap().get("secured_body"));
|
||||
|
||||
Exception e = expectThrows(ElasticsearchSecurityException.class, () -> bwcTestUserClient.prepareSearch("index3").get());
|
||||
assertEquals("action [indices:data/read/search] is unauthorized for user [bwc_test_user]", e.getMessage());
|
||||
|
@ -180,7 +180,7 @@ public class OldSecurityIndexBackwardsCompatibilityTests extends AbstractOldXPac
|
|||
basicAuthHeaderValue("another_bwc_test_user", "123123")
|
||||
)).prepareSearch("index3").get();
|
||||
assertEquals(1, searchResponse.getHits().getTotalHits());
|
||||
assertEquals("bwc_test_user should not see this index", searchResponse.getHits().getHits()[0].getSource().get("title"));
|
||||
assertEquals("bwc_test_user should not see this index", searchResponse.getHits().getHits()[0].getSourceAsMap().get("title"));
|
||||
|
||||
userResponse = securityClient.preparePutUser("meta_bwc_test_user", "123123".toCharArray(), "test_role").email("a@b.c")
|
||||
.metadata(singletonMap("test", 1)).get();
|
||||
|
|
|
@ -109,16 +109,16 @@ public class DocumentAndFieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.get();
|
||||
assertHitCount(response, 1);
|
||||
assertSearchHits(response, "1");
|
||||
assertThat(response.getHits().getAt(0).getSource().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).getSource().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
||||
.prepareSearch("test")
|
||||
.get();
|
||||
assertHitCount(response, 1);
|
||||
assertSearchHits(response, "2");
|
||||
assertThat(response.getHits().getAt(0).getSource().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).getSource().get("field2").toString(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user4", USERS_PASSWD)))
|
||||
.prepareSearch("test")
|
||||
|
@ -126,8 +126,8 @@ public class DocumentAndFieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.get();
|
||||
assertHitCount(response, 2);
|
||||
assertSearchHits(response, "1", "2");
|
||||
assertThat(response.getHits().getAt(0).getSource().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(1).getSource().get("field2").toString(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(1).getSourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
}
|
||||
|
||||
public void testDLSIsAppliedBeforeFLS() throws Exception {
|
||||
|
@ -147,8 +147,8 @@ public class DocumentAndFieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.get();
|
||||
assertHitCount(response, 1);
|
||||
assertSearchHits(response, "2");
|
||||
assertThat(response.getHits().getAt(0).getSource().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).getSource().get("field1").toString(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field1").toString(), equalTo("value2"));
|
||||
|
||||
response = client().filterWithHeader(
|
||||
Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user5", USERS_PASSWD)))
|
||||
|
@ -178,15 +178,15 @@ public class DocumentAndFieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.get();
|
||||
assertHitCount(response, 1);
|
||||
assertThat(response.getHits().getAt(0).getId(), equalTo("1"));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field1"), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field1"), equalTo("value1"));
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
||||
.prepareSearch("test")
|
||||
.get();
|
||||
assertHitCount(response, 1);
|
||||
assertThat(response.getHits().getAt(0).getId(), equalTo("2"));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field2"), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field2"), equalTo("value2"));
|
||||
|
||||
// this is a bit weird the document level permission (all docs with field2:value2) don't match with the field level
|
||||
// permissions (field1),
|
||||
|
@ -196,7 +196,7 @@ public class DocumentAndFieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.get();
|
||||
assertHitCount(response, 1);
|
||||
assertThat(response.getHits().getAt(0).getId(), equalTo("2"));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(0));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(0));
|
||||
|
||||
// user4 has all roles
|
||||
response = client().filterWithHeader(
|
||||
|
@ -206,11 +206,11 @@ public class DocumentAndFieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.get();
|
||||
assertHitCount(response, 2);
|
||||
assertThat(response.getHits().getAt(0).getId(), equalTo("1"));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field1"), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field1"), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(1).getId(), equalTo("2"));
|
||||
assertThat(response.getHits().getAt(1).sourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(1).sourceAsMap().get("field2"), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(1).getSourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(1).getSourceAsMap().get("field2"), equalTo("value2"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -311,15 +311,15 @@ public class DocumentLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.get();
|
||||
assertFalse(response.getResponses()[0].isFailure());
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().size(), is(2));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("id"), is(1));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(2));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("id"), is(1));
|
||||
|
||||
assertFalse(response.getResponses()[1].isFailure());
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().size(), is(2));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("id"), is(1));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(2));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("id"), is(1));
|
||||
|
||||
response = client()
|
||||
.filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
||||
|
@ -329,15 +329,15 @@ public class DocumentLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.get();
|
||||
assertFalse(response.getResponses()[0].isFailure());
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().size(), is(2));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("id"), is(2));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(2));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("id"), is(2));
|
||||
|
||||
assertFalse(response.getResponses()[1].isFailure());
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().size(), is(2));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("id"), is(2));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(2));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("id"), is(2));
|
||||
|
||||
response = client()
|
||||
.filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD)))
|
||||
|
@ -349,21 +349,21 @@ public class DocumentLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.get();
|
||||
assertFalse(response.getResponses()[0].isFailure());
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getTotalHits(), is(2L));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().size(), is(2));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("id"), is(1));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(1).getSource().size(), is(2));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(1).getSource().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(1).getSource().get("id"), is(2));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(2));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("id"), is(1));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(1).getSourceAsMap().size(), is(2));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(1).getSourceAsMap().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(1).getSourceAsMap().get("id"), is(2));
|
||||
|
||||
assertFalse(response.getResponses()[1].isFailure());
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getTotalHits(), is(2L));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().size(), is(2));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("id"), is(1));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(1).getSource().size(), is(2));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(1).getSource().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(1).getSource().get("id"), is(2));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(2));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("id"), is(1));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(1).getSourceAsMap().size(), is(2));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(1).getSourceAsMap().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(1).getSourceAsMap().get("id"), is(2));
|
||||
}
|
||||
|
||||
public void testTVApi() throws Exception {
|
||||
|
@ -634,16 +634,16 @@ public class DocumentLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.setQuery(hasChildQuery("child", matchAllQuery(), ScoreMode.None))
|
||||
.get();
|
||||
assertHitCount(searchResponse, 1L);
|
||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("p1"));
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(hasParentQuery("parent", matchAllQuery(), false))
|
||||
.addSort("_uid", SortOrder.ASC)
|
||||
.get();
|
||||
assertHitCount(searchResponse, 3L);
|
||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c1"));
|
||||
assertThat(searchResponse.getHits().getAt(1).id(), equalTo("c2"));
|
||||
assertThat(searchResponse.getHits().getAt(2).id(), equalTo("c3"));
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("c1"));
|
||||
assertThat(searchResponse.getHits().getAt(1).getId(), equalTo("c2"));
|
||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo("c3"));
|
||||
|
||||
// Both user1 and user2 can't see field1 and field2, no parent/child query should yield results:
|
||||
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)))
|
||||
|
@ -676,15 +676,15 @@ public class DocumentLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.setQuery(hasChildQuery("child", matchAllQuery(), ScoreMode.None))
|
||||
.get();
|
||||
assertHitCount(searchResponse, 1L);
|
||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("p1"));
|
||||
|
||||
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD)))
|
||||
.prepareSearch("test")
|
||||
.setQuery(hasParentQuery("parent", matchAllQuery(), false))
|
||||
.get();
|
||||
assertHitCount(searchResponse, 2L);
|
||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c1"));
|
||||
assertThat(searchResponse.getHits().getAt(1).id(), equalTo("c2"));
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("c1"));
|
||||
assertThat(searchResponse.getHits().getAt(1).getId(), equalTo("c2"));
|
||||
}
|
||||
|
||||
public void testScroll() throws Exception {
|
||||
|
@ -717,8 +717,8 @@ public class DocumentLevelSecurityTests extends SecurityIntegTestCase {
|
|||
do {
|
||||
assertNoFailures(response);
|
||||
assertThat(response.getHits().getTotalHits(), is((long) numVisible));
|
||||
assertThat(response.getHits().getAt(0).getSource().size(), is(1));
|
||||
assertThat(response.getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), is(1));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
|
||||
if (response.getScrollId() == null) {
|
||||
break;
|
||||
|
|
|
@ -515,11 +515,11 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.get();
|
||||
assertFalse(response.getResponses()[0].isFailure());
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().size(), is(1));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(1));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().size(), is(1));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(1));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
|
||||
// user2 is granted access to field2 only
|
||||
response = client()
|
||||
|
@ -530,11 +530,11 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.get();
|
||||
assertFalse(response.getResponses()[0].isFailure());
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().size(), is(1));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(1));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().size(), is(1));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(1));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field2"), is("value2"));
|
||||
|
||||
// user3 is granted access to field1 and field2
|
||||
response = client()
|
||||
|
@ -545,13 +545,13 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.get();
|
||||
assertFalse(response.getResponses()[0].isFailure());
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().size(), is(2));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(2));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().size(), is(2));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(2));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field2"), is("value2"));
|
||||
|
||||
// user4 is granted access to no fields, so the search response does say the doc exist, but no fields are returned
|
||||
response = client()
|
||||
|
@ -562,9 +562,9 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.get();
|
||||
assertFalse(response.getResponses()[0].isFailure());
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().size(), is(0));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(0));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().size(), is(0));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(0));
|
||||
|
||||
// user5 has no field level security configured, so all fields are returned
|
||||
response = client()
|
||||
|
@ -575,15 +575,15 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.get();
|
||||
assertFalse(response.getResponses()[0].isFailure());
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().size(), is(3));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field3"), is("value3"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(3));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field3"), is("value3"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().size(), is(3));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field3"), is("value3"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(3));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field3"), is("value3"));
|
||||
|
||||
// user6 has access to field*
|
||||
response = client()
|
||||
|
@ -594,15 +594,15 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.get();
|
||||
assertFalse(response.getResponses()[0].isFailure());
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().size(), is(3));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field3"), is("value3"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(3));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field3"), is("value3"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().size(), is(3));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field3"), is("value3"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(3));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field3"), is("value3"));
|
||||
|
||||
// user7 has roles with field level security and without field level security
|
||||
response = client()
|
||||
|
@ -613,15 +613,15 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.get();
|
||||
assertFalse(response.getResponses()[0].isFailure());
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().size(), is(3));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field3"), is("value3"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(3));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field3"), is("value3"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().size(), is(3));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field3"), is("value3"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(3));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field3"), is("value3"));
|
||||
|
||||
// user8 has roles with field level security with access to field1 and field2
|
||||
response = client()
|
||||
|
@ -632,13 +632,13 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.get();
|
||||
assertFalse(response.getResponses()[0].isFailure());
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().size(), is(2));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSource().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(2));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[0].getResponse().getHits().getAt(0).getSourceAsMap().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getTotalHits(), is(1L));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().size(), is(2));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSource().get("field2"), is("value2"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().size(), is(2));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
assertThat(response.getResponses()[1].getResponse().getHits().getAt(0).getSourceAsMap().get("field2"), is("value2"));
|
||||
}
|
||||
|
||||
public void testFieldStatsApi() throws Exception {
|
||||
|
@ -750,8 +750,8 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
do {
|
||||
assertThat(response.getHits().getTotalHits(), is((long) numDocs));
|
||||
assertThat(response.getHits().getHits().length, is(1));
|
||||
assertThat(response.getHits().getAt(0).getSource().size(), is(1));
|
||||
assertThat(response.getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), is(1));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
|
||||
if (response.getScrollId() == null) {
|
||||
break;
|
||||
|
@ -791,8 +791,8 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.setQuery(constantScoreQuery(termQuery("field1", "value1")))
|
||||
.get();
|
||||
assertHitCount(response, 1);
|
||||
assertThat(response.getHits().getAt(0).getSource().size(), is(1));
|
||||
assertThat(response.getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), is(1));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
||||
.prepareSearch("test")
|
||||
.setQuery(constantScoreQuery(termQuery("field1", "value1")))
|
||||
|
@ -805,10 +805,10 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.setQuery(constantScoreQuery(termQuery("field1", "value1")))
|
||||
.get();
|
||||
assertHitCount(response, 1);
|
||||
assertThat(response.getHits().getAt(0).getSource().size(), is(3));
|
||||
assertThat(response.getHits().getAt(0).getSource().get("field1"), is("value1"));
|
||||
assertThat(response.getHits().getAt(0).getSource().get("field2"), is("value2"));
|
||||
assertThat(response.getHits().getAt(0).getSource().get("field3"), is("value3"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), is(3));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field1"), is("value1"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field2"), is("value2"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field3"), is("value3"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -871,8 +871,8 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.addStoredField("field2")
|
||||
.addStoredField("field3")
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).fields().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).fields().get("field1").<String>getValue(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).getFields().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).getFields().get("field1").<String>getValue(), equalTo("value1"));
|
||||
|
||||
// user2 is granted access to field2 only:
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
||||
|
@ -881,8 +881,8 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.addStoredField("field2")
|
||||
.addStoredField("field3")
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).fields().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).fields().get("field2").<String>getValue(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getFields().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).getFields().get("field2").<String>getValue(), equalTo("value2"));
|
||||
|
||||
// user3 is granted access to field1 and field2:
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD)))
|
||||
|
@ -891,9 +891,9 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.addStoredField("field2")
|
||||
.addStoredField("field3")
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).fields().size(), equalTo(2));
|
||||
assertThat(response.getHits().getAt(0).fields().get("field1").<String>getValue(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).fields().get("field2").<String>getValue(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getFields().size(), equalTo(2));
|
||||
assertThat(response.getHits().getAt(0).getFields().get("field1").<String>getValue(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).getFields().get("field2").<String>getValue(), equalTo("value2"));
|
||||
|
||||
// user4 is granted access to no fields:
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user4", USERS_PASSWD)))
|
||||
|
@ -902,7 +902,7 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.addStoredField("field2")
|
||||
.addStoredField("field3")
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).fields().size(), equalTo(0));
|
||||
assertThat(response.getHits().getAt(0).getFields().size(), equalTo(0));
|
||||
|
||||
// user5 has no field level security configured:
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user5", USERS_PASSWD)))
|
||||
|
@ -911,10 +911,10 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.addStoredField("field2")
|
||||
.addStoredField("field3")
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).fields().size(), equalTo(3));
|
||||
assertThat(response.getHits().getAt(0).fields().get("field1").<String>getValue(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).fields().get("field2").<String>getValue(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).fields().get("field3").<String>getValue(), equalTo("value3"));
|
||||
assertThat(response.getHits().getAt(0).getFields().size(), equalTo(3));
|
||||
assertThat(response.getHits().getAt(0).getFields().get("field1").<String>getValue(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).getFields().get("field2").<String>getValue(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getFields().get("field3").<String>getValue(), equalTo("value3"));
|
||||
|
||||
// user6 has field level security configured with access to field*:
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user6", USERS_PASSWD)))
|
||||
|
@ -923,10 +923,10 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.addStoredField("field2")
|
||||
.addStoredField("field3")
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).fields().size(), equalTo(3));
|
||||
assertThat(response.getHits().getAt(0).fields().get("field1").<String>getValue(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).fields().get("field2").<String>getValue(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).fields().get("field3").<String>getValue(), equalTo("value3"));
|
||||
assertThat(response.getHits().getAt(0).getFields().size(), equalTo(3));
|
||||
assertThat(response.getHits().getAt(0).getFields().get("field1").<String>getValue(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).getFields().get("field2").<String>getValue(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getFields().get("field3").<String>getValue(), equalTo("value3"));
|
||||
|
||||
// user7 has access to all fields due to a mix of roles without field level security and with:
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user7", USERS_PASSWD)))
|
||||
|
@ -935,10 +935,10 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.addStoredField("field2")
|
||||
.addStoredField("field3")
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).fields().size(), equalTo(3));
|
||||
assertThat(response.getHits().getAt(0).fields().get("field1").<String>getValue(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).fields().get("field2").<String>getValue(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).fields().get("field3").<String>getValue(), equalTo("value3"));
|
||||
assertThat(response.getHits().getAt(0).getFields().size(), equalTo(3));
|
||||
assertThat(response.getHits().getAt(0).getFields().get("field1").<String>getValue(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).getFields().get("field2").<String>getValue(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getFields().get("field3").<String>getValue(), equalTo("value3"));
|
||||
|
||||
// user8 has field level security configured with access to field1 and field2:
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user8", USERS_PASSWD)))
|
||||
|
@ -947,9 +947,9 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.addStoredField("field2")
|
||||
.addStoredField("field3")
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).fields().size(), equalTo(2));
|
||||
assertThat(response.getHits().getAt(0).fields().get("field1").<String>getValue(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).fields().get("field2").<String>getValue(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getFields().size(), equalTo(2));
|
||||
assertThat(response.getHits().getAt(0).getFields().get("field1").<String>getValue(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).getFields().get("field2").<String>getValue(), equalTo("value2"));
|
||||
}
|
||||
|
||||
public void testSource() throws Exception {
|
||||
|
@ -965,64 +965,64 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)))
|
||||
.prepareSearch("test")
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
|
||||
// user2 is granted access to field2 only:
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
||||
.prepareSearch("test")
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
|
||||
// user3 is granted access to field1 and field2:
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD)))
|
||||
.prepareSearch("test")
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(2));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(2));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
|
||||
// user4 is granted access to no fields:
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user4", USERS_PASSWD)))
|
||||
.prepareSearch("test")
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(0));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(0));
|
||||
|
||||
// user5 has no field level security configured:
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user5", USERS_PASSWD)))
|
||||
.prepareSearch("test")
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(3));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field3").toString(), equalTo("value3"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(3));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field3").toString(), equalTo("value3"));
|
||||
|
||||
// user6 has field level security configured with access to field*:
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user6", USERS_PASSWD)))
|
||||
.prepareSearch("test")
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(3));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field3").toString(), equalTo("value3"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(3));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field3").toString(), equalTo("value3"));
|
||||
|
||||
// user7 has access to all fields
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user7", USERS_PASSWD)))
|
||||
.prepareSearch("test")
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(3));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field3").toString(), equalTo("value3"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(3));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field3").toString(), equalTo("value3"));
|
||||
|
||||
// user8 has field level security configured with access to field1 and field2:
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user8", USERS_PASSWD)))
|
||||
.prepareSearch("test")
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(2));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(2));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
}
|
||||
|
||||
public void testSort() throws Exception {
|
||||
|
@ -1040,28 +1040,28 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.prepareSearch("test")
|
||||
.addSort("field1", SortOrder.ASC)
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).sortValues()[0], equalTo(1L));
|
||||
assertThat(response.getHits().getAt(0).getSortValues()[0], equalTo(1L));
|
||||
|
||||
// user2 is not granted to use field1, so the default missing sort value is included
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
||||
.prepareSearch("test")
|
||||
.addSort("field1", SortOrder.ASC)
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).sortValues()[0], equalTo(Long.MAX_VALUE));
|
||||
assertThat(response.getHits().getAt(0).getSortValues()[0], equalTo(Long.MAX_VALUE));
|
||||
|
||||
// user1 is not granted to use field2, so the default missing sort value is included
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)))
|
||||
.prepareSearch("test")
|
||||
.addSort("field2", SortOrder.ASC)
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).sortValues()[0], equalTo(Long.MAX_VALUE));
|
||||
assertThat(response.getHits().getAt(0).getSortValues()[0], equalTo(Long.MAX_VALUE));
|
||||
|
||||
// user2 is granted to use field2, so it is included in the sort_values
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
||||
.prepareSearch("test")
|
||||
.addSort("field2", SortOrder.ASC)
|
||||
.get();
|
||||
assertThat(response.getHits().getAt(0).sortValues()[0], equalTo(2L));
|
||||
assertThat(response.getHits().getAt(0).getSortValues()[0], equalTo(2L));
|
||||
}
|
||||
|
||||
public void testAggs() throws Exception {
|
||||
|
@ -1296,8 +1296,8 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.setQuery(hasChildQuery("child", termQuery("field1", "yellow"), ScoreMode.None))
|
||||
.get();
|
||||
assertHitCount(searchResponse, 1L);
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1L));
|
||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L));
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("p1"));
|
||||
|
||||
searchResponse = client()
|
||||
.filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
|
||||
|
@ -1371,18 +1371,18 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
.setQuery(matchQuery("field1", "value1"))
|
||||
.get();
|
||||
assertHitCount(response, 1);
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(2));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(2));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
|
||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user6", USERS_PASSWD)))
|
||||
.prepareSearch("test")
|
||||
.setQuery(matchQuery("field2", "value2"))
|
||||
.get();
|
||||
assertHitCount(response, 1);
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(2));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(2));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field1").toString(), equalTo("value1"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("field2").toString(), equalTo("value2"));
|
||||
}
|
||||
|
||||
public void testExistQuery() {
|
||||
|
|
|
@ -116,24 +116,24 @@ public class KibanaUserRoleIntegTests extends SecurityIntegTestCase {
|
|||
indexRandom(true, client().prepareIndex().setIndex(index).setType(type).setSource(field, "bar"));
|
||||
|
||||
SearchResponse response = client().prepareSearch(index).setQuery(QueryBuilders.matchAllQuery()).get();
|
||||
final long hits = response.getHits().totalHits();
|
||||
final long hits = response.getHits().getTotalHits();
|
||||
assertThat(hits, greaterThan(0L));
|
||||
response = client()
|
||||
.filterWithHeader(singletonMap("Authorization", UsernamePasswordToken.basicAuthHeaderValue("kibana_user", USERS_PASSWD)))
|
||||
.prepareSearch(index)
|
||||
.setQuery(QueryBuilders.matchAllQuery()).get();
|
||||
assertEquals(response.getHits().totalHits(), hits);
|
||||
assertEquals(response.getHits().getTotalHits(), hits);
|
||||
|
||||
|
||||
MultiSearchResponse multiSearchResponse = client().prepareMultiSearch()
|
||||
.add(client().prepareSearch(index).setQuery(QueryBuilders.matchAllQuery())).get();
|
||||
final long multiHits = multiSearchResponse.getResponses()[0].getResponse().getHits().totalHits();
|
||||
final long multiHits = multiSearchResponse.getResponses()[0].getResponse().getHits().getTotalHits();
|
||||
assertThat(hits, greaterThan(0L));
|
||||
multiSearchResponse = client()
|
||||
.filterWithHeader(singletonMap("Authorization", UsernamePasswordToken.basicAuthHeaderValue("kibana_user", USERS_PASSWD)))
|
||||
.prepareMultiSearch()
|
||||
.add(client().prepareSearch(index).setQuery(QueryBuilders.matchAllQuery())).get();
|
||||
assertEquals(multiSearchResponse.getResponses()[0].getResponse().getHits().totalHits(), multiHits);
|
||||
assertEquals(multiSearchResponse.getResponses()[0].getResponse().getHits().getTotalHits(), multiHits);
|
||||
}
|
||||
|
||||
public void testFieldStats() throws Exception {
|
||||
|
|
|
@ -36,7 +36,7 @@ public class ScrollIdSigningTests extends SecurityIntegTestCase {
|
|||
while (true) {
|
||||
assertSigned(response.getScrollId());
|
||||
assertHitCount(response, docs.length);
|
||||
hits += response.getHits().hits().length;
|
||||
hits += response.getHits().getHits().length;
|
||||
response = client().prepareSearchScroll(response.getScrollId())
|
||||
.setScroll(TimeValue.timeValueMinutes(2)).get();
|
||||
if (response.getHits().getHits().length == 0) {
|
||||
|
|
|
@ -56,7 +56,7 @@ public class SecurityCachePermissionTests extends SecurityIntegTestCase {
|
|||
QueryBuilders.termsLookupQuery("token", new TermsLookup("tokens", "tokens", "1", "tokens"))))
|
||||
.execute().actionGet();
|
||||
assertThat(response.isTimedOut(), is(false));
|
||||
assertThat(response.getHits().hits().length, is(1));
|
||||
assertThat(response.getHits().getHits().length, is(1));
|
||||
|
||||
// Repeat with unauthorized user!!!!
|
||||
try {
|
||||
|
|
|
@ -134,7 +134,7 @@ public class OldMonitoringIndicesBackwardsCompatibilityTests extends AbstractOld
|
|||
long expectedEsData = version.before(Version.V_2_1_0) ? 1 : 2;
|
||||
assertHitCount(response, expectedEsData);
|
||||
response = client().prepareSearch(".marvel-es-*").get();
|
||||
assertThat(response.getHits().totalHits(), greaterThanOrEqualTo(20L));
|
||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(20L));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -154,28 +154,28 @@ public class OldMonitoringIndicesBackwardsCompatibilityTests extends AbstractOld
|
|||
final String masterNodeId = clusterStateResponse.getState().getNodes().getMasterNodeId();
|
||||
|
||||
// Verify some stuff about the stuff in the backwards compatibility indexes
|
||||
Arrays.stream(firstIndexStats.getHits().hits()).forEach(hit -> checkIndexStats(version, hit.sourceAsMap()));
|
||||
Arrays.stream(firstShards.getHits().hits()).forEach(hit -> checkShards(version, hit.sourceAsMap()));
|
||||
Arrays.stream(firstIndices.getHits().hits()).forEach(hit -> checkIndicesStats(version, hit.sourceAsMap()));
|
||||
Arrays.stream(firstNode.getHits().hits()).forEach(hit -> checkNodeStats(version, masterNodeId, hit.sourceAsMap()));
|
||||
Arrays.stream(firstState.getHits().hits()).forEach(hit -> checkClusterState(version, hit.sourceAsMap()));
|
||||
Arrays.stream(firstIndexStats.getHits().getHits()).forEach(hit -> checkIndexStats(version, hit.getSourceAsMap()));
|
||||
Arrays.stream(firstShards.getHits().getHits()).forEach(hit -> checkShards(version, hit.getSourceAsMap()));
|
||||
Arrays.stream(firstIndices.getHits().getHits()).forEach(hit -> checkIndicesStats(version, hit.getSourceAsMap()));
|
||||
Arrays.stream(firstNode.getHits().getHits()).forEach(hit -> checkNodeStats(version, masterNodeId, hit.getSourceAsMap()));
|
||||
Arrays.stream(firstState.getHits().getHits()).forEach(hit -> checkClusterState(version, hit.getSourceAsMap()));
|
||||
|
||||
// Create some docs
|
||||
indexRandom(true, client().prepareIndex("test-1", "doc", "1").setSource("field", 1),
|
||||
client().prepareIndex("test-2", "doc", "2").setSource("field", 2));
|
||||
|
||||
// Wait for monitoring to accumulate some data about the current cluster
|
||||
long indexStatsCount = firstIndexStats.getHits().totalHits();
|
||||
long indexStatsCount = firstIndexStats.getHits().getTotalHits();
|
||||
assertBusy(() -> search(new IndexStatsResolver(MonitoredSystem.ES, Settings.EMPTY),
|
||||
greaterThan(indexStatsCount)), 1, TimeUnit.MINUTES);
|
||||
assertBusy(() -> search(new ShardsResolver(MonitoredSystem.ES, Settings.EMPTY),
|
||||
greaterThan(firstShards.getHits().totalHits())), 1, TimeUnit.MINUTES);
|
||||
greaterThan(firstShards.getHits().getTotalHits())), 1, TimeUnit.MINUTES);
|
||||
assertBusy(() -> search(new IndicesStatsResolver(MonitoredSystem.ES, Settings.EMPTY),
|
||||
greaterThan(firstIndices.getHits().totalHits())), 1, TimeUnit.MINUTES);
|
||||
greaterThan(firstIndices.getHits().getTotalHits())), 1, TimeUnit.MINUTES);
|
||||
assertBusy(() -> search(new NodeStatsResolver(MonitoredSystem.ES, Settings.EMPTY),
|
||||
greaterThan(firstNode.getHits().totalHits())), 1, TimeUnit.MINUTES);
|
||||
greaterThan(firstNode.getHits().getTotalHits())), 1, TimeUnit.MINUTES);
|
||||
assertBusy(() -> search(new ClusterStateResolver(MonitoredSystem.ES, Settings.EMPTY),
|
||||
greaterThan(firstState.getHits().totalHits())), 1, TimeUnit.MINUTES);
|
||||
greaterThan(firstState.getHits().getTotalHits())), 1, TimeUnit.MINUTES);
|
||||
|
||||
} finally {
|
||||
/* Now we stop monitoring and disable the HTTP exporter. We also delete all data and checks multiple times
|
||||
|
@ -207,7 +207,7 @@ public class OldMonitoringIndicesBackwardsCompatibilityTests extends AbstractOld
|
|||
|
||||
private SearchResponse search(MonitoringIndexNameResolver<?> resolver, Matcher<Long> hitCount) {
|
||||
SearchResponse response = client().prepareSearch(resolver.indexPattern()).setTypes(resolver.type(null)).get();
|
||||
assertThat(response.getHits().totalHits(), hitCount);
|
||||
assertThat(response.getHits().getTotalHits(), hitCount);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class MonitoringBulkTests extends MonitoringIntegTestCase {
|
|||
assertHitCount(searchResponse, numDocs);
|
||||
|
||||
for (SearchHit searchHit : searchResponse.getHits()) {
|
||||
Map<String, Object> source = searchHit.sourceAsMap();
|
||||
Map<String, Object> source = searchHit.getSourceAsMap();
|
||||
assertNotNull(source.get(MonitoringBulkTimestampedResolver.Fields.CLUSTER_UUID));
|
||||
assertNotNull(source.get(MonitoringBulkTimestampedResolver.Fields.TIMESTAMP));
|
||||
assertNotNull(source.get(MonitoringBulkTimestampedResolver.Fields.SOURCE_NODE));
|
||||
|
|
|
@ -88,8 +88,8 @@ public class LocalExporterTests extends MonitoringIntegTestCase {
|
|||
awaitMonitoringDocsCount(is((long) monitoringDocs.size()));
|
||||
|
||||
SearchResponse response = client().prepareSearch(MONITORING_INDICES_PREFIX + "*").get();
|
||||
for (SearchHit hit : response.getHits().hits()) {
|
||||
Map<String, Object> source = hit.sourceAsMap();
|
||||
for (SearchHit hit : response.getHits().getHits()) {
|
||||
Map<String, Object> source = hit.getSourceAsMap();
|
||||
assertNotNull(source.get("cluster_uuid"));
|
||||
assertNotNull(source.get("timestamp"));
|
||||
assertNotNull(source.get("source_node"));
|
||||
|
|
|
@ -73,7 +73,7 @@ public class ClusterStateTests extends MonitoringIntegTestCase {
|
|||
logger.debug("--> checking that every document contains the expected fields");
|
||||
Set<String> filters = ClusterStateResolver.FILTERS;
|
||||
for (SearchHit searchHit : response.getHits().getHits()) {
|
||||
Map<String, Object> fields = searchHit.sourceAsMap();
|
||||
Map<String, Object> fields = searchHit.getSourceAsMap();
|
||||
|
||||
for (String filter : filters) {
|
||||
assertContains(filter, fields);
|
||||
|
@ -133,7 +133,7 @@ public class ClusterStateTests extends MonitoringIntegTestCase {
|
|||
};
|
||||
|
||||
for (SearchHit searchHit : response.getHits().getHits()) {
|
||||
Map<String, Object> fields = searchHit.sourceAsMap();
|
||||
Map<String, Object> fields = searchHit.getSourceAsMap();
|
||||
|
||||
for (String filter : filters) {
|
||||
assertContains(filter, fields);
|
||||
|
@ -183,7 +183,7 @@ public class ClusterStateTests extends MonitoringIntegTestCase {
|
|||
};
|
||||
|
||||
for (SearchHit searchHit : response.getHits().getHits()) {
|
||||
Map<String, Object> fields = searchHit.sourceAsMap();
|
||||
Map<String, Object> fields = searchHit.getSourceAsMap();
|
||||
|
||||
for (String filter : filters) {
|
||||
assertContains(filter, fields);
|
||||
|
|
|
@ -70,7 +70,7 @@ public class ClusterStatsTests extends MonitoringIntegTestCase {
|
|||
logger.debug("--> checking that every document contains the expected fields");
|
||||
SearchResponse response = client().prepareSearch().setTypes(ClusterStatsResolver.TYPE).get();
|
||||
for (SearchHit searchHit : response.getHits().getHits()) {
|
||||
Map<String, Object> fields = searchHit.sourceAsMap();
|
||||
Map<String, Object> fields = searchHit.getSourceAsMap();
|
||||
|
||||
for (String filter : ClusterStatsResolver.FILTERS) {
|
||||
assertContains(filter, fields);
|
||||
|
|
|
@ -89,7 +89,7 @@ public class IndexRecoveryTests extends MonitoringIntegTestCase {
|
|||
};
|
||||
|
||||
for (SearchHit searchHit : response.getHits().getHits()) {
|
||||
Map<String, Object> fields = searchHit.sourceAsMap();
|
||||
Map<String, Object> fields = searchHit.getSourceAsMap();
|
||||
for (String filter : filters) {
|
||||
assertContains(filter, fields);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public class IndexStatsTests extends MonitoringIntegTestCase {
|
|||
.setTypes(IndexStatsResolver.TYPE)
|
||||
.setQuery(QueryBuilders.termQuery("index_stats.index", indices[i]))
|
||||
.get();
|
||||
assertThat(count.getHits().totalHits(), greaterThan(0L));
|
||||
assertThat(count.getHits().getTotalHits(), greaterThan(0L));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -89,7 +89,7 @@ public class IndexStatsTests extends MonitoringIntegTestCase {
|
|||
|
||||
logger.debug("--> checking that every document contains the expected fields");
|
||||
for (SearchHit searchHit : response.getHits().getHits()) {
|
||||
Map<String, Object> fields = searchHit.sourceAsMap();
|
||||
Map<String, Object> fields = searchHit.getSourceAsMap();
|
||||
|
||||
for (String filter : IndexStatsResolver.FILTERS) {
|
||||
assertContains(filter, fields);
|
||||
|
|
|
@ -81,7 +81,7 @@ public class IndicesStatsTests extends MonitoringIntegTestCase {
|
|||
|
||||
logger.debug("--> checking that every document contains the expected fields");
|
||||
for (SearchHit searchHit : response.getHits().getHits()) {
|
||||
Map<String, Object> fields = searchHit.sourceAsMap();
|
||||
Map<String, Object> fields = searchHit.getSourceAsMap();
|
||||
|
||||
for (String filter : IndicesStatsResolver.FILTERS) {
|
||||
assertContains(filter, fields);
|
||||
|
|
|
@ -62,7 +62,7 @@ public class NodeStatsTests extends MonitoringIntegTestCase {
|
|||
assertThat(response.getHits().getTotalHits(), greaterThan(0L));
|
||||
|
||||
for (SearchHit searchHit : response.getHits().getHits()) {
|
||||
Map<String, Object> fields = searchHit.sourceAsMap();
|
||||
Map<String, Object> fields = searchHit.getSourceAsMap();
|
||||
|
||||
for (String filter : nodeStatsFilters(watcherEnabled)) {
|
||||
if (Constants.WINDOWS) {
|
||||
|
|
|
@ -76,7 +76,7 @@ public class ShardsTests extends MonitoringIntegTestCase {
|
|||
|
||||
logger.debug("--> checking that every document contains the expected fields");
|
||||
for (SearchHit searchHit : response.getHits().getHits()) {
|
||||
Map<String, Object> fields = searchHit.sourceAsMap();
|
||||
Map<String, Object> fields = searchHit.getSourceAsMap();
|
||||
|
||||
for (String filter : ShardsResolver.FILTERS) {
|
||||
assertContains(filter, fields);
|
||||
|
|
|
@ -243,7 +243,7 @@ public abstract class MonitoringIntegTestCase extends ESIntegTestCase {
|
|||
|
||||
protected void assertMonitoringDocsCount(Matcher<Long> matcher, String... types) {
|
||||
flushAndRefresh(MONITORING_INDICES_PREFIX + "*");
|
||||
long count = client().prepareSearch(MONITORING_INDICES_PREFIX + "*").setSize(0).setTypes(types).get().getHits().totalHits();
|
||||
long count = client().prepareSearch(MONITORING_INDICES_PREFIX + "*").setSize(0).setTypes(types).get().getHits().getTotalHits();
|
||||
logger.trace("--> searched for [{}] documents, found [{}]", Strings.arrayToCommaDelimitedString(types), count);
|
||||
assertThat(count, matcher);
|
||||
}
|
||||
|
|
|
@ -6,19 +6,16 @@
|
|||
package org.elasticsearch.xpack.security;
|
||||
|
||||
import org.apache.lucene.util.CollectionUtil;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
import org.elasticsearch.action.support.PlainActionFuture;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.ESSingleNodeTestCase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class InternalClientIntegTests extends ESSingleNodeTestCase {
|
||||
|
@ -38,7 +35,8 @@ public class InternalClientIntegTests extends ESSingleNodeTestCase {
|
|||
.request();
|
||||
request.indicesOptions().ignoreUnavailable();
|
||||
PlainActionFuture<Collection<Integer>> future = new PlainActionFuture<>();
|
||||
InternalClient.fetchAllByEntity(client(), request, future, (hit) -> Integer.parseInt(hit.sourceAsMap().get("number").toString()));
|
||||
InternalClient.fetchAllByEntity(client(), request, future,
|
||||
(hit) -> Integer.parseInt(hit.getSourceAsMap().get("number").toString()));
|
||||
Collection<Integer> integers = future.actionGet();
|
||||
ArrayList<Integer> list = new ArrayList<>(integers);
|
||||
CollectionUtil.timSort(list);
|
||||
|
|
|
@ -319,7 +319,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
|
||||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
assertAuditMessage(hit, "transport", "anonymous_access_denied");
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
if (message instanceof RemoteHostMockMessage) {
|
||||
assertEquals(remoteAddress.getAddress(), sourceMap.get("origin_address"));
|
||||
} else {
|
||||
|
@ -342,7 +342,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
|
||||
assertAuditMessage(hit, "rest", "anonymous_access_denied");
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertThat(NetworkAddress.format(InetAddress.getLoopbackAddress()), equalTo(sourceMap.get("origin_address")));
|
||||
assertThat("_uri", equalTo(sourceMap.get("uri")));
|
||||
assertThat(sourceMap.get("origin_type"), is("rest"));
|
||||
|
@ -354,7 +354,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
TransportMessage message = randomBoolean() ? new RemoteHostMockMessage() : new LocalHostMockMessage();
|
||||
auditor.authenticationFailed(new MockToken(), "_action", message);
|
||||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertAuditMessage(hit, "transport", "authentication_failed");
|
||||
|
||||
if (message instanceof RemoteHostMockMessage) {
|
||||
|
@ -376,7 +376,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
|
||||
assertAuditMessage(hit, "transport", "authentication_failed");
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
if (message instanceof RemoteHostMockMessage) {
|
||||
assertEquals(remoteAddress.getAddress(), sourceMap.get("origin_address"));
|
||||
} else {
|
||||
|
@ -400,7 +400,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
|
||||
assertAuditMessage(hit, "rest", "authentication_failed");
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertThat(sourceMap.get("principal"), is((Object) "_principal"));
|
||||
assertThat("127.0.0.1", equalTo(sourceMap.get("origin_address")));
|
||||
assertThat("_uri", equalTo(sourceMap.get("uri")));
|
||||
|
@ -415,7 +415,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
|
||||
assertAuditMessage(hit, "rest", "authentication_failed");
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertThat(sourceMap.get("principal"), nullValue());
|
||||
assertThat("127.0.0.1", equalTo(sourceMap.get("origin_address")));
|
||||
assertThat("_uri", equalTo(sourceMap.get("uri")));
|
||||
|
@ -430,7 +430,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
|
||||
assertAuditMessage(hit, "transport", "realm_authentication_failed");
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
|
||||
if (message instanceof RemoteHostMockMessage) {
|
||||
assertEquals(remoteAddress.getAddress(), sourceMap.get("origin_address"));
|
||||
|
@ -456,7 +456,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
|
||||
assertAuditMessage(hit, "rest", "realm_authentication_failed");
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertThat("127.0.0.1", equalTo(sourceMap.get("origin_address")));
|
||||
assertThat("_uri", equalTo(sourceMap.get("uri")));
|
||||
assertEquals("_realm", sourceMap.get("realm"));
|
||||
|
@ -479,7 +479,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
|
||||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
assertAuditMessage(hit, "transport", "access_granted");
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertEquals("transport", sourceMap.get("origin_type"));
|
||||
if (runAs) {
|
||||
assertThat(sourceMap.get("principal"), is("running as"));
|
||||
|
@ -502,7 +502,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
|
||||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
assertAuditMessage(hit, "transport", "access_granted");
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertEquals("transport", sourceMap.get("origin_type"));
|
||||
assertEquals(SystemUser.INSTANCE.principal(), sourceMap.get("principal"));
|
||||
assertEquals("internal:_action", sourceMap.get("action"));
|
||||
|
@ -523,7 +523,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
auditor.accessDenied(user, "_action", message);
|
||||
|
||||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertAuditMessage(hit, "transport", "access_denied");
|
||||
assertEquals("transport", sourceMap.get("origin_type"));
|
||||
if (runAs) {
|
||||
|
@ -547,7 +547,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
|
||||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
assertAuditMessage(hit, "rest", "tampered_request");
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertThat(sourceMap.get("principal"), nullValue());
|
||||
assertThat("127.0.0.1", equalTo(sourceMap.get("origin_address")));
|
||||
assertThat("_uri", equalTo(sourceMap.get("uri")));
|
||||
|
@ -561,7 +561,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
auditor.tamperedRequest("_action", message);
|
||||
|
||||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertAuditMessage(hit, "transport", "tampered_request");
|
||||
assertEquals("transport", sourceMap.get("origin_type"));
|
||||
assertThat(sourceMap.get("principal"), is(nullValue()));
|
||||
|
@ -585,7 +585,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
|
||||
assertAuditMessage(hit, "transport", "tampered_request");
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertEquals("transport", sourceMap.get("origin_type"));
|
||||
if (runAs) {
|
||||
assertThat(sourceMap.get("principal"), is("running as"));
|
||||
|
@ -606,7 +606,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
|
||||
assertAuditMessage(hit, "ip_filter", "connection_granted");
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertEquals("allow default:accept_all", sourceMap.get("rule"));
|
||||
assertEquals("default", sourceMap.get("transport_profile"));
|
||||
}
|
||||
|
@ -620,7 +620,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
|
||||
assertAuditMessage(hit, "ip_filter", "connection_denied");
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertEquals("deny _all", sourceMap.get("rule"));
|
||||
assertEquals("default", sourceMap.get("transport_profile"));
|
||||
}
|
||||
|
@ -633,7 +633,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
|
||||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
assertAuditMessage(hit, "transport", "run_as_granted");
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertEquals("transport", sourceMap.get("origin_type"));
|
||||
assertThat(sourceMap.get("principal"), is("_username"));
|
||||
assertThat(sourceMap.get("run_as_principal"), is("running as"));
|
||||
|
@ -649,7 +649,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
|
||||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
assertAuditMessage(hit, "transport", "run_as_denied");
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertEquals("transport", sourceMap.get("origin_type"));
|
||||
assertThat(sourceMap.get("principal"), is("_username"));
|
||||
assertThat(sourceMap.get("run_as_principal"), is("running as"));
|
||||
|
@ -672,7 +672,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
|
||||
assertAuditMessage(hit, "rest", "authentication_success");
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertThat("_uri", equalTo(sourceMap.get("uri")));
|
||||
assertRequestBody(sourceMap);
|
||||
if (runAs) {
|
||||
|
@ -698,7 +698,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
auditor.authenticationSuccess(realm, user, "_action", message);
|
||||
|
||||
SearchHit hit = getIndexedAuditMessage(enqueuedMessage.get());
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertAuditMessage(hit, "transport", "authentication_success");
|
||||
assertEquals("transport", sourceMap.get("origin_type"));
|
||||
if (runAs) {
|
||||
|
@ -713,7 +713,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
}
|
||||
|
||||
private void assertAuditMessage(SearchHit hit, String layer, String type) {
|
||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
assertThat(sourceMap.get("@timestamp"), notNullValue());
|
||||
DateTime dateTime = ISODateTimeFormat.dateTimeParser().withZoneUTC().parseDateTime((String) sourceMap.get("@timestamp"));
|
||||
assertThat(dateTime.isBefore(DateTime.now(DateTimeZone.UTC)), is(true));
|
||||
|
@ -805,7 +805,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
.prepareSearch(indexName)
|
||||
.setTypes(IndexAuditTrail.DOC_TYPE)
|
||||
.get();
|
||||
if (searchResponse.getHits().totalHits() > 0L) {
|
||||
if (searchResponse.getHits().getTotalHits() > 0L) {
|
||||
searchResponseSetOnce.set(searchResponse);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -413,7 +413,7 @@ public class ReadActionsTests extends SecurityIntegTestCase {
|
|||
private static void assertReturnedIndices(SearchResponse searchResponse, String... indices) {
|
||||
List<String> foundIndices = new ArrayList<>();
|
||||
for (SearchHit searchHit : searchResponse.getHits().getHits()) {
|
||||
foundIndices.add(searchHit.index());
|
||||
foundIndices.add(searchHit.getIndex());
|
||||
}
|
||||
assertThat(foundIndices.size(), equalTo(indices.length));
|
||||
assertThat(foundIndices, hasItems(indices));
|
||||
|
|
|
@ -122,7 +122,7 @@ public class OldWatcherIndicesBackwardsCompatibilityTests extends AbstractOldXPa
|
|||
|
||||
String watchHistoryPattern = version.onOrAfter(Version.V_5_0_0_alpha1) ? ".watcher-history*" : ".watch_history*";
|
||||
SearchResponse history = client().prepareSearch(watchHistoryPattern).get();
|
||||
assertThat(history.getHits().totalHits(), greaterThanOrEqualTo(10L));
|
||||
assertThat(history.getHits().getTotalHits(), greaterThanOrEqualTo(10L));
|
||||
}
|
||||
|
||||
void assertBasicWatchInteractions() throws Exception {
|
||||
|
|
|
@ -98,7 +98,7 @@ public class IndexActionTests extends ESIntegTestCase {
|
|||
|
||||
SearchResponse searchResponse = searchRequestbuilder.get();
|
||||
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1L));
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L));
|
||||
SearchHit hit = searchResponse.getHits().getAt(0);
|
||||
|
||||
if (customId) {
|
||||
|
@ -106,9 +106,9 @@ public class IndexActionTests extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
if (customTimestampField) {
|
||||
assertThat(hit.getSource().size(), is(2));
|
||||
assertThat(hit.getSource(), hasEntry("foo", (Object) "bar"));
|
||||
assertThat(hit.getSource(), hasEntry(timestampField, (Object) WatcherDateTimeUtils.formatDate(executionTime)));
|
||||
assertThat(hit.getSourceAsMap().size(), is(2));
|
||||
assertThat(hit.getSourceAsMap(), hasEntry("foo", (Object) "bar"));
|
||||
assertThat(hit.getSourceAsMap(), hasEntry(timestampField, (Object) WatcherDateTimeUtils.formatDate(executionTime)));
|
||||
|
||||
Terms terms = searchResponse.getAggregations().get("timestamps");
|
||||
assertThat(terms, notNullValue());
|
||||
|
@ -116,8 +116,8 @@ public class IndexActionTests extends ESIntegTestCase {
|
|||
assertThat(terms.getBuckets().get(0).getKeyAsNumber().longValue(), is(executionTime.getMillis()));
|
||||
assertThat(terms.getBuckets().get(0).getDocCount(), is(1L));
|
||||
} else {
|
||||
assertThat(hit.getSource().size(), is(1));
|
||||
assertThat(hit.getSource(), hasEntry("foo", (Object) "bar"));
|
||||
assertThat(hit.getSourceAsMap().size(), is(1));
|
||||
assertThat(hit.getSourceAsMap(), hasEntry("foo", (Object) "bar"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,21 +170,21 @@ public class IndexActionTests extends ESIntegTestCase {
|
|||
.query(matchAllQuery()))
|
||||
.get();
|
||||
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(2L));
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L));
|
||||
final int fields = customTimestampField ? 2 : 1;
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
final SearchHit hit = searchResponse.getHits().getAt(i);
|
||||
final String value = "bar" + (i != 0 ? i : "");
|
||||
|
||||
assertThat(hit.getSource().size(), is(fields));
|
||||
assertThat(hit.getSourceAsMap().size(), is(fields));
|
||||
|
||||
if (customId) {
|
||||
assertThat(hit.getId(), is(Integer.toString(i)));
|
||||
}
|
||||
if (customTimestampField) {
|
||||
assertThat(hit.getSource(), hasEntry(timestampField, (Object) WatcherDateTimeUtils.formatDate(executionTime)));
|
||||
assertThat(hit.getSourceAsMap(), hasEntry(timestampField, (Object) WatcherDateTimeUtils.formatDate(executionTime)));
|
||||
}
|
||||
assertThat(hit.getSource(), hasEntry("foo", (Object) value));
|
||||
assertThat(hit.getSourceAsMap(), hasEntry("foo", (Object) value));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ public class WebhookHttpsIntegrationTests extends AbstractWatcherIntegrationTest
|
|||
searchWatchRecords(b -> b.setQuery(QueryBuilders.termQuery(WatchRecord.Field.STATE.getPreferredName(), "executed")));
|
||||
|
||||
assertNoFailures(response);
|
||||
XContentSource source = xContentSource(response.getHits().getAt(0).sourceRef());
|
||||
XContentSource source = xContentSource(response.getHits().getAt(0).getSourceRef());
|
||||
String body = source.getValue("result.actions.0.webhook.response.body");
|
||||
assertThat(body, notNullValue());
|
||||
assertThat(body, is("body"));
|
||||
|
|
|
@ -13,8 +13,8 @@ import org.elasticsearch.search.SearchShardTarget;
|
|||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
|
||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||
import org.elasticsearch.search.internal.InternalSearchHit;
|
||||
import org.elasticsearch.search.internal.InternalSearchHits;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
import org.elasticsearch.search.SearchHits;
|
||||
import org.elasticsearch.search.internal.InternalSearchResponse;
|
||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase;
|
||||
|
@ -78,12 +78,12 @@ public class CompareConditionSearchTests extends AbstractWatcherIntegrationTestC
|
|||
public void testExecuteAccessHits() throws Exception {
|
||||
CompareCondition condition = new CompareCondition("ctx.payload.hits.hits.0._score", CompareCondition.Op.EQ, 1,
|
||||
Clock.systemUTC());
|
||||
InternalSearchHit hit = new InternalSearchHit(0, "1", new Text("type"), null);
|
||||
SearchHit hit = new SearchHit(0, "1", new Text("type"), null);
|
||||
hit.score(1f);
|
||||
hit.shard(new SearchShardTarget("a", new Index("a", "indexUUID"), 0));
|
||||
|
||||
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(
|
||||
new InternalSearchHits(new InternalSearchHit[]{hit}, 1L, 1f), null, null, null, false, false);
|
||||
new SearchHits(new SearchHit[]{hit}, 1L, 1f), null, null, null, false, false);
|
||||
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||
|
||||
WatchExecutionContext ctx = mockExecutionContext("_watch_name", new Payload.XContent(response));
|
||||
|
|
|
@ -19,10 +19,8 @@ import org.elasticsearch.search.SearchShardTarget;
|
|||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
|
||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||
import org.elasticsearch.search.internal.InternalSearchHit;
|
||||
import org.elasticsearch.search.internal.InternalSearchHits;
|
||||
import org.elasticsearch.search.SearchHits;
|
||||
import org.elasticsearch.search.internal.InternalSearchResponse;
|
||||
import org.elasticsearch.xpack.watcher.condition.ScriptCondition;
|
||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase;
|
||||
import org.elasticsearch.xpack.watcher.watch.Payload;
|
||||
|
@ -59,8 +57,9 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTestCa
|
|||
});
|
||||
|
||||
scripts.put("ctx.payload.hits?.hits[0]?._score == 1.0", vars -> {
|
||||
List<SearchHit> searchHits = (List<SearchHit>) XContentMapValues.extractValue("ctx.payload.hits.hits", vars);
|
||||
double score = (double) XContentMapValues.extractValue("_score", (Map<String, Object>) searchHits.get(0));
|
||||
List<Map<String, Object>> searchHits = (List<Map<String, Object>>) XContentMapValues.extractValue("ctx.payload.hits.hits",
|
||||
vars);
|
||||
double score = (double) XContentMapValues.extractValue("_score", searchHits.get(0));
|
||||
return score == 1.0;
|
||||
});
|
||||
|
||||
|
@ -108,12 +107,12 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTestCa
|
|||
ScriptService scriptService = internalCluster().getInstance(ScriptService.class);
|
||||
ScriptCondition condition = new ScriptCondition(
|
||||
new Script("ctx.payload.hits?.hits[0]?._score == 1.0"), scriptService);
|
||||
InternalSearchHit hit = new InternalSearchHit(0, "1", new Text("type"), null);
|
||||
SearchHit hit = new SearchHit(0, "1", new Text("type"), null);
|
||||
hit.score(1f);
|
||||
hit.shard(new SearchShardTarget("a", new Index("a", "testUUID"), 0));
|
||||
|
||||
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(new InternalSearchHits(
|
||||
new InternalSearchHit[]{hit}, 1L, 1f), null, null, null, false, false);
|
||||
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(new SearchHits(
|
||||
new SearchHit[]{hit}, 1L, 1f), null, null, null, false, false);
|
||||
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||
|
||||
WatchExecutionContext ctx = mockExecutionContext("_watch_name", new Payload.XContent(response));
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.watcher.execution;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
|
||||
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
|
||||
|
@ -31,8 +30,8 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.search.SearchShardTarget;
|
||||
import org.elasticsearch.search.internal.InternalSearchHit;
|
||||
import org.elasticsearch.search.internal.InternalSearchHits;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
import org.elasticsearch.search.SearchHits;
|
||||
import org.elasticsearch.search.internal.InternalSearchResponse;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.init.proxy.WatcherClientProxy;
|
||||
|
@ -224,7 +223,7 @@ public class TriggeredWatchStoreTests extends ESTestCase {
|
|||
SearchResponse searchResponse = mock(SearchResponse.class);
|
||||
when(searchResponse.getSuccessfulShards()).thenReturn(1);
|
||||
when(searchResponse.getTotalShards()).thenReturn(1);
|
||||
when(searchResponse.getHits()).thenReturn(InternalSearchHits.empty());
|
||||
when(searchResponse.getHits()).thenReturn(SearchHits.empty());
|
||||
when(clientProxy.search(any(SearchRequest.class), any(TimeValue.class))).thenReturn(searchResponse);
|
||||
|
||||
when(clientProxy.clearScroll(anyString())).thenReturn(new ClearScrollResponse(true, 1));
|
||||
|
@ -263,21 +262,21 @@ public class TriggeredWatchStoreTests extends ESTestCase {
|
|||
SearchResponse searchResponse1 = mock(SearchResponse.class);
|
||||
when(searchResponse1.getSuccessfulShards()).thenReturn(1);
|
||||
when(searchResponse1.getTotalShards()).thenReturn(1);
|
||||
InternalSearchHit hit = new InternalSearchHit(0, "_id", new Text("_type"), null);
|
||||
SearchHit hit = new SearchHit(0, "_id", new Text("_type"), null);
|
||||
hit.version(1L);
|
||||
hit.shard(new SearchShardTarget("_node_id", index, 0));
|
||||
hit.sourceRef(new BytesArray("{}"));
|
||||
InternalSearchHits hits = new InternalSearchHits(new InternalSearchHit[]{hit}, 1, 1.0f);
|
||||
SearchHits hits = new SearchHits(new SearchHit[]{hit}, 1, 1.0f);
|
||||
when(searchResponse1.getHits()).thenReturn(hits);
|
||||
when(searchResponse1.getScrollId()).thenReturn("_scrollId");
|
||||
when(clientProxy.search(any(SearchRequest.class), any(TimeValue.class))).thenReturn(searchResponse1);
|
||||
|
||||
// First return a scroll response with a single hit and then with no hits
|
||||
hit = new InternalSearchHit(0, "_id", new Text("_type"), null);
|
||||
hit = new SearchHit(0, "_id", new Text("_type"), null);
|
||||
hit.version(1L);
|
||||
hit.shard(new SearchShardTarget("_node_id", index, 0));
|
||||
hit.sourceRef(new BytesArray("{}"));
|
||||
hits = new InternalSearchHits(new InternalSearchHit[]{hit}, 1, 1.0f);
|
||||
hits = new SearchHits(new SearchHit[]{hit}, 1, 1.0f);
|
||||
SearchResponse searchResponse2 = new SearchResponse(
|
||||
new InternalSearchResponse(hits, null, null, null, false, null), "_scrollId", 1, 1, 1, null);
|
||||
SearchResponse searchResponse3 = new SearchResponse(InternalSearchResponse.empty(), "_scrollId", 1, 1, 1, null);
|
||||
|
|
|
@ -115,7 +115,7 @@ public class HistoryActionConditionTests extends AbstractWatcherIntegrationTestC
|
|||
assertThat(response.getHits().getTotalHits(), is(1L));
|
||||
|
||||
final SearchHit hit = response.getHits().getAt(0);
|
||||
final List<Object> actions = getActionsFromHit(hit.getSource());
|
||||
final List<Object> actions = getActionsFromHit(hit.getSourceAsMap());
|
||||
|
||||
for (int i = 0; i < actionConditionsWithFailure.size(); ++i) {
|
||||
final Map<String, Object> action = (Map<String, Object>)actions.get(i);
|
||||
|
@ -160,7 +160,7 @@ public class HistoryActionConditionTests extends AbstractWatcherIntegrationTestC
|
|||
assertThat(response.getHits().getTotalHits(), is(1L));
|
||||
|
||||
final SearchHit hit = response.getHits().getAt(0);
|
||||
final List<Object> actions = getActionsFromHit(hit.getSource());
|
||||
final List<Object> actions = getActionsFromHit(hit.getSourceAsMap());
|
||||
|
||||
for (int i = 0; i < actionConditionsWithFailure.size(); ++i) {
|
||||
final Map<String, Object> action = (Map<String, Object>)actions.get(i);
|
||||
|
@ -206,7 +206,7 @@ public class HistoryActionConditionTests extends AbstractWatcherIntegrationTestC
|
|||
assertThat(response.getHits().getTotalHits(), is(1L));
|
||||
|
||||
final SearchHit hit = response.getHits().getAt(0);
|
||||
final List<Object> actions = getActionsFromHit(hit.getSource());
|
||||
final List<Object> actions = getActionsFromHit(hit.getSourceAsMap());
|
||||
|
||||
for (int i = 0; i < actionConditions.size(); ++i) {
|
||||
final Map<String, Object> action = (Map<String, Object>)actions.get(i);
|
||||
|
|
|
@ -89,7 +89,7 @@ public class ChainIntegrationTests extends AbstractWatcherIntegrationTestCase {
|
|||
refresh();
|
||||
SearchResponse searchResponse = client().prepareSearch("my-index").setTypes("my-type").get();
|
||||
assertHitCount(searchResponse, 1);
|
||||
assertThat(searchResponse.getHits().getAt(0).sourceAsString(), containsString("the-most-awesome-index-ever"));
|
||||
assertThat(searchResponse.getHits().getAt(0).getSourceAsString(), containsString("the-most-awesome-index-ever"));
|
||||
} catch (IndexNotFoundException e) {
|
||||
fail("Index not found: ["+ e.getIndex() + "]");
|
||||
}
|
||||
|
|
|
@ -455,12 +455,12 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
|||
greaterThanOrEqualTo(minimumExpectedWatchActionsWithActionPerformed));
|
||||
if (assertConditionMet) {
|
||||
assertThat((Integer) XContentMapValues.extractValue("result.input.payload.hits.total",
|
||||
searchResponse.getHits().getAt(0).sourceAsMap()), greaterThanOrEqualTo(1));
|
||||
searchResponse.getHits().getAt(0).getSourceAsMap()), greaterThanOrEqualTo(1));
|
||||
}
|
||||
});
|
||||
} catch (AssertionError error) {
|
||||
SearchResponse searchResponse = lastResponse.get();
|
||||
logger.info("Found [{}] records for watch [{}]", searchResponse.getHits().totalHits(), watchName);
|
||||
logger.info("Found [{}] records for watch [{}]", searchResponse.getHits().getTotalHits(), watchName);
|
||||
int counter = 1;
|
||||
for (SearchHit hit : searchResponse.getHits().getHits()) {
|
||||
logger.info("hit [{}]=\n {}", counter++, XContentHelper.convertToJson(hit.getSourceRef(), true, true));
|
||||
|
@ -522,7 +522,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
|||
});
|
||||
} catch (AssertionError error) {
|
||||
SearchResponse searchResponse = lastResponse.get();
|
||||
logger.info("Found [{}] records for watch [{}]", searchResponse.getHits().totalHits(), watchName);
|
||||
logger.info("Found [{}] records for watch [{}]", searchResponse.getHits().getTotalHits(), watchName);
|
||||
int counter = 1;
|
||||
for (SearchHit hit : searchResponse.getHits().getHits()) {
|
||||
logger.info("hit [{}]=\n {}", counter++, XContentHelper.convertToJson(hit.getSourceRef(), true, true));
|
||||
|
|
|
@ -160,8 +160,8 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
|
|||
refresh();
|
||||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").get();
|
||||
assertHitCount(searchResponse, 1);
|
||||
assertThat(searchResponse.getHits().getAt(0).id(), Matchers.equalTo(wid.value()));
|
||||
assertThat(searchResponse.getHits().getAt(0).sourceAsMap().get(WatchRecord.Field.STATE.getPreferredName()).toString(),
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), Matchers.equalTo(wid.value()));
|
||||
assertThat(searchResponse.getHits().getAt(0).getSourceAsMap().get(WatchRecord.Field.STATE.getPreferredName()).toString(),
|
||||
equalTo(ExecutionState.NOT_EXECUTED_WATCH_MISSING.toString()));
|
||||
}
|
||||
|
||||
|
@ -284,15 +284,15 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
|
|||
// because we try to execute a single watch in parallel, only one execution should happen
|
||||
refresh();
|
||||
SearchResponse searchResponse = client().prepareSearch("output").get();
|
||||
assertThat(searchResponse.getHits().totalHits(), is(greaterThanOrEqualTo(numberOfWatches)));
|
||||
long successfulWatchExecutions = searchResponse.getHits().totalHits();
|
||||
assertThat(searchResponse.getHits().getTotalHits(), is(greaterThanOrEqualTo(numberOfWatches)));
|
||||
long successfulWatchExecutions = searchResponse.getHits().getTotalHits();
|
||||
|
||||
// the watch history should contain entries for each triggered watch, which a few have been marked as not executed
|
||||
SearchResponse historySearchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*")
|
||||
.setSize(expectedWatchHistoryCount).get();
|
||||
assertHitCount(historySearchResponse, expectedWatchHistoryCount);
|
||||
long notExecutedCount = Arrays.asList(historySearchResponse.getHits().getHits()).stream()
|
||||
.filter(hit -> hit.getSource().get("state").equals(ExecutionState.NOT_EXECUTED_ALREADY_QUEUED.id()))
|
||||
.filter(hit -> hit.getSourceAsMap().get("state").equals(ExecutionState.NOT_EXECUTED_ALREADY_QUEUED.id()))
|
||||
.count();
|
||||
logger.info("Watches not executed: [{}]: expected watch history count [{}] - [{}] successful watch exections",
|
||||
notExecutedCount, expectedWatchHistoryCount, successfulWatchExecutions);
|
||||
|
@ -360,7 +360,8 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
|
|||
SearchResponse searchResponse = client().prepareSearch(watchRecordIndex).setSize(numRecords).get();
|
||||
assertThat(searchResponse.getHits().getTotalHits(), Matchers.equalTo((long) numRecords));
|
||||
for (int i = 0; i < numRecords; i++) {
|
||||
assertThat(searchResponse.getHits().getAt(i).getSource().get("state"), is(ExecutionState.EXECUTED_MULTIPLE_TIMES.id()));
|
||||
assertThat(searchResponse.getHits().getAt(i).getSourceAsMap().get("state"),
|
||||
is(ExecutionState.EXECUTED_MULTIPLE_TIMES.id()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ public class ExecutionVarsIntegrationTests extends AbstractWatcherIntegrationTes
|
|||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), is(1L));
|
||||
|
||||
Map<String, Object> source = searchResponse.getHits().getAt(0).getSource();
|
||||
Map<String, Object> source = searchResponse.getHits().getAt(0).getSourceAsMap();
|
||||
|
||||
assertValue(source, "watch_id", is("_id"));
|
||||
assertValue(source, "state", is("executed"));
|
||||
|
|
|
@ -218,7 +218,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|||
assertThat(ackResponse.getStatus().actionStatus("_id").ackStatus().state(), is(ActionStatus.AckStatus.State.ACKED));
|
||||
|
||||
refresh("actions");
|
||||
long countAfterAck = client().prepareSearch("actions").setTypes("action").setQuery(matchAllQuery()).get().getHits().totalHits();
|
||||
long countAfterAck = client().prepareSearch("actions").setTypes("action").setQuery(matchAllQuery()).get().getHits().getTotalHits();
|
||||
assertThat(countAfterAck, greaterThanOrEqualTo(1L));
|
||||
|
||||
restartWatcherRandomly();
|
||||
|
|
|
@ -169,14 +169,14 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas
|
|||
SearchResponse response = client().prepareSearch("output1").get();
|
||||
assertNoFailures(response);
|
||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("key3").toString(), equalTo("20"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("key3").toString(), equalTo("20"));
|
||||
|
||||
response = client().prepareSearch("output2").get();
|
||||
assertNoFailures(response);
|
||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("key3").toString(), equalTo("20"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("key3").toString(), equalTo("20"));
|
||||
}
|
||||
|
||||
public void testSearchTransform() throws Exception {
|
||||
|
@ -218,12 +218,12 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas
|
|||
SearchResponse response = client().prepareSearch("output1").get();
|
||||
assertNoFailures(response);
|
||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||
assertThat(response.getHits().getAt(0).sourceAsString(), containsString("mytestresult"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsString(), containsString("mytestresult"));
|
||||
|
||||
response = client().prepareSearch("output2").get();
|
||||
assertNoFailures(response);
|
||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||
assertThat(response.getHits().getAt(0).sourceAsString(), containsString("mytestresult"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsString(), containsString("mytestresult"));
|
||||
}
|
||||
|
||||
public void testChainTransform() throws Exception {
|
||||
|
@ -264,14 +264,14 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas
|
|||
SearchResponse response = client().prepareSearch("output1").get();
|
||||
assertNoFailures(response);
|
||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("key4").toString(), equalTo("30"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("key4").toString(), equalTo("30"));
|
||||
|
||||
response = client().prepareSearch("output2").get();
|
||||
assertNoFailures(response);
|
||||
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).sourceAsMap().get("key4").toString(), equalTo("30"));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().size(), equalTo(1));
|
||||
assertThat(response.getHits().getAt(0).getSourceAsMap().get("key4").toString(), equalTo("30"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ public class DeleteWatchTests extends AbstractWatcherIntegrationTestCase {
|
|||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*").setQuery(matchAllQuery()).get();
|
||||
assertHitCount(searchResponse, 1);
|
||||
|
||||
Map<String, Object> source = searchResponse.getHits().getAt(0).sourceAsMap();
|
||||
Map<String, Object> source = searchResponse.getHits().getAt(0).getSourceAsMap();
|
||||
// watch has been executed successfully
|
||||
String state = ObjectPath.eval("state", source);
|
||||
assertThat(state, is("executed"));
|
||||
|
|
|
@ -67,7 +67,7 @@ public class IndexAuditIT extends ESIntegTestCase {
|
|||
lastClusterState.set(state);
|
||||
client().admin().indices().prepareRefresh().get();
|
||||
return client().prepareSearch(".security_audit_log*").setQuery(QueryBuilders.matchQuery("principal", USER))
|
||||
.get().getHits().totalHits() > 0;
|
||||
.get().getHits().getTotalHits() > 0;
|
||||
}, 10L, TimeUnit.SECONDS);
|
||||
|
||||
if (!found) {
|
||||
|
@ -78,7 +78,7 @@ public class IndexAuditIT extends ESIntegTestCase {
|
|||
SearchResponse searchResponse = client().prepareSearch(".security_audit_log*").setQuery(
|
||||
QueryBuilders.matchQuery("principal", USER)).get();
|
||||
assertThat(searchResponse.getHits().getHits().length, greaterThan(0));
|
||||
assertThat((String) searchResponse.getHits().getAt(0).sourceAsMap().get("principal"), is(USER));
|
||||
assertThat((String) searchResponse.getHits().getAt(0).getSourceAsMap().get("principal"), is(USER));
|
||||
}
|
||||
|
||||
public void testAuditTrailTemplateIsRecreatedAfterDelete() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue