use of io.druid.audit.AuditInfo in project druid by druid-io.
the class SQLAuditManagerTest method testAuditEntrySerde.
@Test(timeout = 10_000L)
public void testAuditEntrySerde() throws IOException {
AuditEntry entry = new AuditEntry("testKey", "testType", new AuditInfo("testAuthor", "testComment", "127.0.0.1"), "testPayload", new DateTime("2013-01-01T00:00:00Z"));
ObjectMapper mapper = new DefaultObjectMapper();
AuditEntry serde = mapper.readValue(mapper.writeValueAsString(entry), AuditEntry.class);
Assert.assertEquals(entry, serde);
}
use of io.druid.audit.AuditInfo in project druid by druid-io.
the class SQLAuditManagerTest method testFetchAuditHistory.
@Test(timeout = 10_000L)
public void testFetchAuditHistory() 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);
auditManager.doAudit(entry);
List<AuditEntry> auditEntries = auditManager.fetchAuditHistory("testKey", "testType", new Interval("2012-01-01T00:00:00Z/2013-01-03T00:00:00Z"));
Assert.assertEquals(2, auditEntries.size());
Assert.assertEquals(entry, auditEntries.get(0));
Assert.assertEquals(entry, auditEntries.get(1));
}
use of io.druid.audit.AuditInfo in project druid by druid-io.
the class LookupCoordinatorManagerTest method testUpdateLookupsOnlyAddsToTier.
@Test
public void testUpdateLookupsOnlyAddsToTier() throws Exception {
final Map<String, Object> ignore = ImmutableMap.<String, Object>of("prop", "old");
final AuditInfo auditInfo = new AuditInfo("author", "comment", "localhost");
final LookupCoordinatorManager manager = new LookupCoordinatorManager(client, discoverer, mapper, configManager, lookupCoordinatorManagerConfig) {
@Override
public Map<String, Map<String, Map<String, Object>>> getKnownLookups() {
return ImmutableMap.<String, Map<String, Map<String, Object>>>of(LOOKUP_TIER + "1", ImmutableMap.<String, Map<String, Object>>of("foo", ImmutableMap.<String, Object>of("prop", "old")), LOOKUP_TIER + "2", ImmutableMap.of("ignore", ignore));
}
};
final Map<String, Object> newSpec = ImmutableMap.<String, Object>of("prop", "new");
EasyMock.reset(configManager);
EasyMock.expect(configManager.set(EasyMock.eq(LookupCoordinatorManager.LOOKUP_CONFIG_KEY), EasyMock.eq(ImmutableMap.<String, Map<String, Map<String, Object>>>of(LOOKUP_TIER + "1", ImmutableMap.of("foo", newSpec), LOOKUP_TIER + "2", ImmutableMap.of("ignore", ignore))), EasyMock.eq(auditInfo))).andReturn(true).once();
EasyMock.replay(configManager);
Assert.assertTrue(manager.updateLookups(ImmutableMap.<String, Map<String, Map<String, Object>>>of(LOOKUP_TIER + "1", ImmutableMap.<String, Map<String, Object>>of("foo", newSpec)), auditInfo));
EasyMock.verify(configManager);
}
use of io.druid.audit.AuditInfo in project druid by druid-io.
the class LookupCoordinatorManagerTest method testDeleteLookupIgnoresNotReady.
@Test
public void testDeleteLookupIgnoresNotReady() throws Exception {
final LookupCoordinatorManager manager = new LookupCoordinatorManager(client, discoverer, mapper, configManager, lookupCoordinatorManagerConfig) {
@Override
public Map<String, Map<String, Map<String, Object>>> getKnownLookups() {
return null;
}
};
final AuditInfo auditInfo = new AuditInfo("author", "comment", "localhost");
Assert.assertFalse(manager.deleteLookup(LOOKUP_TIER, "foo", auditInfo));
}
use of io.druid.audit.AuditInfo in project druid by druid-io.
the class LookupCoordinatorManagerTest method testUpdateLookupFailsBadUpdates.
@Test
public void testUpdateLookupFailsBadUpdates() throws Exception {
final Map<String, Object> ignore = ImmutableMap.<String, Object>of("prop", "old");
final LookupCoordinatorManager manager = new LookupCoordinatorManager(client, discoverer, mapper, configManager, lookupCoordinatorManagerConfig) {
@Override
public Map<String, Map<String, Map<String, Object>>> getKnownLookups() {
return ImmutableMap.<String, Map<String, Map<String, Object>>>of(LOOKUP_TIER, ImmutableMap.of("foo", ImmutableMap.<String, Object>of("prop", "old"), "ignore", ignore));
}
};
final Map<String, Object> newSpec = ImmutableMap.<String, Object>of("prop", "new");
final Map<String, Map<String, Object>> lookup = ImmutableMap.<String, Map<String, Object>>of("foo", newSpec, "ignore", ignore);
final Map<String, Map<String, Map<String, Object>>> tier = ImmutableMap.of(LOOKUP_TIER, lookup);
final AuditInfo auditInfo = new AuditInfo("author", "comment", "localhost");
EasyMock.reset(configManager);
EasyMock.expect(configManager.set(EasyMock.eq(LookupCoordinatorManager.LOOKUP_CONFIG_KEY), EasyMock.eq(ImmutableMap.of(LOOKUP_TIER, ImmutableMap.of("foo", newSpec, "ignore", ignore))), EasyMock.eq(auditInfo))).andReturn(false).once();
EasyMock.replay(configManager);
Assert.assertFalse(manager.updateLookups(tier, auditInfo));
EasyMock.verify(configManager);
}
Aggregations