private void deleteTestFiles() throws Exception { FileBasedEventStore eventStore = (FileBasedEventStore) appSensorServer.getEventStore(); FileBasedAttackStore attackStore = (FileBasedAttackStore) appSensorServer.getAttackStore(); FileBasedResponseStore responseStore = (FileBasedResponseStore) appSensorServer.getResponseStore(); Files.deleteIfExists(eventStore.getPath()); Files.deleteIfExists(attackStore.getPath()); Files.deleteIfExists(responseStore.getPath()); }
@Test public void testAttackCreation() throws Exception { deleteTestFiles(); ServerConfiguration updatedConfiguration = appSensorServer.getConfiguration(); updatedConfiguration.setDetectionPoints(loadMockedDetectionPoints()); appSensorServer.setConfiguration(updatedConfiguration); SearchCriteria criteria = new SearchCriteria() .setUser(bob) .setDetectionPoint(detectionPoint1) .setDetectionSystemIds(detectionSystems1); assertEquals(0, appSensorServer.getEventStore().findEvents(criteria).size()); assertEquals(0, appSensorServer.getAttackStore().findAttacks(criteria).size()); appSensorClient .getEventManager() .addEvent(new Event(bob, detectionPoint1, new DetectionSystem("my-sample-client"))); assertEquals(1, appSensorServer.getEventStore().findEvents(criteria).size()); assertEquals(0, appSensorServer.getAttackStore().findAttacks(criteria).size()); appSensorClient .getEventManager() .addEvent(new Event(bob, detectionPoint1, new DetectionSystem("localhostme"))); assertEquals(2, appSensorServer.getEventStore().findEvents(criteria).size()); assertEquals(0, appSensorServer.getAttackStore().findAttacks(criteria).size()); appSensorClient .getEventManager() .addEvent(new Event(bob, detectionPoint1, new DetectionSystem("localhostme"))); assertEquals(3, appSensorServer.getEventStore().findEvents(criteria).size()); assertEquals(1, appSensorServer.getAttackStore().findAttacks(criteria).size()); appSensorClient .getEventManager() .addEvent(new Event(bob, detectionPoint1, new DetectionSystem("localhostme"))); assertEquals(4, appSensorServer.getEventStore().findEvents(criteria).size()); assertEquals(1, appSensorServer.getAttackStore().findAttacks(criteria).size()); appSensorClient .getEventManager() .addEvent(new Event(bob, detectionPoint1, new DetectionSystem("localhostme"))); assertEquals(5, appSensorServer.getEventStore().findEvents(criteria).size()); assertEquals(1, appSensorServer.getAttackStore().findAttacks(criteria).size()); appSensorClient .getEventManager() .addEvent(new Event(bob, detectionPoint1, new DetectionSystem("localhostme"))); assertEquals(6, appSensorServer.getEventStore().findEvents(criteria).size()); assertEquals(2, appSensorServer.getAttackStore().findAttacks(criteria).size()); appSensorClient .getEventManager() .addEvent(new Event(bob, detectionPoint1, new DetectionSystem("localhostme"))); assertEquals(7, appSensorServer.getEventStore().findEvents(criteria).size()); assertEquals(2, appSensorServer.getAttackStore().findAttacks(criteria).size()); }