diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/AuthorizationEngine.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/AuthorizationEngine.java index 091d902014a9f..ba87cf786580f 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/AuthorizationEngine.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/AuthorizationEngine.java @@ -342,6 +342,9 @@ public String getFailureContext() { } public static String getFailureDescription(Collection deniedIndices) { + if (deniedIndices.isEmpty()) { + return null; + } return "on indices [" + Strings.collectionToCommaDelimitedString(deniedIndices) + "]"; } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java index 298f80fdda2ad..d7c04fb56d5b1 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java @@ -680,8 +680,7 @@ public void testUnknownRoleCausesDenial() throws IOException { assertThat(securityException, throwableWithMessage(containsString( "[" + action + "] is unauthorized" + " for user [test user]" + - " with roles [non-existent-role]" + - " on indices ["))); + " with roles [non-existent-role],"))); assertThat(securityException, throwableWithMessage(containsString("this action is granted by the index privileges [read,all]"))); verify(auditTrail).accessDenied(eq(requestId), eq(authentication), eq(action), eq(request), authzInfoRoles(Role.EMPTY.names())); @@ -722,8 +721,7 @@ public void testThatRoleWithNoIndicesIsDenied() throws IOException { assertThat(securityException, throwableWithMessage(containsString( "[" + action + "] is unauthorized" + " for user [test user]" + - " with roles [no_indices]" + - " on indices ["))); + " with roles [no_indices],"))); assertThat(securityException, throwableWithMessage(containsString("this action is granted by the index privileges [read,all]"))); verify(auditTrail).accessDenied(eq(requestId), eq(authentication), eq(action), eq(request),