Search in sources :

Example 76 with IUser

use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.

the class PostgreSQLGroupNodeCommentTests method editGroupNodeComment6.

@Test(expected = CouldntSaveDataException.class)
public void editGroupNodeComment6() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException {
    final INaviGroupNode groupNode = setupGroupNode();
    final List<IComment> comments = groupNode.getComments() == null ? new ArrayList<IComment>() : groupNode.getComments();
    final IComment lastComment = comments.size() == 0 ? null : Iterables.getLast(comments);
    final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
    final String commentText = " CODE NODE COMMENT TEST BEFORE EDIT ";
    final Integer commentId = getProvider().appendGroupNodeComment(groupNode, commentText, user.getUserId());
    final IComment newComment = new CComment(commentId, user, lastComment, commentText);
    final ArrayList<IComment> newComments = getProvider().loadCommentById(commentId);
    assertNotNull(newComments);
    assertEquals(comments.size() + 1, newComments.size());
    assertEquals(newComment, Iterables.getLast(newComments));
    final IUser wrongUser = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
    getProvider().editGroupNodeComment(groupNode, commentId, wrongUser.getUserId(), " FAIL ");
}
Also used : CComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment) IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) IUser(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) UniqueTestUserGenerator(com.google.security.zynamics.binnavi.Database.PostgreSQL.UniqueTestUserGenerator) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 77 with IUser

use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.

the class PostgreSQLGroupNodeCommentTests method appendInstructionCommentInGroupNode.

@Test
public void appendInstructionCommentInGroupNode() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final INaviFunction function = module.getContent().getFunctionContainer().getFunction("sub_1004565");
    final INaviView view = module.getContent().getViewContainer().getView(function);
    view.load();
    assertEquals(42, view.getNodeCount());
    final INaviViewNode node1 = view.getContent().getBasicBlocks().get(1);
    final INaviViewNode node2 = view.getContent().getBasicBlocks().get(2);
    view.getContent().createGroupNode(Lists.newArrayList(node1, node2));
    final ZyGraph graph = CGraphBuilder.buildGraph(view);
    final INaviView nonNativeView = graph.saveAs(new CModuleContainer(getDatabase(), module), " TEST INSTRUCTION COMMENTS IN GROUP NODE ", " TESTING GROUP NODE COMMENTS ");
    final INaviInstruction instruction = view.getContent().getBasicBlocks().get(0).getLastInstruction();
    final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
    final String firstCommentString = "TEST INSTRUCTION COMMENT PROPAGATION";
    final int firstCommentId = getProvider().appendGlobalInstructionComment(instruction, firstCommentString, user.getUserId());
    final IComment firstComment = new CComment(firstCommentId, user, null, firstCommentString);
    final ArrayList<IComment> commentsFromDatabase = getProvider().loadCommentById(firstCommentId);
    assertNotNull(commentsFromDatabase);
    assertEquals(1, commentsFromDatabase.size());
    assertTrue(commentsFromDatabase.contains(firstComment));
    final INaviInstruction instruction2 = nonNativeView.getBasicBlocks().get(0).getLastInstruction();
    assertEquals(1, instruction2.getGlobalComment().size());
}
Also used : IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) CModuleContainer(com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer) UniqueTestUserGenerator(com.google.security.zynamics.binnavi.Database.PostgreSQL.UniqueTestUserGenerator) CComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) IUser(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 78 with IUser

use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.

the class CUserManagerTest method editUserWrongArgumentsTest2.

@Test(expected = NullPointerException.class)
public void editUserWrongArgumentsTest2() throws CouldntSaveDataException {
    final CUserManager manager = CUserManager.get(m_sql);
    final IUser user = manager.addUser("TEST USER 12412");
    manager.editUserName(user, null);
}
Also used : IUser(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser) CUserManager(com.google.security.zynamics.binnavi.Gui.Users.CUserManager) Test(org.junit.Test)

Example 79 with IUser

use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.

the class CUserManagerTest method setCurrentActiveUserCorrectArgumentsTest.

@Test
public void setCurrentActiveUserCorrectArgumentsTest() throws CouldntSaveDataException {
    final CUserManager manager = CUserManager.get(m_sql);
    final IUser user = manager.addUser(" TEST SET CURRENT ACTIVE USER ");
    manager.setCurrentActiveUser(user);
}
Also used : IUser(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser) CUserManager(com.google.security.zynamics.binnavi.Gui.Users.CUserManager) Test(org.junit.Test)

Example 80 with IUser

use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.

the class CUserManagerTest method editUserCorrectArgumentsTest.

@Test
public void editUserCorrectArgumentsTest() throws CouldntSaveDataException {
    final CUserManager manager = CUserManager.get(m_sql);
    final IUser user1 = manager.addUser("TWO");
    final IUser user2 = manager.editUserName(user1, "TWO AFTER EDIT");
    assertEquals("TWO", user1.getUserName());
    assertEquals("TWO AFTER EDIT", user2.getUserName());
    assertTrue(user1.getUserId() == user2.getUserId());
}
Also used : IUser(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser) CUserManager(com.google.security.zynamics.binnavi.Gui.Users.CUserManager) Test(org.junit.Test)

Aggregations

IUser (com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser)120 Test (org.junit.Test)109 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)99 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)97 CComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment)96 UniqueTestUserGenerator (com.google.security.zynamics.binnavi.Database.PostgreSQL.UniqueTestUserGenerator)95 CUserManager (com.google.security.zynamics.binnavi.Gui.Users.CUserManager)11 INaviGroupNode (com.google.security.zynamics.binnavi.disassembly.INaviGroupNode)9 INaviTextNode (com.google.security.zynamics.binnavi.disassembly.INaviTextNode)8 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)6 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)4 CouldntDeleteException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)3 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)3 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)3 CNaviViewEdge (com.google.security.zynamics.binnavi.disassembly.CNaviViewEdge)3 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)3 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)3 ArrayList (java.util.ArrayList)3 CUser (com.google.security.zynamics.binnavi.Gui.Users.CUser)2 IUserManagerListener (com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUserManagerListener)2