test: allow percolate api to fail when the percolator field can't be found

Original commit: elastic/x-pack-elasticsearch@3343c9dc3a
This commit is contained in:
Martijn van Groningen 2016-04-19 14:11:38 +02:00
parent 98feb695ff
commit e24d09b54e

View File

@ -18,6 +18,7 @@ import java.util.Locale;
import java.util.Map;
import static java.util.Collections.singletonMap;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
//test is just too slow, please fix it to not be sleep-based
@ -312,11 +313,11 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
switch (action) {
case "all" :
if (userIsAllowed) {
assertUserIsAllowed(user, "manage", index);
assertUserIsAllowed(user, "crud", index);
assertUserIsAllowed(user, "manage", index);
} else {
assertUserIsDenied(user, "manage", index);
assertUserIsDenied(user, "crud", index);
assertUserIsDenied(user, "manage", index);
}
break;
@ -404,7 +405,11 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
assertAccessIsAllowed("admin", "GET", "/" + index + "/foo/1");
assertAccessIsAllowed(user, "GET", "/" + index + "/foo/1/_explain", "{ \"query\" : { \"match_all\" : {} } }");
assertAccessIsAllowed(user, "GET", "/" + index + "/foo/1/_termvector");
assertAccessIsAllowed(user, "GET", "/" + index + "/foo/_percolate", "{ \"doc\" : { \"foo\" : \"bar\" } }");
try {
assertAccessIsAllowed(user, "GET", "/" + index + "/foo/_percolate", "{ \"doc\" : { \"foo\" : \"bar\" } }");
} catch (Throwable e) {
assertThat(e.getMessage(), containsString("field [query] does not exist"));
}
assertAccessIsAllowed(user, "GET",
"/" + index + "/_suggest", "{ \"sgs\" : { \"text\" : \"foo\", \"term\" : { \"field\" : \"body\" } } }");
assertAccessIsAllowed(user, "GET",
@ -417,7 +422,11 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
multiPercolate.append("{\"doc\" : {\"message\" : \"some text\"}}\n");
multiPercolate.append("{\"percolate\" : {\"index\" : \"" + index + "\", \"type\" : \"foo\", \"id\" : \"1\"}}\n");
multiPercolate.append("{}\n");
assertAccessIsAllowed(user, "GET", "/" + index + "/foo/_mpercolate", multiPercolate.toString());
try {
assertAccessIsAllowed(user, "GET", "/" + index + "/foo/_mpercolate", multiPercolate.toString());
} catch (Throwable e) {
assertThat(e.getMessage(), containsString("field [query] does not exist"));
}
assertUserIsAllowed(user, "search", index);
} else {