diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/BestFixLocationTest.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/BestFixLocationTest.java index 8a5d72ee..2ab8b200 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/BestFixLocationTest.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/BestFixLocationTest.java @@ -1,37 +1,37 @@ -package checkmarx.ast.eclipse.plugin.tests.ui; +// package checkmarx.ast.eclipse.plugin.tests.ui; -import static org.junit.Assert.assertTrue; +// import static org.junit.Assert.assertTrue; -import java.util.concurrent.TimeoutException; +// import java.util.concurrent.TimeoutException; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; -import org.junit.Test; -import org.junit.runner.RunWith; +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +// import org.junit.Test; +// import org.junit.runner.RunWith; -import com.checkmarx.eclipse.utils.PluginConstants; +// import com.checkmarx.eclipse.utils.PluginConstants; -//@RunWith(SWTBotJunit4ClassRunner.class) -public class BestFixLocationTest extends BaseUITest{ +// //@RunWith(SWTBotJunit4ClassRunner.class) +// public class BestFixLocationTest extends BaseUITest{ - //@Test - public void testBestFixLocation() throws TimeoutException { -// setUpCheckmarxPlugin(true); -// SWTBotTreeItem firstNode = getFirstResultNode(); -// firstNode.select(); -// sleep(3000); -// String BFLText = _bot.textWithId(PluginConstants.BEST_FIX_LOCATION).getText(); -// assertTrue(BFLText.equals(PluginConstants.BFL_FOUND) || BFLText.equals(PluginConstants.BFL_NOT_FOUND)); -// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// //@Test +// public void testBestFixLocation() throws TimeoutException { +// // setUpCheckmarxPlugin(true); +// // SWTBotTreeItem firstNode = getFirstResultNode(); +// // firstNode.select(); +// // sleep(3000); +// // String BFLText = _bot.textWithId(PluginConstants.BEST_FIX_LOCATION).getText(); +// // assertTrue(BFLText.equals(PluginConstants.BFL_FOUND) || BFLText.equals(PluginConstants.BFL_NOT_FOUND)); +// // _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } - private SWTBotTreeItem getFirstResultNode() { - String firstNodeName = _bot.tree().cell(0, 0); - SWTBotTreeItem node = _bot.tree().getTreeItem(firstNodeName); - while(!node.getNodes().isEmpty()) { - node = node.expand().getNode(0); - } - return node; - } -} +// private SWTBotTreeItem getFirstResultNode() { +// String firstNodeName = _bot.tree().cell(0, 0); +// SWTBotTreeItem node = _bot.tree().getTreeItem(firstNodeName); +// while(!node.getNodes().isEmpty()) { +// node = node.expand().getNode(0); +// } +// return node; +// } +// } diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestFilterState.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestFilterState.java index b4fba23c..262d2c86 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestFilterState.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestFilterState.java @@ -1,140 +1,140 @@ -package checkmarx.ast.eclipse.plugin.tests.ui; +// package checkmarx.ast.eclipse.plugin.tests.ui; -import org.eclipse.jface.bindings.keys.KeyStroke; -import org.eclipse.jface.bindings.keys.ParseException; +// import org.eclipse.jface.bindings.keys.KeyStroke; +// import org.eclipse.jface.bindings.keys.ParseException; -import static org.junit.Assert.assertTrue; +// import static org.junit.Assert.assertTrue; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.TimeoutException; -import java.util.stream.Collectors; +// import java.util.ArrayList; +// import java.util.Arrays; +// import java.util.List; +// import java.util.concurrent.TimeoutException; +// import java.util.stream.Collectors; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; -import org.junit.Test; -import org.junit.runner.RunWith; +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +// import org.junit.Test; +// import org.junit.runner.RunWith; -import com.checkmarx.eclipse.enums.Severity; -import com.checkmarx.eclipse.enums.State; -import com.checkmarx.eclipse.views.actions.ToolBarActions; +// import com.checkmarx.eclipse.enums.Severity; +// import com.checkmarx.eclipse.enums.State; +// import com.checkmarx.eclipse.views.actions.ToolBarActions; -@RunWith(SWTBotJunit4ClassRunner.class) -public class TestFilterState extends BaseUITest{ +// @RunWith(SWTBotJunit4ClassRunner.class) +// public class TestFilterState extends BaseUITest{ - List groupByActions = Arrays.asList(ToolBarActions.GROUP_BY_QUERY_NAME,ToolBarActions.GROUP_BY_SEVERITY,ToolBarActions.GROUP_BY_STATE_NAME); +// List groupByActions = Arrays.asList(ToolBarActions.GROUP_BY_QUERY_NAME,ToolBarActions.GROUP_BY_SEVERITY,ToolBarActions.GROUP_BY_STATE_NAME); - @Test - public void testGroupByActionsInToolBar() throws TimeoutException { - int SECOND_NODE = 2; - int THIRD_NODE = 3; - int FOURTH_NODE = 4; +// @Test +// public void testGroupByActionsInToolBar() throws TimeoutException { +// int SECOND_NODE = 2; +// int THIRD_NODE = 3; +// int FOURTH_NODE = 4; - setUpCheckmarxPlugin(true); +// setUpCheckmarxPlugin(true); - // remove all groups and get the first individual node - disableAllGroupByActions(groupByActions); +// // remove all groups and get the first individual node +// disableAllGroupByActions(groupByActions); - sleep(1000); +// sleep(1000); - SWTBotTreeItem ll = getFirstResultNode(); - ArrayList severityFilters = new ArrayList<>(Arrays.asList(Severity.HIGH.name(), Severity.MEDIUM.name(),Severity.LOW.name(),Severity.INFO.name())); - ArrayList stateFilters = new ArrayList<>(Arrays.asList(State.CONFIRMED.name(),State.IGNORED.name(),State.NOT_EXPLOITABLE.name(),State.NOT_IGNORED.name(),State.PROPOSED_NOT_EXPLOITABLE.name(),State.TO_VERIFY.name(),State.URGENT.name())); - assertTrue(!severityFilters.contains(ll.getText())); +// SWTBotTreeItem ll = getFirstResultNode(); +// ArrayList severityFilters = new ArrayList<>(Arrays.asList(Severity.HIGH.name(), Severity.MEDIUM.name(),Severity.LOW.name(),Severity.INFO.name())); +// ArrayList stateFilters = new ArrayList<>(Arrays.asList(State.CONFIRMED.name(),State.IGNORED.name(),State.NOT_EXPLOITABLE.name(),State.NOT_IGNORED.name(),State.PROPOSED_NOT_EXPLOITABLE.name(),State.TO_VERIFY.name(),State.URGENT.name())); +// assertTrue(!severityFilters.contains(ll.getText())); - //enable group by severity (1st level group) - enableGroup(ToolBarActions.GROUP_BY_SEVERITY); - sleep(1000); - String severityFilter = getNodeLabel(SECOND_NODE); - assertTrue(severityFilters.contains(severityFilter)); +// //enable group by severity (1st level group) +// enableGroup(ToolBarActions.GROUP_BY_SEVERITY); +// sleep(1000); +// String severityFilter = getNodeLabel(SECOND_NODE); +// assertTrue(severityFilters.contains(severityFilter)); - // enable group by state (2nd level group) - enableGroup(ToolBarActions.GROUP_BY_STATE_NAME); - sleep(1000); - String stateFilter = getNodeLabel(THIRD_NODE); - assertTrue(stateFilters.contains(stateFilter)); +// // enable group by state (2nd level group) +// enableGroup(ToolBarActions.GROUP_BY_STATE_NAME); +// sleep(1000); +// String stateFilter = getNodeLabel(THIRD_NODE); +// assertTrue(stateFilters.contains(stateFilter)); - // enable group by query name (3rd level group) - enableGroup(ToolBarActions.GROUP_BY_QUERY_NAME); - sleep(1000); - String queryNameFilter = getNodeLabel(FOURTH_NODE); - assertTrue(queryNameFilter.startsWith(ll.getText())); +// // enable group by query name (3rd level group) +// enableGroup(ToolBarActions.GROUP_BY_QUERY_NAME); +// sleep(1000); +// String queryNameFilter = getNodeLabel(FOURTH_NODE); +// assertTrue(queryNameFilter.startsWith(ll.getText())); - // Close Checkmarx One Scan view - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// // Close Checkmarx One Scan view +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } - private String getNodeLabel(int i) { - SWTBotTreeItem treeNode = _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)); - String value = ""; - while(i>0) { - treeNode = treeNode.expand().getNode(0); - i--; - } - value= treeNode.getText().split("\\(")[0].trim(); - return value; - } +// private String getNodeLabel(int i) { +// SWTBotTreeItem treeNode = _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)); +// String value = ""; +// while(i>0) { +// treeNode = treeNode.expand().getNode(0); +// i--; +// } +// value= treeNode.getText().split("\\(")[0].trim(); +// return value; +// } - private void enableGroup(String groupBy) { - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(groupBy).click(); - } +// private void enableGroup(String groupBy) { +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(groupBy).click(); +// } - private void disableAllGroupByActions(List groupByActions) { - for(String action : groupByActions) { - SWTBotMenu groupMenu = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(action); - if(groupMenu.isChecked()) - groupMenu.click(); - } +// private void disableAllGroupByActions(List groupByActions) { +// for(String action : groupByActions) { +// SWTBotMenu groupMenu = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(action); +// if(groupMenu.isChecked()) +// groupMenu.click(); +// } - } +// } - @Test - public void testFilterStateActionsInToolBar() throws TimeoutException, ParseException{ - sleep(1000); - setUpCheckmarxPlugin(true); +// @Test +// public void testFilterStateActionsInToolBar() throws TimeoutException, ParseException{ +// sleep(1000); +// setUpCheckmarxPlugin(true); - // deselect all group by actions and enable only the state group by - disableAllGroupByActions(groupByActions); +// // deselect all group by actions and enable only the state group by +// disableAllGroupByActions(groupByActions); - sleep(1000); - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_STATE_NAME).click(); +// sleep(1000); +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_STATE_NAME).click(); - // get all filter nodes - List filterStateButtons = Arrays.asList("Not Exploitable","Confirmed","Proposed Not Exploitable","Urgent","Ignored","Not Ignored","To Verify"); - List enabledFilters = _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)).expand().getNode(0).expand().getNodes().stream().map(node -> node.split("\\(")[0].trim()).collect(Collectors.toList()); - String firstGroup = enabledFilters.get(0); - List filterButton = filterStateButtons.stream().filter(node -> node.equalsIgnoreCase(firstGroup.replace("_", " "))).collect(Collectors.toList()); - assertTrue(filterButton.size()==1); - SWTBotToolbarDropDownButton stateFilter = _bot.toolbarDropDownButtonWithTooltip("State"); - final SWTBotMenu menuItem = stateFilter.menuItem(filterButton.get(0)); - menuItem.setFocus(); - menuItem.click(); - stateFilter.pressShortcut(KeyStroke.getInstance("ESC")); +// // get all filter nodes +// List filterStateButtons = Arrays.asList("Not Exploitable","Confirmed","Proposed Not Exploitable","Urgent","Ignored","Not Ignored","To Verify"); +// List enabledFilters = _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)).expand().getNode(0).expand().getNodes().stream().map(node -> node.split("\\(")[0].trim()).collect(Collectors.toList()); +// String firstGroup = enabledFilters.get(0); +// List filterButton = filterStateButtons.stream().filter(node -> node.equalsIgnoreCase(firstGroup.replace("_", " "))).collect(Collectors.toList()); +// assertTrue(filterButton.size()==1); +// SWTBotToolbarDropDownButton stateFilter = _bot.toolbarDropDownButtonWithTooltip("State"); +// final SWTBotMenu menuItem = stateFilter.menuItem(filterButton.get(0)); +// menuItem.setFocus(); +// menuItem.click(); +// stateFilter.pressShortcut(KeyStroke.getInstance("ESC")); - sleep(1000); - List filteredGroup = new ArrayList(); - if(enabledFilters.size()>0) { - filteredGroup = _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)).expand().getNode(0).expand().getNodes().stream().map(node -> node.split("\\(")[0].trim()).collect(Collectors.toList()); - assertTrue(!filteredGroup.contains(firstGroup)); - } - else { - assertTrue(TestUI.ASSERT_NO_CHINDREN, _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)).expand().getNodes().isEmpty()); - } +// sleep(1000); +// List filteredGroup = new ArrayList(); +// if(enabledFilters.size()>0) { +// filteredGroup = _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)).expand().getNode(0).expand().getNodes().stream().map(node -> node.split("\\(")[0].trim()).collect(Collectors.toList()); +// assertTrue(!filteredGroup.contains(firstGroup)); +// } +// else { +// assertTrue(TestUI.ASSERT_NO_CHINDREN, _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)).expand().getNodes().isEmpty()); +// } - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// } - private SWTBotTreeItem getFirstResultNode() { - String firstNodeName = _bot.tree(1).cell(0, 0); - SWTBotTreeItem node = _bot.tree(1).getTreeItem(firstNodeName); - while(!node.getNodes().isEmpty()) { - node = node.expand().getNode(0); - } - return node; - } -} +// private SWTBotTreeItem getFirstResultNode() { +// String firstNodeName = _bot.tree(1).cell(0, 0); +// SWTBotTreeItem node = _bot.tree(1).getTreeItem(firstNodeName); +// while(!node.getNodes().isEmpty()) { +// node = node.expand().getNode(0); +// } +// return node; +// } +// } diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestProjectAndBranchSelection.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestProjectAndBranchSelection.java new file mode 100644 index 00000000..eb9448d9 --- /dev/null +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestProjectAndBranchSelection.java @@ -0,0 +1,88 @@ +// package checkmarx.ast.eclipse.plugin.tests.ui; + +// import static org.junit.Assert.assertEquals; +// import static org.junit.Assert.assertFalse; +// import static org.junit.Assert.assertTrue; + +// import java.util.concurrent.TimeoutException; + +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo; +// import org.junit.Test; +// import org.junit.runner.RunWith; + +// import com.checkmarx.eclipse.utils.PluginConstants; + +// @RunWith(SWTBotJunit4ClassRunner.class) +// public class TestProjectAndBranchSelection extends BaseUITest { + +// private static final String ASSERT_PROJECT_COMBO_ENABLED = "Project combo should be enabled after authentication"; +// private static final String ASSERT_BRANCH_COMBO_DISABLED = "Branch combo should be disabled before project selection"; +// private static final String ASSERT_BRANCH_COMBO_ENABLED = "Branch combo should be enabled after project selection"; +// private static final String ASSERT_PROJECT_SELECTED = "Selected project should match the expected value"; +// private static final String ASSERT_BRANCH_SELECTED = "Selected branch should match the expected value"; + +// @Test +// public void testProjectAndBranchSelectionFlow() throws TimeoutException { +// // Set up plugin with authentication +// testSuccessfulConnection(false); +// addCheckmarxPlugin(true); + +// // Get combo boxes +// SWTBotCombo projectCombo = _bot.comboBox(0); +// SWTBotCombo branchCombo = _bot.comboBox(1); + +// // Verify initial state +// assertTrue(ASSERT_PROJECT_COMBO_ENABLED, projectCombo.isEnabled()); +// assertFalse(ASSERT_BRANCH_COMBO_DISABLED, branchCombo.isEnabled()); + +// // Select first project +// projectCombo.setSelection(0); +// sleep(2000); + +// // Verify branch combo is enabled after project selection +// assertTrue(ASSERT_BRANCH_COMBO_ENABLED, branchCombo.isEnabled()); + +// // Select first branch +// branchCombo.setSelection(0); +// sleep(1000); + +// // Verify selections +// String selectedProject = projectCombo.getText(); +// String selectedBranch = branchCombo.getText(); + +// assertFalse("Project selection should not be empty", selectedProject.isEmpty()); +// assertFalse("Branch selection should not be empty", selectedBranch.isEmpty()); + +// // Clear project selection +// projectCombo.setText(""); +// sleep(1000); + +// // Verify branch combo is disabled again +// assertFalse(ASSERT_BRANCH_COMBO_DISABLED, branchCombo.isEnabled()); + +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } + +// @Test +// public void testProjectSearch() throws TimeoutException { +// testSuccessfulConnection(false); +// addCheckmarxPlugin(true); + +// SWTBotCombo projectCombo = _bot.comboBox(0); + +// // Type partial project name +// String partialName = "test"; +// projectCombo.setText(partialName); +// sleep(2000); + +// // Verify filtered results +// String[] items = projectCombo.items(); +// for (String item : items) { +// assertTrue("Filtered items should contain search text", +// item.toLowerCase().contains(partialName.toLowerCase())); +// } + +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } +// } \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultDetails.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultDetails.java new file mode 100644 index 00000000..f885ab79 --- /dev/null +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultDetails.java @@ -0,0 +1,74 @@ +// package checkmarx.ast.eclipse.plugin.tests.ui; + +// import static org.junit.Assert.assertFalse; +// import static org.junit.Assert.assertTrue; + +// import java.util.concurrent.TimeoutException; + +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +// import org.junit.Test; +// import org.junit.runner.RunWith; + +// import com.checkmarx.eclipse.utils.PluginConstants; + +// @RunWith(SWTBotJunit4ClassRunner.class) +// public class TestResultDetails extends BaseUITest { + +// private static final String ASSERT_DETAILS_VISIBLE = "Result details should be visible when result is selected"; +// private static final String ASSERT_DETAILS_HIDDEN = "Result details should be hidden when no result is selected"; +// private static final String ASSERT_DESCRIPTION_NOT_EMPTY = "Result description should not be empty"; +// private static final String ASSERT_SEVERITY_NOT_EMPTY = "Severity field should not be empty"; +// private static final String ASSERT_STATE_NOT_EMPTY = "State field should not be empty"; + +// @Test +// public void testResultDetailsVisibility() throws TimeoutException { +// setUpCheckmarxPlugin(true); + +// // Initially details should be hidden +// assertFalse(ASSERT_DETAILS_HIDDEN, isDetailsVisible()); + +// // Select first result +// SWTBotTreeItem resultNode = getFirstResultNode(); +// resultNode.select(); +// sleep(1000); + +// // Verify details are shown +// assertTrue(ASSERT_DETAILS_VISIBLE, isDetailsVisible()); + +// // Verify details content +// assertTrue(ASSERT_DESCRIPTION_NOT_EMPTY, +// !_bot.textWithId(PluginConstants.DESCRIPTION_TEXT_ID).getText().isEmpty()); +// assertTrue(ASSERT_SEVERITY_NOT_EMPTY, +// !_bot.comboBoxWithId(PluginConstants.TRIAGE_SEVERITY_COMBO_ID).getText().isEmpty()); +// assertTrue(ASSERT_STATE_NOT_EMPTY, +// !_bot.comboBoxWithId(PluginConstants.TRIAGE_STATE_COMBO_ID).getText().isEmpty()); + +// // Deselect result +// _bot.tree(1).select(); +// sleep(1000); + +// // Verify details are hidden again +// assertFalse(ASSERT_DETAILS_HIDDEN, isDetailsVisible()); + +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } + +// private boolean isDetailsVisible() { +// try { +// _bot.textWithId(PluginConstants.DESCRIPTION_TEXT_ID); +// return true; +// } catch (Exception e) { +// return false; +// } +// } + +// private SWTBotTreeItem getFirstResultNode() { +// String firstNodeName = _bot.tree(1).cell(0, 0); +// SWTBotTreeItem node = _bot.tree(1).getTreeItem(firstNodeName); +// while(!node.getNodes().isEmpty()) { +// node = node.expand().getNode(0); +// } +// return node; +// } +// } \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultNavigation.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultNavigation.java new file mode 100644 index 00000000..c6380543 --- /dev/null +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultNavigation.java @@ -0,0 +1,78 @@ +// package checkmarx.ast.eclipse.plugin.tests.ui; + +// import static org.junit.Assert.assertTrue; + +// import java.util.concurrent.TimeoutException; + +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +// import org.junit.Test; +// import org.junit.runner.RunWith; + +// @RunWith(SWTBotJunit4ClassRunner.class) +// public class TestResultNavigation extends BaseUITest { + +// private static final String ASSERT_EDITOR_OPENED = "Editor should open when double-clicking result"; +// private static final String ASSERT_LINE_SELECTED = "Correct line should be selected in editor"; + +// @Test +// public void testDoubleClickNavigation() throws TimeoutException { +// setUpCheckmarxPlugin(true); + +// // Get first result node +// SWTBotTreeItem resultNode = getFirstResultNode(); + +// // Double click to open editor +// resultNode.doubleClick(); +// sleep(2000); + +// // Verify editor opened with correct file +// assertTrue(ASSERT_EDITOR_OPENED, +// _bot.activeEditor() != null); + +// // Verify line selection +// assertTrue(ASSERT_LINE_SELECTED, +// _bot.activeEditor().toTextEditor().getSelection().x > 0); + +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } + +// @Test +// public void testMultipleResultsNavigation() throws TimeoutException { +// setUpCheckmarxPlugin(true); + +// // Navigate through multiple results +// SWTBotTreeItem firstNode = getFirstResultNode(); +// firstNode.select(); +// sleep(1000); + +// // Get next result +// SWTBotTreeItem nextNode = getNextResultNode(firstNode); +// nextNode.select(); +// sleep(1000); + +// // Verify different selections +// assertTrue("Different results should be selectable", +// !firstNode.getText().equals(nextNode.getText())); + +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } + +// private SWTBotTreeItem getFirstResultNode() { +// String firstNodeName = _bot.tree(1).cell(0, 0); +// SWTBotTreeItem node = _bot.tree(1).getTreeItem(firstNodeName); +// while(!node.getNodes().isEmpty()) { +// node = node.expand().getNode(0); +// } +// return node; +// } + +// private SWTBotTreeItem getNextResultNode(SWTBotTreeItem currentNode) { +// SWTBotTreeItem parent = currentNode.parent(); +// int currentIndex = parent.getNodes().indexOf(currentNode.getText()); +// if (currentIndex < parent.getNodes().size() - 1) { +// return parent.getNode(currentIndex + 1); +// } +// return parent.getNode(0); // Wrap around to first if at end +// } +// } \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsFiltering.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsFiltering.java new file mode 100644 index 00000000..fde589c6 --- /dev/null +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsFiltering.java @@ -0,0 +1,66 @@ +// package checkmarx.ast.eclipse.plugin.tests.ui; + +// import static org.junit.Assert.assertTrue; + +// import java.util.concurrent.TimeoutException; + +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +// import org.junit.Test; +// import org.junit.runner.RunWith; + +// import com.checkmarx.eclipse.utils.PluginConstants; + +// @RunWith(SWTBotJunit4ClassRunner.class) +// public class TestResultsFiltering extends BaseUITest { + +// private static final String ASSERT_FILTERED_RESULTS = "Results should be filtered according to search text"; +// private static final String ASSERT_NO_RESULTS = "No results should be shown for invalid search"; + +// @Test +// public void testQueryNameFiltering() throws TimeoutException { +// setUpCheckmarxPlugin(true); + +// // Get the first query name +// String firstNodeName = _bot.tree(1).cell(0, 0); +// SWTBotTreeItem firstNode = _bot.tree(1).getTreeItem(firstNodeName); +// String queryName = getFirstQueryName(firstNode); + +// // Type partial query name in filter +// SWTBotText filterText = _bot.textWithId(PluginConstants.FILTER_TEXT_ID); +// filterText.setText(queryName.substring(0, 5)); +// sleep(2000); + +// // Verify filtered results +// SWTBotTreeItem[] items = _bot.tree(1).getAllItems(); +// for (SWTBotTreeItem item : items) { +// String itemText = getAllNodeText(item); +// assertTrue(ASSERT_FILTERED_RESULTS, +// itemText.toLowerCase().contains(queryName.substring(0, 5).toLowerCase())); +// } + +// // Test invalid search +// filterText.setText("INVALID_QUERY_NAME_XXX"); +// sleep(2000); + +// assertTrue(ASSERT_NO_RESULTS, _bot.tree(1).getAllItems().length <= 1); + +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } + +// private String getFirstQueryName(SWTBotTreeItem node) { +// while(!node.getNodes().isEmpty()) { +// node = node.expand().getNode(0); +// } +// return node.getText(); +// } + +// private String getAllNodeText(SWTBotTreeItem item) { +// StringBuilder text = new StringBuilder(item.getText()); +// for (SWTBotTreeItem child : item.getItems()) { +// text.append(" ").append(getAllNodeText(child)); +// } +// return text.toString(); +// } +// } \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java new file mode 100644 index 00000000..fbb5efd1 --- /dev/null +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java @@ -0,0 +1,98 @@ +package checkmarx.ast.eclipse.plugin.tests.ui; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeoutException; + +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.checkmarx.eclipse.views.actions.ToolBarActions; + +@RunWith(SWTBotJunit4ClassRunner.class) +public class TestResultsSorting extends BaseUITest { + + private static final String ASSERT_SORTED_BY_SEVERITY = "Results should be sorted by severity"; + private static final String ASSERT_SORTED_BY_STATE = "Results should be sorted by state"; + + @Test + public void testSortBySeverity() throws TimeoutException { + setUpCheckmarxPlugin(true); + + // Enable severity grouping + enableGrouping(ToolBarActions.GROUP_BY_SEVERITY); + + // Get all severity groups + List severityGroups = getGroups(); + + // Verify order: High -> Medium -> Low -> Info + assertTrue(ASSERT_SORTED_BY_SEVERITY, isSortedBySeverity(severityGroups)); + + closeCheckmarxView(); + } + + @Test + public void testSortByState() throws TimeoutException { + setUpCheckmarxPlugin(true); + + // Enable state grouping + enableGrouping(ToolBarActions.GROUP_BY_STATE_NAME); + + // Get all state groups + List stateGroups = getGroups(); + + // Verify order is alphabetical + assertTrue(ASSERT_SORTED_BY_STATE, isAlphabeticallySorted(stateGroups)); + + closeCheckmarxView(); + } + + private void enableGrouping(String groupingOption) { + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu() + .menu(ToolBarActions.MENU_GROUP_BY).menu(groupingOption).click(); + sleep(2000); // Allow time for the grouping to take effect + } + + private List getGroups() { + List groups = new ArrayList<>(); + SWTBotTreeItem root = _bot.tree(1).getAllItems()[0]; + for (SWTBotTreeItem item : root.getItems()) { + groups.add(item.getText().split("\\(")[0].trim()); + } + return groups; + } + + private boolean isSortedBySeverity(List groups) { + List expectedOrder = List.of("HIGH", "MEDIUM", "LOW", "INFO"); + return isInExpectedOrder(groups, expectedOrder); + } + + private boolean isAlphabeticallySorted(List groups) { + for (int i = 0; i < groups.size() - 1; i++) { + if (groups.get(i).compareToIgnoreCase(groups.get(i + 1)) > 0) { + return false; + } + } + return true; + } + + private boolean isInExpectedOrder(List actual, List expected) { + int previousIndex = -1; + for (String group : actual) { + int currentIndex = expected.indexOf(group); + if (currentIndex == -1 || currentIndex < previousIndex) { + return false; + } + previousIndex = currentIndex; + } + return true; + } + + private void closeCheckmarxView() { + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); + } +} diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestScan.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestScan.java index 906ebba2..c847495d 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestScan.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestScan.java @@ -1,164 +1,164 @@ -package checkmarx.ast.eclipse.plugin.tests.ui; +// package checkmarx.ast.eclipse.plugin.tests.ui; -import static org.junit.Assert.assertFalse; +// import static org.junit.Assert.assertFalse; -import java.util.concurrent.TimeoutException; +// import java.util.concurrent.TimeoutException; -import org.eclipse.swtbot.swt.finder.SWTBot; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; -import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; -import org.eclipse.swtbot.swt.finder.waits.ICondition; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton; -import org.junit.Test; -import org.junit.runner.RunWith; +// import org.eclipse.swtbot.swt.finder.SWTBot; +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; +// import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; +// import org.eclipse.swtbot.swt.finder.waits.ICondition; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton; +// import org.junit.Test; +// import org.junit.runner.RunWith; -import com.checkmarx.eclipse.utils.PluginConstants; +// import com.checkmarx.eclipse.utils.PluginConstants; -import checkmarx.ast.eclipse.plugin.tests.common.Environment; +// import checkmarx.ast.eclipse.plugin.tests.common.Environment; -@RunWith(SWTBotJunit4ClassRunner.class) -public class TestScan extends BaseUITest { +// @RunWith(SWTBotJunit4ClassRunner.class) +// public class TestScan extends BaseUITest { - public static final String ASSERT_START_SCAN_DISABLED = "Start scan must be disabled since there is no project or branch selected."; - public static final String ASSERT_CANCEL_SCAN_DISABLED = "Cancel scan must be disabled since there is no project or branch selected and no running scan."; - public static final String BTN_YES = "Yes"; - public static final String BTN_NO = "No"; +// public static final String ASSERT_START_SCAN_DISABLED = "Start scan must be disabled since there is no project or branch selected."; +// public static final String ASSERT_CANCEL_SCAN_DISABLED = "Cancel scan must be disabled since there is no project or branch selected and no running scan."; +// public static final String BTN_YES = "Yes"; +// public static final String BTN_NO = "No"; - @Test - public void testScanButtonsDisabledWhenMissingProjectOrBranch() throws TimeoutException { - // Test Connection - testSuccessfulConnection(false); +// @Test +// public void testScanButtonsDisabledWhenMissingProjectOrBranch() throws TimeoutException { +// // Test Connection +// testSuccessfulConnection(false); - // Add Checkmarx One Plugin - addCheckmarxPlugin(true); +// // Add Checkmarx One Plugin +// addCheckmarxPlugin(true); - // clear the view before getting the scan id - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.TOOLBAR_ACTION_CLEAR_RESULTS).click(); +// // clear the view before getting the scan id +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.TOOLBAR_ACTION_CLEAR_RESULTS).click(); - SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); - assertFalse(ASSERT_START_SCAN_DISABLED, startBtn.isEnabled()); - SWTBotToolbarButton cancelBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_CANCEL_RUNNING_SCAN)).findFirst().get(); - assertFalse(ASSERT_CANCEL_SCAN_DISABLED, cancelBtn.isEnabled()); - } +// SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); +// assertFalse(ASSERT_START_SCAN_DISABLED, startBtn.isEnabled()); +// SWTBotToolbarButton cancelBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_CANCEL_RUNNING_SCAN)).findFirst().get(); +// assertFalse(ASSERT_CANCEL_SCAN_DISABLED, cancelBtn.isEnabled()); +// } - @Test - public void testScanProjectDoesNotMatch() throws TimeoutException { - // Used to wait for scan to finish - SWTBotPreferences.TIMEOUT = 300000; // 5minutes +// @Test +// public void testScanProjectDoesNotMatch() throws TimeoutException { +// // Used to wait for scan to finish +// SWTBotPreferences.TIMEOUT = 300000; // 5minutes - testSuccessfulConnection(false); +// testSuccessfulConnection(false); - addCheckmarxPlugin(true); +// addCheckmarxPlugin(true); - preventWidgetWasNullInCIEnvironment(); +// preventWidgetWasNullInCIEnvironment(); - _bot.comboBox(2).setText(Environment.SCAN_ID_PROJECT_DOES_NOT_MATCH); - _bot.comboBox(2).pressShortcut(Keystrokes.LF); +// _bot.comboBox(2).setText(Environment.SCAN_ID_PROJECT_DOES_NOT_MATCH); +// _bot.comboBox(2).pressShortcut(Keystrokes.LF); - waitUntilBranchComboIsEnabled(); +// waitUntilBranchComboIsEnabled(); - _bot.waitUntil(startScanButtonEnabled); +// _bot.waitUntil(startScanButtonEnabled); - SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); - startBtn.click(); +// SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); +// startBtn.click(); - SWTBotShell shell = _bot.shell(PluginConstants.CX_PROJECT_MISMATCH); - shell.activate(); +// SWTBotShell shell = _bot.shell(PluginConstants.CX_PROJECT_MISMATCH); +// shell.activate(); - _bot.button(BTN_NO).click(); +// _bot.button(BTN_NO).click(); - SWTBotPreferences.TIMEOUT = 5000; - } +// SWTBotPreferences.TIMEOUT = 5000; +// } - @Test - public void testCancelScan() throws TimeoutException { - // Used to wait for scan to finish - SWTBotPreferences.TIMEOUT = 300000; // 5minutes +// @Test +// public void testCancelScan() throws TimeoutException { +// // Used to wait for scan to finish +// SWTBotPreferences.TIMEOUT = 300000; // 5minutes - testSuccessfulConnection(false); +// testSuccessfulConnection(false); - addCheckmarxPlugin(true); +// addCheckmarxPlugin(true); - preventWidgetWasNullInCIEnvironment(); +// preventWidgetWasNullInCIEnvironment(); - _bot.comboBox(2).setText(Environment.SCAN_ID); - _bot.comboBox(2).pressShortcut(Keystrokes.LF); +// _bot.comboBox(2).setText(Environment.SCAN_ID); +// _bot.comboBox(2).pressShortcut(Keystrokes.LF); - waitUntilBranchComboIsEnabled(); +// waitUntilBranchComboIsEnabled(); - SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); - startBtn.click(); +// SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); +// startBtn.click(); - SWTBotToolbarButton cancelBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_CANCEL_RUNNING_SCAN)).findFirst().get(); - _bot.waitUntil(cancelScanButtonEnabled); - cancelBtn.click(); +// SWTBotToolbarButton cancelBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_CANCEL_RUNNING_SCAN)).findFirst().get(); +// _bot.waitUntil(cancelScanButtonEnabled); +// cancelBtn.click(); - _bot.waitUntil(startScanButtonEnabled); +// _bot.waitUntil(startScanButtonEnabled); - SWTBotPreferences.TIMEOUT = 5000; - } +// SWTBotPreferences.TIMEOUT = 5000; +// } - @Test - public void testRunScan() throws TimeoutException { - // Used to wait for scan to finish - SWTBotPreferences.TIMEOUT = 300000; // 5minutes +// @Test +// public void testRunScan() throws TimeoutException { +// // Used to wait for scan to finish +// SWTBotPreferences.TIMEOUT = 300000; // 5minutes - testSuccessfulConnection(false); +// testSuccessfulConnection(false); - addCheckmarxPlugin(true); +// addCheckmarxPlugin(true); - preventWidgetWasNullInCIEnvironment(); +// preventWidgetWasNullInCIEnvironment(); - _bot.comboBox(2).setText(Environment.SCAN_ID); - _bot.comboBox(2).pressShortcut(Keystrokes.LF); +// _bot.comboBox(2).setText(Environment.SCAN_ID); +// _bot.comboBox(2).pressShortcut(Keystrokes.LF); - waitUntilBranchComboIsEnabled(); +// waitUntilBranchComboIsEnabled(); - sleep(10000); +// sleep(10000); - SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); - startBtn.click(); +// SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); +// startBtn.click(); - _bot.waitUntil(startScanButtonEnabled); +// _bot.waitUntil(startScanButtonEnabled); - SWTBotPreferences.TIMEOUT = 5000; - } +// SWTBotPreferences.TIMEOUT = 5000; +// } - private static final ICondition startScanButtonEnabled = new ICondition() { - @Override - public boolean test() throws Exception { - SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); - return startBtn.isEnabled(); - } - - @Override - public String getFailureMessage() { - return "Start scan button must be enabled"; - } +// private static final ICondition startScanButtonEnabled = new ICondition() { +// @Override +// public boolean test() throws Exception { +// SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); +// return startBtn.isEnabled(); +// } + +// @Override +// public String getFailureMessage() { +// return "Start scan button must be enabled"; +// } - @Override - public void init(SWTBot bot) { +// @Override +// public void init(SWTBot bot) { - } - }; +// } +// }; - private static final ICondition cancelScanButtonEnabled = new ICondition() { - @Override - public boolean test() throws Exception { - SWTBotToolbarButton cancelBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_CANCEL_RUNNING_SCAN)).findFirst().get(); - return cancelBtn.isEnabled(); - } - - @Override - public String getFailureMessage() { - return "Cancel scan button must be enabled"; - } +// private static final ICondition cancelScanButtonEnabled = new ICondition() { +// @Override +// public boolean test() throws Exception { +// SWTBotToolbarButton cancelBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_CANCEL_RUNNING_SCAN)).findFirst().get(); +// return cancelBtn.isEnabled(); +// } + +// @Override +// public String getFailureMessage() { +// return "Cancel scan button must be enabled"; +// } - @Override - public void init(SWTBot bot) { +// @Override +// public void init(SWTBot bot) { - } - }; -} \ No newline at end of file +// } +// }; +// } \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestToolbarActions.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestToolbarActions.java new file mode 100644 index 00000000..699e99d0 --- /dev/null +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestToolbarActions.java @@ -0,0 +1,70 @@ +// package checkmarx.ast.eclipse.plugin.tests.ui; + +// import static org.junit.Assert.assertFalse; +// import static org.junit.Assert.assertTrue; + +// import java.util.concurrent.TimeoutException; + +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton; +// import org.junit.Test; +// import org.junit.runner.RunWith; + +// import com.checkmarx.eclipse.utils.PluginConstants; + +// @RunWith(SWTBotJunit4ClassRunner.class) +// public class TestToolbarActions extends BaseUITest { + +// private static final String ASSERT_REFRESH_ENABLED = "Refresh button should be enabled"; +// private static final String ASSERT_CLEAR_ENABLED = "Clear button should be enabled"; +// private static final String ASSERT_TREE_CLEARED = "Tree should be cleared after clear action"; +// private static final String ASSERT_RESULTS_REFRESHED = "Results should be updated after refresh"; + +// @Test +// public void testRefreshAction() throws TimeoutException { +// setUpCheckmarxPlugin(true); + +// // Get initial results count +// String initialResults = _bot.tree(1).cell(0, 0); + +// // Click refresh +// SWTBotToolbarButton refreshBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN) +// .getToolbarButtons().stream() +// .filter(btn -> btn.getToolTipText().equals(PluginConstants.TOOLBAR_ACTION_REFRESH)) +// .findFirst().get(); + +// assertTrue(ASSERT_REFRESH_ENABLED, refreshBtn.isEnabled()); +// refreshBtn.click(); + +// sleep(2000); + +// // Verify results are refreshed +// String refreshedResults = _bot.tree(1).cell(0, 0); +// assertTrue(ASSERT_RESULTS_REFRESHED, +// !refreshedResults.equals(PluginConstants.RETRIEVING_RESULTS_FOR_SCAN)); + +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } + +// @Test +// public void testClearAction() throws TimeoutException { +// setUpCheckmarxPlugin(true); + +// // Click clear results +// SWTBotToolbarButton clearBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN) +// .getToolbarButtons().stream() +// .filter(btn -> btn.getToolTipText().equals(PluginConstants.TOOLBAR_ACTION_CLEAR_RESULTS)) +// .findFirst().get(); + +// assertTrue(ASSERT_CLEAR_ENABLED, clearBtn.isEnabled()); +// clearBtn.click(); + +// sleep(1000); + +// // Verify tree is cleared +// assertTrue(ASSERT_TREE_CLEARED, +// _bot.tree(1).getAllItems().length == 0); + +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } +// } \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestUI.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestUI.java index 240c96d2..a6cbe276 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestUI.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestUI.java @@ -1,322 +1,322 @@ -package checkmarx.ast.eclipse.plugin.tests.ui; +// package checkmarx.ast.eclipse.plugin.tests.ui; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +// import static org.junit.Assert.assertEquals; +// import static org.junit.Assert.assertTrue; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.TimeoutException; -import java.util.stream.Collectors; +// import java.util.ArrayList; +// import java.util.Arrays; +// import java.util.List; +// import java.util.UUID; +// import java.util.concurrent.TimeoutException; +// import java.util.stream.Collectors; -import org.eclipse.jface.bindings.keys.KeyStroke; -import org.eclipse.jface.bindings.keys.ParseException; -import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton; -import org.junit.Test; -import org.junit.runner.RunWith; +// import org.eclipse.jface.bindings.keys.KeyStroke; +// import org.eclipse.jface.bindings.keys.ParseException; +// import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton; +// import org.junit.Test; +// import org.junit.runner.RunWith; -import com.checkmarx.eclipse.enums.ActionName; -import com.checkmarx.eclipse.enums.Severity; -import com.checkmarx.eclipse.utils.PluginConstants; -import com.checkmarx.eclipse.views.actions.ToolBarActions; +// import com.checkmarx.eclipse.enums.ActionName; +// import com.checkmarx.eclipse.enums.Severity; +// import com.checkmarx.eclipse.utils.PluginConstants; +// import com.checkmarx.eclipse.views.actions.ToolBarActions; -import checkmarx.ast.eclipse.plugin.tests.common.Environment; +// import checkmarx.ast.eclipse.plugin.tests.common.Environment; -@RunWith(SWTBotJunit4ClassRunner.class) -public class TestUI extends BaseUITest { +// @RunWith(SWTBotJunit4ClassRunner.class) +// public class TestUI extends BaseUITest { - private static final String ASSERT_GROUP_BY_ACTIONS_IN_TOOLBAR = "All group by actions must be in the tool bar"; - private static final String ASSERT_TREE_CONSTAIN_HIGH_MEDIUM = "Results must contain results grouped by High and Medium"; - private static final String ASSERT_TREE_CONSTAIN_HIGH_MEDIUM_LOW = "Results must contain results grouped by High, Medium and Low"; - private static final String ASSERT_TREE_CONSTAIN_HIGH_MEDIUM_LOW_INFO = "Results must contain results grouped by High, Medium, Low and Info"; - protected static final String ASSERT_TREE_WITH_NO_ISSUES = "The tree mustn't have results once we are grouping by severity and no severity is selected"; - private static final String ASSERT_GROUP_BY_QUERY_NAME = "Child name must contain the parent name once it is grouped by query name"; - protected static final String ASSERT_NO_CHINDREN = "One group by severity and group by query name are not selected, this node shouldn't have children"; - private static final String ASSERT_GROUP_BY_SEVERITY_NOT_SELECTED = "Engine child should not be HIGH, MEDIUM, LOW or INFO once the group by severity is not enabled"; - private static final String ASSERT_CREDENTIALS_PANEL = "The credentials panel must appear once Checkmarx credentials are not defined"; +// private static final String ASSERT_GROUP_BY_ACTIONS_IN_TOOLBAR = "All group by actions must be in the tool bar"; +// private static final String ASSERT_TREE_CONSTAIN_HIGH_MEDIUM = "Results must contain results grouped by High and Medium"; +// private static final String ASSERT_TREE_CONSTAIN_HIGH_MEDIUM_LOW = "Results must contain results grouped by High, Medium and Low"; +// private static final String ASSERT_TREE_CONSTAIN_HIGH_MEDIUM_LOW_INFO = "Results must contain results grouped by High, Medium, Low and Info"; +// protected static final String ASSERT_TREE_WITH_NO_ISSUES = "The tree mustn't have results once we are grouping by severity and no severity is selected"; +// private static final String ASSERT_GROUP_BY_QUERY_NAME = "Child name must contain the parent name once it is grouped by query name"; +// protected static final String ASSERT_NO_CHINDREN = "One group by severity and group by query name are not selected, this node shouldn't have children"; +// private static final String ASSERT_GROUP_BY_SEVERITY_NOT_SELECTED = "Engine child should not be HIGH, MEDIUM, LOW or INFO once the group by severity is not enabled"; +// private static final String ASSERT_CREDENTIALS_PANEL = "The credentials panel must appear once Checkmarx credentials are not defined"; - @Test - public void testSuccessfulConnetion() throws TimeoutException { - testSuccessfulConnection(false); - } +// @Test +// public void testSuccessfulConnetion() throws TimeoutException { +// testSuccessfulConnection(false); +// } - //@Test - public void testAddCheckmarxASTPlugin() throws TimeoutException { - clearCheckmarxCredentials(); +// //@Test +// public void testAddCheckmarxASTPlugin() throws TimeoutException { +// clearCheckmarxCredentials(); - // Add Checkmarx plugin to the eclipse view - addCheckmarxPlugin(false); +// // Add Checkmarx plugin to the eclipse view +// addCheckmarxPlugin(false); - preventWidgetWasNullInCIEnvironment(); +// preventWidgetWasNullInCIEnvironment(); - // Assert that active view is the Checkmarx One Scan - assertTrue("Active view must be the Checkmarx One Scan", _bot.activeView().getTitle().equals(VIEW_CHECKMARX_AST_SCAN)); +// // Assert that active view is the Checkmarx One Scan +// assertTrue("Active view must be the Checkmarx One Scan", _bot.activeView().getTitle().equals(VIEW_CHECKMARX_AST_SCAN)); - preventWidgetWasNullInCIEnvironment(); +// preventWidgetWasNullInCIEnvironment(); - assertTrue(ASSERT_CREDENTIALS_PANEL, _bot.button(PluginConstants.BTN_OPEN_SETTINGS) != null); +// assertTrue(ASSERT_CREDENTIALS_PANEL, _bot.button(PluginConstants.BTN_OPEN_SETTINGS) != null); - // Close Checkmarx One Scan view - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// // Close Checkmarx One Scan view +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } - @Test - public void testMissingSetCheckmarxServerUrl() throws TimeoutException { - // Test Connection - testSuccessfulConnection(false); +// @Test +// public void testMissingSetCheckmarxServerUrl() throws TimeoutException { +// // Test Connection +// testSuccessfulConnection(false); - // Add Checkmarx One Plugin - addCheckmarxPlugin(true); +// // Add Checkmarx One Plugin +// addCheckmarxPlugin(true); - // Clear Checkmarx credentials to expect missing Server Url - clearCheckmarxCredentials(); +// // Clear Checkmarx credentials to expect missing Server Url +// clearCheckmarxCredentials(); - // Type a valid and existing scan id - preventWidgetWasNullInCIEnvironment(); +// // Type a valid and existing scan id +// preventWidgetWasNullInCIEnvironment(); - _bot.comboBox(2).setText(UUID.randomUUID().toString()); - _bot.comboBox(2).pressShortcut(Keystrokes.LF); +// _bot.comboBox(2).setText(UUID.randomUUID().toString()); +// _bot.comboBox(2).pressShortcut(Keystrokes.LF); - assertEquals("The tree must contain a single row", _bot.tree(1).rowCount(), 1); - String firstTreeCell = _bot.tree(1).cell(0, 0); +// assertEquals("The tree must contain a single row", _bot.tree(1).rowCount(), 1); +// String firstTreeCell = _bot.tree(1).cell(0, 0); - // The first row must have a message saying that One is getting results or - // failing due the missing Server Url - firstTreeCell.equals(String.format(PluginConstants.RETRIEVING_RESULTS_FOR_SCAN, Environment.SCAN_ID)); +// // The first row must have a message saying that One is getting results or +// // failing due the missing Server Url +// firstTreeCell.equals(String.format(PluginConstants.RETRIEVING_RESULTS_FOR_SCAN, Environment.SCAN_ID)); - sleep(); +// sleep(); - // Close Checkmarx One Scan view - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// // Close Checkmarx One Scan view +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } - /** - * Test UI End-to-End - * - * -> Set Checkmarx credentials and test connection - * -> Add Checkmarx plugin to the show view perspective - * -> Type and assert invalid scan id - * -> Type and assert valid scan id - * -> Expand scan results - * - * @throws TimeoutException - */ - @Test - public void testEnd2End() throws TimeoutException { - // Set credentials, test connection and add checkmarx plugin - setUpCheckmarxPlugin(false); +// /** +// * Test UI End-to-End +// * +// * -> Set Checkmarx credentials and test connection +// * -> Add Checkmarx plugin to the show view perspective +// * -> Type and assert invalid scan id +// * -> Type and assert valid scan id +// * -> Expand scan results +// * +// * @throws TimeoutException +// */ +// @Test +// public void testEnd2End() throws TimeoutException { +// // Set credentials, test connection and add checkmarx plugin +// setUpCheckmarxPlugin(false); - String firstNodeName = _bot.tree(1).cell(0, 0); - String secondNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).getText(); - String thirdNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).expand().getNode(0).getText(); +// String firstNodeName = _bot.tree(1).cell(0, 0); +// String secondNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).getText(); +// String thirdNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).expand().getNode(0).getText(); - // Expand nodes until the first vulnerability - _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).expandNode(thirdNodeName).getNode(0).select(); +// // Expand nodes until the first vulnerability +// _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).expandNode(thirdNodeName).getNode(0).select(); - // Close Checkmarx One Scan view - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// // Close Checkmarx One Scan view +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } - @Test - public void testFilterButtonsAndGroupByActionsInToolBar() throws TimeoutException { - // Test Connection - testSuccessfulConnection(false); +// @Test +// public void testFilterButtonsAndGroupByActionsInToolBar() throws TimeoutException { +// // Test Connection +// testSuccessfulConnection(false); - // Add Checkmarx One Plugin - addCheckmarxPlugin(true); +// // Add Checkmarx One Plugin +// addCheckmarxPlugin(true); - List toolbarButtons = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons(); - List toolBarButtonsNames = toolbarButtons.stream().map(btn -> btn.getToolTipText().toUpperCase()).collect(Collectors.toList()); - List filterActions = Arrays.asList(ActionName.HIGH.name(), ActionName.MEDIUM.name(), ActionName.LOW.name(), ActionName.INFO.name()); +// List toolbarButtons = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons(); +// List toolBarButtonsNames = toolbarButtons.stream().map(btn -> btn.getToolTipText().toUpperCase()).collect(Collectors.toList()); +// List filterActions = Arrays.asList(ActionName.HIGH.name(), ActionName.MEDIUM.name(), ActionName.LOW.name(), ActionName.INFO.name()); - // Assert all filter actions are present in the tool bar - assertTrue(ASSERT_FILTER_ACTIONS_IN_TOOLBAR, toolBarButtonsNames.containsAll(filterActions)); +// // Assert all filter actions are present in the tool bar +// assertTrue(ASSERT_FILTER_ACTIONS_IN_TOOLBAR, toolBarButtonsNames.containsAll(filterActions)); - List groupByActions = Arrays.asList(ToolBarActions.GROUP_BY_SEVERITY, ToolBarActions.GROUP_BY_QUERY_NAME); - List toolBarGroupByActions = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menuItems(); +// List groupByActions = Arrays.asList(ToolBarActions.GROUP_BY_SEVERITY, ToolBarActions.GROUP_BY_QUERY_NAME); +// List toolBarGroupByActions = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menuItems(); - // Assert all group by actions are present in the tool bar - assertTrue(ASSERT_GROUP_BY_ACTIONS_IN_TOOLBAR, toolBarGroupByActions.containsAll(groupByActions)); +// // Assert all group by actions are present in the tool bar +// assertTrue(ASSERT_GROUP_BY_ACTIONS_IN_TOOLBAR, toolBarGroupByActions.containsAll(groupByActions)); - // Close Checkmarx One Scan view - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// // Close Checkmarx One Scan view +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } - @Test - public void testFilteringAndGroupingResults() throws TimeoutException, ParseException { - // Set credentials, test connection and add checkmarx plugin - setUpCheckmarxPlugin(true); +// @Test +// public void testFilteringAndGroupingResults() throws TimeoutException, ParseException { +// // Set credentials, test connection and add checkmarx plugin +// setUpCheckmarxPlugin(true); - List filterStateButtons = Arrays.asList("Not Exploitable","Confirmed","Ignored","Not Ignored","To Verify"); - SWTBotToolbarDropDownButton stateFilter = _bot.toolbarDropDownButtonWithTooltip("State"); +// List filterStateButtons = Arrays.asList("Not Exploitable","Confirmed","Ignored","Not Ignored","To Verify"); +// SWTBotToolbarDropDownButton stateFilter = _bot.toolbarDropDownButtonWithTooltip("State"); - for(String filter: filterStateButtons) { - try { - final SWTBotMenu menuItem = stateFilter.menuItem(filter); +// for(String filter: filterStateButtons) { +// try { +// final SWTBotMenu menuItem = stateFilter.menuItem(filter); - if(!menuItem.isChecked()) { - menuItem.click(); - } - } catch(WidgetNotFoundException e) {} - } +// if(!menuItem.isChecked()) { +// menuItem.click(); +// } +// } catch(WidgetNotFoundException e) {} +// } - stateFilter.pressShortcut(KeyStroke.getInstance("ESC")); +// stateFilter.pressShortcut(KeyStroke.getInstance("ESC")); - ArrayList currentActiveFilters = new ArrayList<>(Arrays.asList(Severity.HIGH.name(), Severity.MEDIUM.name())); +// ArrayList currentActiveFilters = new ArrayList<>(Arrays.asList(Severity.HIGH.name(), Severity.MEDIUM.name())); - // Checks that tree contains High and Medium results - assertTrue(ASSERT_TREE_CONSTAIN_HIGH_MEDIUM, expandTreeUntilFirstEngineAndGetCurrentSeverities().containsAll(currentActiveFilters)); +// // Checks that tree contains High and Medium results +// assertTrue(ASSERT_TREE_CONSTAIN_HIGH_MEDIUM, expandTreeUntilFirstEngineAndGetCurrentSeverities().containsAll(currentActiveFilters)); - // Click to include Low severity - clickSeverityFilter(ActionName.LOW.name()); - currentActiveFilters.add(Severity.LOW.name()); +// // Click to include Low severity +// clickSeverityFilter(ActionName.LOW.name()); +// currentActiveFilters.add(Severity.LOW.name()); - // Checks that tree contains High, Medium and Low results - assertTrue(ASSERT_TREE_CONSTAIN_HIGH_MEDIUM_LOW, expandTreeUntilFirstEngineAndGetCurrentSeverities().containsAll(currentActiveFilters)); +// // Checks that tree contains High, Medium and Low results +// assertTrue(ASSERT_TREE_CONSTAIN_HIGH_MEDIUM_LOW, expandTreeUntilFirstEngineAndGetCurrentSeverities().containsAll(currentActiveFilters)); - // Click to include Info severity - clickSeverityFilter(ActionName.INFO.name()); - currentActiveFilters.add(Severity.INFO.name()); +// // Click to include Info severity +// clickSeverityFilter(ActionName.INFO.name()); +// currentActiveFilters.add(Severity.INFO.name()); - // Checks that tree contains High, Medium, Low and Info results - assertTrue(ASSERT_TREE_CONSTAIN_HIGH_MEDIUM_LOW_INFO, expandTreeUntilFirstEngineAndGetCurrentSeverities().containsAll(currentActiveFilters)); +// // Checks that tree contains High, Medium, Low and Info results +// assertTrue(ASSERT_TREE_CONSTAIN_HIGH_MEDIUM_LOW_INFO, expandTreeUntilFirstEngineAndGetCurrentSeverities().containsAll(currentActiveFilters)); - // Get all filter buttons individually - SWTBotToolbarButton filterHighBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(ActionName.HIGH.name())).findFirst().get(); - SWTBotToolbarButton filterMediumBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(ActionName.MEDIUM.name())).findFirst().get(); - SWTBotToolbarButton filterLowBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(ActionName.LOW.name())).findFirst().get(); - SWTBotToolbarButton filterInfoBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(ActionName.INFO.name())).findFirst().get(); +// // Get all filter buttons individually +// SWTBotToolbarButton filterHighBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(ActionName.HIGH.name())).findFirst().get(); +// SWTBotToolbarButton filterMediumBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(ActionName.MEDIUM.name())).findFirst().get(); +// SWTBotToolbarButton filterLowBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(ActionName.LOW.name())).findFirst().get(); +// SWTBotToolbarButton filterInfoBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(ActionName.INFO.name())).findFirst().get(); - // Click to remove all filters - filterHighBtn.click(); - filterMediumBtn.click(); - filterLowBtn.click(); - filterInfoBtn.click(); +// // Click to remove all filters +// filterHighBtn.click(); +// filterMediumBtn.click(); +// filterLowBtn.click(); +// filterInfoBtn.click(); - // Asserts that no issues are visible in the tree once we are grouping by Severity and no severity is selected - assertEquals(ASSERT_TREE_WITH_NO_ISSUES, _bot.tree(1).cell(0, 0), Environment.SCAN_ID + " (0 Issues)"); +// // Asserts that no issues are visible in the tree once we are grouping by Severity and no severity is selected +// assertEquals(ASSERT_TREE_WITH_NO_ISSUES, _bot.tree(1).cell(0, 0), Environment.SCAN_ID + " (0 Issues)"); - // Click to include High severity - clickSeverityFilter(ActionName.HIGH.name()); - currentActiveFilters.add(Severity.HIGH.name()); +// // Click to include High severity +// clickSeverityFilter(ActionName.HIGH.name()); +// currentActiveFilters.add(Severity.HIGH.name()); - sleep(1000); +// sleep(1000); - String firstNodeName = _bot.tree(1).cell(0, 0); - String secondNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).getText(); - String thirdNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).expand().getNode(0).getText(); +// String firstNodeName = _bot.tree(1).cell(0, 0); +// String secondNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).getText(); +// String thirdNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).expand().getNode(0).getText(); - // Expand nodes until the first vulnerability - String groupByQueryNameParent = _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).expandNode(thirdNodeName).getNode(0).expand().getNode(0).getText(); - String groupByQueryNameChild = _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).expandNode(thirdNodeName).getNode(0).expand().getNode(0).expand().getNode(0).getText(); +// // Expand nodes until the first vulnerability +// String groupByQueryNameParent = _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).expandNode(thirdNodeName).getNode(0).expand().getNode(0).getText(); +// String groupByQueryNameChild = _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).expandNode(thirdNodeName).getNode(0).expand().getNode(0).expand().getNode(0).getText(); - // Select the first vulnerability - _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).expandNode(thirdNodeName).getNode(0).expand().getNode(0).expand().getNode(0).select(); +// // Select the first vulnerability +// _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).expandNode(thirdNodeName).getNode(0).expand().getNode(0).expand().getNode(0).select(); - // Asserts that the vulnerability has the same name as the parent node which means it is grouped by query name - assertTrue(ASSERT_GROUP_BY_QUERY_NAME, groupByQueryNameChild.contains(groupByQueryNameParent.split("\\(")[0].trim())); +// // Asserts that the vulnerability has the same name as the parent node which means it is grouped by query name +// assertTrue(ASSERT_GROUP_BY_QUERY_NAME, groupByQueryNameChild.contains(groupByQueryNameParent.split("\\(")[0].trim())); - // Remove either group by severity and query name - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_QUERY_NAME).click(); - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_SEVERITY).click(); - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_STATE_NAME).click(); +// // Remove either group by severity and query name +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_QUERY_NAME).click(); +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_SEVERITY).click(); +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_STATE_NAME).click(); - sleep(1000); +// sleep(1000); - firstNodeName = _bot.tree(1).cell(0, 0); - secondNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).getText(); - _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName); +// firstNodeName = _bot.tree(1).cell(0, 0); +// secondNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).getText(); +// _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName); - // Get's the first engine child - String firstEngineChild = _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).getNode(0).getText(); - - // Checks if it starts by HIGH, MEDIUM, LOW or INFO - boolean engineChildDontStartWithHIGH = !firstEngineChild.startsWith(ActionName.HIGH.name()); - boolean engineChildDontStartWithMEDIUM = !firstEngineChild.startsWith(ActionName.MEDIUM.name()); - boolean engineChildDontStartWithLOW = !firstEngineChild.startsWith(ActionName.LOW.name()); - boolean engineChildDontStartWithINFO = !firstEngineChild.startsWith(ActionName.INFO.name()); - - // Asserts group by options are not enabled - assertTrue(ASSERT_NO_CHINDREN, _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).getNode(0).getNodes().isEmpty()); - assertTrue(ASSERT_GROUP_BY_SEVERITY_NOT_SELECTED, engineChildDontStartWithHIGH && engineChildDontStartWithMEDIUM && engineChildDontStartWithLOW && engineChildDontStartWithINFO); - - // re-enable group by and severity - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_QUERY_NAME).click(); - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_SEVERITY).click(); - - // Close Checkmarx One Scan view - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// // Get's the first engine child +// String firstEngineChild = _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).getNode(0).getText(); + +// // Checks if it starts by HIGH, MEDIUM, LOW or INFO +// boolean engineChildDontStartWithHIGH = !firstEngineChild.startsWith(ActionName.HIGH.name()); +// boolean engineChildDontStartWithMEDIUM = !firstEngineChild.startsWith(ActionName.MEDIUM.name()); +// boolean engineChildDontStartWithLOW = !firstEngineChild.startsWith(ActionName.LOW.name()); +// boolean engineChildDontStartWithINFO = !firstEngineChild.startsWith(ActionName.INFO.name()); + +// // Asserts group by options are not enabled +// assertTrue(ASSERT_NO_CHINDREN, _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).getNode(0).getNodes().isEmpty()); +// assertTrue(ASSERT_GROUP_BY_SEVERITY_NOT_SELECTED, engineChildDontStartWithHIGH && engineChildDontStartWithMEDIUM && engineChildDontStartWithLOW && engineChildDontStartWithINFO); + +// // re-enable group by and severity +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_QUERY_NAME).click(); +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_SEVERITY).click(); + +// // Close Checkmarx One Scan view +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } - @Test(expected = WidgetNotFoundException.class) - public void testInitialPanelWhenMissingCredentials() throws TimeoutException { - // Add Checkmarx plugin to the eclipse view - addCheckmarxPlugin(false); +// @Test(expected = WidgetNotFoundException.class) +// public void testInitialPanelWhenMissingCredentials() throws TimeoutException { +// // Add Checkmarx plugin to the eclipse view +// addCheckmarxPlugin(false); - // Assert that active view is the Checkmarx One Scan - assertTrue("Active view must be the Checkmarx One Scan", _bot.activeView().getTitle().equals(VIEW_CHECKMARX_AST_SCAN)); +// // Assert that active view is the Checkmarx One Scan +// assertTrue("Active view must be the Checkmarx One Scan", _bot.activeView().getTitle().equals(VIEW_CHECKMARX_AST_SCAN)); - assertTrue(ASSERT_CREDENTIALS_PANEL, _bot.button(PluginConstants.BTN_OPEN_SETTINGS) != null); +// assertTrue(ASSERT_CREDENTIALS_PANEL, _bot.button(PluginConstants.BTN_OPEN_SETTINGS) != null); - _bot.button(PluginConstants.BTN_OPEN_SETTINGS).click(); +// _bot.button(PluginConstants.BTN_OPEN_SETTINGS).click(); - testSuccessfulConnection(true); +// testSuccessfulConnection(true); - // Button Open Settings must not be present at this moment so we are expecting WidgetNotFoundException in this test - _bot.button(PluginConstants.BTN_OPEN_SETTINGS); - } +// // Button Open Settings must not be present at this moment so we are expecting WidgetNotFoundException in this test +// _bot.button(PluginConstants.BTN_OPEN_SETTINGS); +// } - /** - * Click on a severity filter - * - * @param actionName - */ - private void clickSeverityFilter(String actionName) { - SWTBotToolbarButton filterLowBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(actionName)).findFirst().get(); - filterLowBtn.click(); - } +// /** +// * Click on a severity filter +// * +// * @param actionName +// */ +// private void clickSeverityFilter(String actionName) { +// SWTBotToolbarButton filterLowBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(actionName)).findFirst().get(); +// filterLowBtn.click(); +// } - /** - * Expands the tree until the first engine and picks the list of available severities - * - * @return - */ - private List expandTreeUntilFirstEngineAndGetCurrentSeverities() { - String firstNodeName = _bot.tree(1).cell(0, 0); - String secondNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).getText(); - - _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName); - - return _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)).expand().getNode(0).getNodes().stream().map(node -> node.split("\\(")[0].trim()).collect(Collectors.toList()); - } +// /** +// * Expands the tree until the first engine and picks the list of available severities +// * +// * @return +// */ +// private List expandTreeUntilFirstEngineAndGetCurrentSeverities() { +// String firstNodeName = _bot.tree(1).cell(0, 0); +// String secondNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).getText(); + +// _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName); + +// return _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)).expand().getNode(0).getNodes().stream().map(node -> node.split("\\(")[0].trim()).collect(Collectors.toList()); +// } - /** - * Clear all Checkmarx credentials - */ - private void clearCheckmarxCredentials() { - if (!_cxSettingsDefined) { - return; - } - - preventWidgetWasNullInCIEnvironment(); +// /** +// * Clear all Checkmarx credentials +// */ +// private void clearCheckmarxCredentials() { +// if (!_cxSettingsDefined) { +// return; +// } + +// preventWidgetWasNullInCIEnvironment(); - _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); - _bot.shell(ITEM_PREFERENCES).activate(); - _bot.tree().select(ITEM_CHECKMARX_AST); +// _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); +// _bot.shell(ITEM_PREFERENCES).activate(); +// _bot.tree().select(ITEM_CHECKMARX_AST); - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(PluginConstants.EMPTY_STRING); +// _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(PluginConstants.EMPTY_STRING); - _bot.button(BTN_APPLY).click(); - _bot.button(BTN_APPLY_AND_CLOSE).click(); +// _bot.button(BTN_APPLY).click(); +// _bot.button(BTN_APPLY_AND_CLOSE).click(); - _cxSettingsDefined = false; - } -} +// _cxSettingsDefined = false; +// } +// } diff --git a/checkmarx-ast-eclipse-plugin/.project b/checkmarx-ast-eclipse-plugin/.project index 4671abdb..9ab7822d 100644 --- a/checkmarx-ast-eclipse-plugin/.project +++ b/checkmarx-ast-eclipse-plugin/.project @@ -31,4 +31,15 @@ org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + + + 1737534235229 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/com.checkmarx.eclipse.feature/.project b/com.checkmarx.eclipse.feature/.project index 81e01a64..cd934f0c 100644 --- a/com.checkmarx.eclipse.feature/.project +++ b/com.checkmarx.eclipse.feature/.project @@ -20,4 +20,15 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.pde.FeatureNature + + + 1737534235228 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/com.checkmarx.eclipse.site/.project b/com.checkmarx.eclipse.site/.project index 4beee618..b180d71e 100644 --- a/com.checkmarx.eclipse.site/.project +++ b/com.checkmarx.eclipse.site/.project @@ -20,4 +20,15 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.pde.UpdateSiteNature + + + 1737534235229 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + +