use of org.apache.druid.audit.AuditInfo in project druid by druid-io.
the class LookupCoordinatorManagerTest method testUpdateLookupsAddsNewTier.
@Test
public void testUpdateLookupsAddsNewTier() {
final LookupExtractorFactoryMapContainer ignore = new LookupExtractorFactoryMapContainer("v0", ImmutableMap.of("prop", "old"));
final AuditInfo auditInfo = new AuditInfo("author", "comment", "localhost");
final LookupCoordinatorManager manager = new LookupCoordinatorManager(client, druidNodeDiscoveryProvider, mapper, configManager, lookupCoordinatorManagerConfig) {
@Override
public Map<String, Map<String, LookupExtractorFactoryMapContainer>> getKnownLookups() {
return ImmutableMap.of(LOOKUP_TIER + "2", ImmutableMap.of("ignore", ignore));
}
};
manager.start();
final LookupExtractorFactoryMapContainer newSpec = new LookupExtractorFactoryMapContainer("v1", ImmutableMap.of("prop", "new"));
EasyMock.reset(configManager);
EasyMock.expect(configManager.set(EasyMock.eq(LookupCoordinatorManager.LOOKUP_CONFIG_KEY), EasyMock.eq(ImmutableMap.<String, Map<String, LookupExtractorFactoryMapContainer>>of(LOOKUP_TIER + "1", ImmutableMap.of("foo", newSpec), LOOKUP_TIER + "2", ImmutableMap.of("ignore", ignore))), EasyMock.eq(auditInfo))).andReturn(SetResult.ok()).once();
EasyMock.replay(configManager);
Assert.assertTrue(manager.updateLookups(ImmutableMap.of(LOOKUP_TIER + "1", ImmutableMap.of("foo", newSpec)), auditInfo));
EasyMock.verify(configManager);
}
use of org.apache.druid.audit.AuditInfo in project druid by druid-io.
the class SQLAuditManagerTest method testCreateAuditEntry.
@Test(timeout = 60_000L)
public void testCreateAuditEntry() throws IOException {
String entry1Key = "testKey";
String entry1Type = "testType";
AuditInfo entry1AuditInfo = new AuditInfo("testAuthor", "testComment", "127.0.0.1");
String entry1Payload = "testPayload";
auditManager.doAudit(entry1Key, entry1Type, entry1AuditInfo, entry1Payload, stringConfigSerde);
byte[] payload = connector.lookup(derbyConnectorRule.metadataTablesConfigSupplier().get().getAuditTable(), "audit_key", "payload", "testKey");
AuditEntry dbEntry = mapper.readValue(payload, AuditEntry.class);
Assert.assertEquals(entry1Key, dbEntry.getKey());
Assert.assertEquals(entry1Payload, dbEntry.getPayload());
Assert.assertEquals(entry1Type, dbEntry.getType());
Assert.assertEquals(entry1AuditInfo, dbEntry.getAuditInfo());
}
use of org.apache.druid.audit.AuditInfo in project druid by druid-io.
the class SQLAuditManagerTest method testRemoveAuditLogsOlderThanWithEntryNotOlderThanTime.
@Test(timeout = 60_000L)
public void testRemoveAuditLogsOlderThanWithEntryNotOlderThanTime() throws IOException {
String entry1Key = "testKey";
String entry1Type = "testType";
AuditInfo entry1AuditInfo = new AuditInfo("testAuthor", "testComment", "127.0.0.1");
String entry1Payload = "testPayload";
auditManager.doAudit(entry1Key, entry1Type, entry1AuditInfo, entry1Payload, stringConfigSerde);
byte[] payload = connector.lookup(derbyConnectorRule.metadataTablesConfigSupplier().get().getAuditTable(), "audit_key", "payload", "testKey");
AuditEntry dbEntry = mapper.readValue(payload, AuditEntry.class);
Assert.assertEquals(entry1Key, dbEntry.getKey());
Assert.assertEquals(entry1Payload, dbEntry.getPayload());
Assert.assertEquals(entry1Type, dbEntry.getType());
Assert.assertEquals(entry1AuditInfo, dbEntry.getAuditInfo());
// Do delete
auditManager.removeAuditLogsOlderThan(DateTimes.of("2012-01-01T00:00:00Z").getMillis());
// Verify that entry was not delete
payload = connector.lookup(derbyConnectorRule.metadataTablesConfigSupplier().get().getAuditTable(), "audit_key", "payload", "testKey");
dbEntry = mapper.readValue(payload, AuditEntry.class);
Assert.assertEquals(entry1Key, dbEntry.getKey());
Assert.assertEquals(entry1Payload, dbEntry.getPayload());
Assert.assertEquals(entry1Type, dbEntry.getType());
Assert.assertEquals(entry1AuditInfo, dbEntry.getAuditInfo());
}
use of org.apache.druid.audit.AuditInfo in project druid by druid-io.
the class SQLAuditManagerTest method testCreateAuditEntryWithPayloadUnderSkipPayloadLimit.
@Test(timeout = 60_000L)
public void testCreateAuditEntryWithPayloadUnderSkipPayloadLimit() throws IOException {
SQLAuditManager auditManagerWithMaxPayloadSizeBytes = new SQLAuditManager(connector, derbyConnectorRule.metadataTablesConfigSupplier(), new NoopServiceEmitter(), mapper, new SQLAuditManagerConfig() {
@Override
public long getMaxPayloadSizeBytes() {
return 500;
}
});
String entry1Key = "testKey";
String entry1Type = "testType";
AuditInfo entry1AuditInfo = new AuditInfo("testAuthor", "testComment", "127.0.0.1");
String entry1Payload = "payload audit to store";
auditManagerWithMaxPayloadSizeBytes.doAudit(entry1Key, entry1Type, entry1AuditInfo, entry1Payload, stringConfigSerde);
byte[] payload = connector.lookup(derbyConnectorRule.metadataTablesConfigSupplier().get().getAuditTable(), "audit_key", "payload", "testKey");
AuditEntry dbEntry = mapper.readValue(payload, AuditEntry.class);
Assert.assertEquals(entry1Key, dbEntry.getKey());
Assert.assertEquals(entry1Payload, dbEntry.getPayload());
Assert.assertEquals(entry1Type, dbEntry.getType());
Assert.assertEquals(entry1AuditInfo, dbEntry.getAuditInfo());
}
use of org.apache.druid.audit.AuditInfo in project druid by druid-io.
the class SQLAuditManagerTest method testAuditEntrySerde.
@Test(timeout = 60_000L)
public void testAuditEntrySerde() throws IOException {
AuditEntry entry = new AuditEntry("testKey", "testType", new AuditInfo("testAuthor", "testComment", "127.0.0.1"), "testPayload", DateTimes.of("2013-01-01T00:00:00Z"));
ObjectMapper mapper = new DefaultObjectMapper();
AuditEntry serde = mapper.readValue(mapper.writeValueAsString(entry), AuditEntry.class);
Assert.assertEquals(entry, serde);
}
Aggregations