Search in sources :

Example 1 with PostgreSQLFunctionNotificationParser

use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser in project binnavi by google.

the class PostgreSQLFunctionNotificationParserTest method testParser.

private void testParser(final String table, final String databaseOperation, final String address, final String moduleId) {
    final String notification = table + " " + databaseOperation + " " + moduleId + " " + address;
    notifications.add(new MockPGNotification("function_changes", notification));
    final PostgreSQLFunctionNotificationParser parser = new PostgreSQLFunctionNotificationParser();
    final Collection<FunctionNotificationContainer> result = parser.parse(notifications, provider);
    assertNotNull(result);
    assertTrue(!result.isEmpty());
    assertTrue(result.size() == 1);
    final FunctionNotificationContainer container = Iterables.getFirst(result, null);
    assertNotNull(container);
    assertEquals(databaseOperation, container.getDatabaseOperation());
    assertEquals(new CAddress(address, 10), container.getFunctionAddress());
}
Also used : FunctionNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer) PostgreSQLFunctionNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 2 with PostgreSQLFunctionNotificationParser

use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser in project binnavi by google.

the class PostgreSQLFunctionNotificationParserTest method testFunctionInform2Description.

@Test
public void testFunctionInform2Description() throws CouldntLoadDataException {
    final String description = "FUNCTION DESCRIPTION CHANGE TEST";
    function.setDescriptionInternal(description);
    assertEquals(description, function.getDescription());
    final FunctionNotificationContainer container = new FunctionNotificationContainer(module.getConfiguration().getId(), module, function.getAddress(), "UPDATE");
    final PostgreSQLFunctionNotificationParser parser = new PostgreSQLFunctionNotificationParser();
    parser.inform(Lists.newArrayList(container), provider);
    assertEquals("Mock Description", function.getDescription());
}
Also used : FunctionNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer) PostgreSQLFunctionNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser) Test(org.junit.Test)

Example 3 with PostgreSQLFunctionNotificationParser

use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser in project binnavi by google.

the class PostgreSQLFunctionNotificationParserTest method testFunctionInform0.

@Test
public void testFunctionInform0() throws CouldntLoadDataException {
    final FunctionNotificationContainer container = new FunctionNotificationContainer(module.getConfiguration().getId(), module, function.getAddress(), "INSERT");
    final PostgreSQLFunctionNotificationParser parser = new PostgreSQLFunctionNotificationParser();
    parser.inform(Lists.newArrayList(container), provider);
}
Also used : FunctionNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer) PostgreSQLFunctionNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser) Test(org.junit.Test)

Example 4 with PostgreSQLFunctionNotificationParser

use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser in project binnavi by google.

the class PostgreSQLFunctionNotificationParserTest method testFunctionInform1Name.

@Test
public void testFunctionInform1Name() throws CouldntLoadDataException {
    final String name = "FUNCTION NAME CHANGE TEST";
    function.setNameInternal(name);
    assertEquals(name, function.getName());
    final FunctionNotificationContainer container = new FunctionNotificationContainer(module.getConfiguration().getId(), module, function.getAddress(), "UPDATE");
    final PostgreSQLFunctionNotificationParser parser = new PostgreSQLFunctionNotificationParser();
    parser.inform(Lists.newArrayList(container), provider);
    assertEquals("Mock Function", function.getName());
}
Also used : FunctionNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer) PostgreSQLFunctionNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser) Test(org.junit.Test)

Example 5 with PostgreSQLFunctionNotificationParser

use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser in project binnavi by google.

the class PostgreSQLFunctionNotificationParserTest method testFunctionInform3Resolve.

@Test
public void testFunctionInform3Resolve() throws CouldntLoadDataException {
    final INaviFunction forwardFunction = new MockFunction(provider);
    function.setForwardedFunctionInternal(forwardFunction);
    assertTrue(function.isForwarded());
    assertEquals(forwardFunction.getAddress(), function.getForwardedFunctionAddress());
    assertEquals(forwardFunction.getModule().getConfiguration().getId(), function.getForwardedFunctionModuleId());
    final FunctionNotificationContainer container = new FunctionNotificationContainer(module.getConfiguration().getId(), module, function.getAddress(), "UPDATE");
    final PostgreSQLFunctionNotificationParser parser = new PostgreSQLFunctionNotificationParser();
    parser.inform(Lists.newArrayList(container), provider);
    assertFalse(function.isForwarded());
    assertNull(function.getForwardedFunctionAddress());
    assertEquals(0, function.getForwardedFunctionModuleId());
}
Also used : MockFunction(com.google.security.zynamics.binnavi.disassembly.MockFunction) FunctionNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer) PostgreSQLFunctionNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) Test(org.junit.Test)

Aggregations

FunctionNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer)5 PostgreSQLFunctionNotificationParser (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser)5 Test (org.junit.Test)4 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)1 MockFunction (com.google.security.zynamics.binnavi.disassembly.MockFunction)1 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)1