diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/user/PutUserRequestBuilder.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/user/PutUserRequestBuilder.java index a9f73bd757d..11f061c2d9b 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/user/PutUserRequestBuilder.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/user/PutUserRequestBuilder.java @@ -111,14 +111,14 @@ public class PutUserRequestBuilder extends ActionRequestBuilder builder.source("kibana4", new BytesArray(json.getBytes(StandardCharsets.UTF_8)))); + assertThat(e.getMessage(), containsString("expected field [full_name] to be of type string")); + } + + public void testInvalidEmail() throws IOException { + final String json = "{\n" + + " \"roles\": [\n" + + " \"kibana4\"\n" + + " ],\n" + + " \"full_name\": \"Kibana User\",\n" + + " \"email\": [ \"kibana@elastic.co\" ],\n" + + " \"metadata\": {}\n" + + "}"; + + PutUserRequestBuilder builder = new PutUserRequestBuilder(mock(Client.class)); + ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, + () -> builder.source("kibana4", new BytesArray(json.getBytes(StandardCharsets.UTF_8)))); + assertThat(e.getMessage(), containsString("expected field [email] to be of type string")); + } +}