fix the indexing of the request class for the IndexAuditTrail

The IndexAuditTrail was checking the logger level of the class before adding the request
class to the message, which was an error. The logger level should not control anything
about the IndexAuditTrail.

Closes elastic/elasticsearch#546

Original commit: elastic/x-pack-elasticsearch@35ee8ab453
This commit is contained in:
jaymode 2015-09-14 10:07:23 -04:00
parent 52e58b8de0
commit a3ae0827fa
2 changed files with 12 additions and 10 deletions

View File

@ -523,11 +523,7 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail, Cl
if (indices != null) {
msg.builder.array(Field.INDICES, indices);
}
// FIXME WTF!!! Why does this have anything to do with the logger!!!!!
if (logger.isDebugEnabled()) {
msg.builder.field(Field.REQUEST, message.getClass().getSimpleName());
}
return msg.end();
}
@ -552,11 +548,7 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail, Cl
if (indices != null) {
msg.builder.array(Field.INDICES, indices);
}
// FIXME WTF!!! Why does this have anything to do with the logger!!!!!
if (logger.isDebugEnabled()) {
msg.builder.field(Field.REQUEST, message.getClass().getSimpleName());
}
return msg.end();
}

View File

@ -242,6 +242,7 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
List<Object> indices = hit.field("indices").getValues();
assertThat(indices, contains((Object[]) ((IndicesRequest) message).indices()));
}
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
}
@Test(expected = IndexNotFoundException.class)
@ -298,6 +299,7 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
assertEquals("_principal", hit.field("principal").getValue());
assertEquals("_action", hit.field("action").getValue());
assertEquals("transport", hit.field("origin_type").getValue());
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
}
@Test
@ -324,6 +326,7 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
List<Object> indices = hit.field("indices").getValues();
assertThat(indices, contains((Object[]) ((IndicesRequest) message).indices()));
}
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
}
@Test(expected = IndexNotFoundException.class)
@ -419,6 +422,7 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
List<Object> indices = hit.field("indices").getValues();
assertThat(indices, contains((Object[]) ((IndicesRequest)message).indices()));
}
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
}
@Test(expected = IndexNotFoundException.class)
@ -484,6 +488,7 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
List<Object> indices = hit.field("indices").getValues();
assertThat(indices, contains((Object[]) ((IndicesRequest)message).indices()));
}
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
}
@Test(expected = IndexNotFoundException.class)
@ -506,6 +511,7 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
assertEquals("transport", hit.field("origin_type").getValue());
assertEquals(User.SYSTEM.principal(), hit.field("principal").getValue());
assertEquals("internal:_action", hit.field("action").getValue());
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
}
@Test(expected = IndexNotFoundException.class)
@ -546,6 +552,7 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
List<Object> indices = hit.field("indices").getValues();
assertThat(indices, contains((Object[]) ((IndicesRequest)message).indices()));
}
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
}
@Test(expected = IndexNotFoundException.class)
@ -582,6 +589,7 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
assertEquals("_username", hit.field("principal").getValue());
}
assertEquals("_action", hit.field("action").getValue());
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
}
@Test(expected = IndexNotFoundException.class)
@ -656,6 +664,7 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
assertThat((String) hit.field("principal").getValue(), is("_username"));
assertThat((String) hit.field("run_as_principal").getValue(), is("running as"));
assertEquals("_action", hit.field("action").getValue());
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
}
@Test(expected = IndexNotFoundException.class)
@ -680,6 +689,7 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
assertThat((String) hit.field("principal").getValue(), is("_username"));
assertThat((String) hit.field("run_as_principal").getValue(), is("running as"));
assertEquals("_action", hit.field("action").getValue());
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
}
@Test(expected = IndexNotFoundException.class)