use of io.druid.audit.AuditInfo in project druid by druid-io.
the class SQLAuditManagerTest method testFetchAuditHistoryByKeyAndTypeWithLimit.
@Test(timeout = 10_000L)
public void testFetchAuditHistoryByKeyAndTypeWithLimit() throws IOException {
AuditEntry entry1 = new AuditEntry("testKey1", "testType", new AuditInfo("testAuthor", "testComment", "127.0.0.1"), "testPayload", new DateTime("2013-01-01T00:00:00Z"));
AuditEntry entry2 = new AuditEntry("testKey2", "testType", new AuditInfo("testAuthor", "testComment", "127.0.0.1"), "testPayload", new DateTime("2013-01-02T00:00:00Z"));
auditManager.doAudit(entry1);
auditManager.doAudit(entry2);
List<AuditEntry> auditEntries = auditManager.fetchAuditHistory("testKey1", "testType", 1);
Assert.assertEquals(1, auditEntries.size());
Assert.assertEquals(entry1, auditEntries.get(0));
}
use of io.druid.audit.AuditInfo in project druid by druid-io.
the class SQLAuditManagerTest method testCreateAuditEntry.
@Test(timeout = 10_000L)
public void testCreateAuditEntry() throws IOException {
AuditEntry entry = new AuditEntry("testKey", "testType", new AuditInfo("testAuthor", "testComment", "127.0.0.1"), "testPayload", new DateTime("2013-01-01T00:00:00Z"));
auditManager.doAudit(entry);
byte[] payload = connector.lookup(derbyConnectorRule.metadataTablesConfigSupplier().get().getAuditTable(), "audit_key", "payload", "testKey");
AuditEntry dbEntry = mapper.readValue(payload, AuditEntry.class);
Assert.assertEquals(entry, dbEntry);
}
use of io.druid.audit.AuditInfo in project druid by druid-io.
the class RulesResourceTest method testGetAllDatasourcesRuleHistoryWithInterval.
@Test
public void testGetAllDatasourcesRuleHistoryWithInterval() {
String interval = "P2D/2013-01-02T00:00:00Z";
Interval theInterval = new Interval(interval);
AuditEntry entry1 = new AuditEntry("testKey", "testType", new AuditInfo("testAuthor", "testComment", "127.0.0.1"), "testPayload", new DateTime("2013-01-02T00:00:00Z"));
AuditEntry entry2 = new AuditEntry("testKey", "testType", new AuditInfo("testAuthor", "testComment", "127.0.0.1"), "testPayload", new DateTime("2013-01-01T00:00:00Z"));
EasyMock.expect(auditManager.fetchAuditHistory(EasyMock.eq("rules"), EasyMock.eq(theInterval))).andReturn(ImmutableList.of(entry1, entry2)).once();
EasyMock.replay(auditManager);
RulesResource rulesResource = new RulesResource(databaseRuleManager, auditManager);
Response response = rulesResource.getDatasourceRuleHistory(interval, null);
List<AuditEntry> rulesHistory = (List) response.getEntity();
Assert.assertEquals(2, rulesHistory.size());
Assert.assertEquals(entry1, rulesHistory.get(0));
Assert.assertEquals(entry2, rulesHistory.get(1));
EasyMock.verify(auditManager);
}
use of io.druid.audit.AuditInfo in project druid by druid-io.
the class RulesResourceTest method testGetAllDatasourcesRuleHistoryWithCount.
@Test
public void testGetAllDatasourcesRuleHistoryWithCount() {
AuditEntry entry1 = new AuditEntry("testKey", "testType", new AuditInfo("testAuthor", "testComment", "127.0.0.1"), "testPayload", new DateTime("2013-01-02T00:00:00Z"));
AuditEntry entry2 = new AuditEntry("testKey", "testType", new AuditInfo("testAuthor", "testComment", "127.0.0.1"), "testPayload", new DateTime("2013-01-01T00:00:00Z"));
EasyMock.expect(auditManager.fetchAuditHistory(EasyMock.eq("rules"), EasyMock.eq(2))).andReturn(ImmutableList.of(entry1, entry2)).once();
EasyMock.replay(auditManager);
RulesResource rulesResource = new RulesResource(databaseRuleManager, auditManager);
Response response = rulesResource.getDatasourceRuleHistory(null, 2);
List<AuditEntry> rulesHistory = (List) response.getEntity();
Assert.assertEquals(2, rulesHistory.size());
Assert.assertEquals(entry1, rulesHistory.get(0));
Assert.assertEquals(entry2, rulesHistory.get(1));
EasyMock.verify(auditManager);
}
use of io.druid.audit.AuditInfo in project druid by druid-io.
the class RulesResourceTest method testGetDatasourceRuleHistoryWithCount.
@Test
public void testGetDatasourceRuleHistoryWithCount() {
AuditEntry entry1 = new AuditEntry("testKey", "testType", new AuditInfo("testAuthor", "testComment", "127.0.0.1"), "testPayload", new DateTime("2013-01-02T00:00:00Z"));
AuditEntry entry2 = new AuditEntry("testKey", "testType", new AuditInfo("testAuthor", "testComment", "127.0.0.1"), "testPayload", new DateTime("2013-01-01T00:00:00Z"));
EasyMock.expect(auditManager.fetchAuditHistory(EasyMock.eq("datasource1"), EasyMock.eq("rules"), EasyMock.eq(2))).andReturn(ImmutableList.of(entry1, entry2)).once();
EasyMock.replay(auditManager);
RulesResource rulesResource = new RulesResource(databaseRuleManager, auditManager);
Response response = rulesResource.getDatasourceRuleHistory("datasource1", null, 2);
List<AuditEntry> rulesHistory = (List) response.getEntity();
Assert.assertEquals(2, rulesHistory.size());
Assert.assertEquals(entry1, rulesHistory.get(0));
Assert.assertEquals(entry2, rulesHistory.get(1));
EasyMock.verify(auditManager);
}
Aggregations