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