Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
989c55e
Resolved preferences page bugs
cx-aniket-shinde Mar 2, 2026
c5f1067
Unit tests for dataProvider and code coverage report
cx-aniket-shinde Mar 4, 2026
28172fd
Corrected ci.yml
cx-aniket-shinde Mar 4, 2026
d27834a
Jars updated
cx-aniket-shinde Mar 4, 2026
43c6868
Corrected ci.yml
cx-aniket-shinde Mar 4, 2026
fd6d322
Corrected ci.yml
cx-aniket-shinde Mar 4, 2026
4fc5d9d
pom corrected for results
cx-aniket-shinde Mar 4, 2026
5ee8379
Corrected ci.yml
cx-aniket-shinde Mar 4, 2026
ead1ef5
Corrected ci.yml
cx-aniket-shinde Mar 4, 2026
6806360
Corrected ci.yml
cx-aniket-shinde Mar 4, 2026
828e23c
changes for summary report
cx-aniket-shinde Mar 5, 2026
8526421
changes for summary report
cx-aniket-shinde Mar 5, 2026
0511f75
Checkmarx View ubnit tests
cx-aniket-shinde Mar 5, 2026
7e69add
ToolbarActionTest ubnit tests
cx-aniket-shinde Mar 5, 2026
464de76
Resolved UI test cases issue
cx-aniket-shinde Mar 5, 2026
d0a4526
Resolved UI test cases issue
cx-aniket-shinde Mar 5, 2026
6e414f8
Resolved UI test cases issue
cx-aniket-shinde Mar 5, 2026
ac1779c
Resolved empty scan Id and and result not loaded issue
cx-aniket-shinde Mar 5, 2026
d0f172e
Resolved UI test cases issue
cx-aniket-shinde Mar 5, 2026
15635a1
Resolved UI test cases issue
cx-aniket-shinde Mar 5, 2026
3749667
Resolved UI test cases issue
cx-aniket-shinde Mar 5, 2026
d1bded6
Resolved UI test cases issue
cx-aniket-shinde Mar 5, 2026
149d61a
Resolved UI test cases issue
cx-aniket-shinde Mar 5, 2026
675fb8d
Resolved UI test cases issue
cx-aniket-shinde Mar 5, 2026
db621c4
Resolved UI test cases issue
cx-aniket-shinde Mar 5, 2026
20af0a6
Resolved UI test cases issue
cx-aniket-shinde Mar 6, 2026
9105428
Resolved UI test cases issue
cx-aniket-shinde Mar 6, 2026
67b44c7
Authenticator Unit test cases
cx-aniket-shinde Mar 6, 2026
37a8e2d
Authenticator Unit test cases
cx-aniket-shinde Mar 6, 2026
779ee9a
Unit test cases for Plugin Utils
cx-aniket-shinde Mar 6, 2026
de35939
Unit test cases for Plugin Utils
cx-aniket-shinde Mar 6, 2026
1da05d5
Unit test cases for action filter state
cx-aniket-shinde Mar 6, 2026
b2588fe
Unit test cases for action filter state
cx-aniket-shinde Mar 6, 2026
18886c5
Unit test cases increase coverage
cx-aniket-shinde Mar 9, 2026
0452dea
Unit test cases for global settings
cx-aniket-shinde Mar 9, 2026
96c8dc4
Resolved latest scan id not appeard
cx-aniket-shinde Mar 11, 2026
a668901
Reseted the ci.yml changes for Push on branch
cx-aniket-shinde Mar 11, 2026
f2876ec
Jar jackson core changed to resolve scan vuln
cx-aniket-shinde Mar 11, 2026
0566fd1
Jar jackson core changed to resolve scan vuln
cx-aniket-shinde Mar 11, 2026
91b60b6
Jar jackson core changed to resolve scan vuln
cx-aniket-shinde Mar 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 64 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ on:
pull_request:
branches:
- main
push:
branches:
- codeMigration

jobs:

Expand Down Expand Up @@ -36,6 +33,11 @@ jobs:
run: |
Xvfb -ac :99 -screen 0 1920x1080x16 &
mvn verify -Dtest.includes="**/ui/*.java"
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: jacoco-coverage-report-ui
path: checkmarx-ast-eclipse-plugin-tests/target/site/jacoco-aggregate

integration-tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -64,5 +66,64 @@ jobs:
run: |
Xvfb -ac :99 -screen 0 1920x1080x16 &
mvn verify -Dtest.includes="**/integration/*Test.java"
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: jacoco-coverage-report-integration
path: checkmarx-ast-eclipse-plugin-tests/target/site/jacoco-aggregate
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.5.2
with:
lfs: true
- name: Checkout LFS objects
run: git lfs checkout
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: Run Unit Tests with Coverage
env:
CX_BASE_URI: ${{ secrets.CX_BASE_URI }}
CX_TENANT: ${{ secrets.CX_TENANT }}
CX_APIKEY: ${{ secrets.CX_APIKEY }}
CX_TEST_SCAN: ${{ secrets.CX_TEST_SCAN }}
DISPLAY: :99.0
run: |
Xvfb -ac :99 -screen 0 1920x1080x16 &
mvn clean verify -Dtest.includes="**/unit/**/*Test.java"
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: jacoco-coverage-report-unit
path: checkmarx-ast-eclipse-plugin-tests/target/site/jacoco-aggregate
- name: Generate JaCoCo Coverage Summary
run: |
REPORT="checkmarx-ast-eclipse-plugin-tests/target/site/jacoco-aggregate/jacoco.xml"

LINE_COVERED=$(grep 'type="LINE"' $REPORT | sed -E 's/.*covered="([0-9]+)".*/\1/')
LINE_MISSED=$(grep 'type="LINE"' $REPORT | sed -E 's/.*missed="([0-9]+)".*/\1/')

BRANCH_COVERED=$(grep 'type="BRANCH"' $REPORT | sed -E 's/.*covered="([0-9]+)".*/\1/')
BRANCH_MISSED=$(grep 'type="BRANCH"' $REPORT | sed -E 's/.*missed="([0-9]+)".*/\1/')

LINE_TOTAL=$((LINE_COVERED + LINE_MISSED))
BRANCH_TOTAL=$((BRANCH_COVERED + BRANCH_MISSED))

LINE_PERCENT=$(awk "BEGIN {printf \"%.2f\", ($LINE_COVERED/$LINE_TOTAL)*100}")
BRANCH_PERCENT=$(awk "BEGIN {printf \"%.2f\", ($BRANCH_COVERED/$BRANCH_TOTAL)*100}")

echo "## 🧪 Test Coverage Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Metric | Coverage |" >> $GITHUB_STEP_SUMMARY
echo "|------|------|" >> $GITHUB_STEP_SUMMARY
echo "| **Line Coverage** | ${LINE_PERCENT}% |" >> $GITHUB_STEP_SUMMARY
echo "| **Branch Coverage** | ${BRANCH_PERCENT}% |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

9 changes: 0 additions & 9 deletions checkmarx-ast-eclipse-plugin-tests/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,7 @@
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/mockito-core-5.14.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/objenesis-2.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/junit-jupiter-5.11.4.jar"/>
<classpathentry kind="lib" path="lib/objenesis-3.3.jar"/>
<classpathentry kind="lib" path="lib/powermock-api-mockito2-2.0.7.jar"/>
<classpathentry kind="lib" path="lib/powermock-core-2.0.9.jar"/>
<classpathentry kind="lib" path="lib/powermock-api-support-1.4.9.jar"/>
<classpathentry kind="lib" path="lib/powermock-module-junit4-2.0.9.jar"/>
<classpathentry kind="lib" path="lib/powermock-module-junit4-common-2.0.9.jar"/>
<classpathentry kind="lib" path="lib/powermock-module-junit4-rule-2.0.9.jar"/>
<classpathentry kind="lib" path="lib/powermock-reflect-2.0.9.jar"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
Expand Down
2 changes: 1 addition & 1 deletion checkmarx-ast-eclipse-plugin-tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ Require-Bundle:
org.eclipse.jdt.junit5.runtime,
junit-jupiter-api
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ClassPath: .,lib/mockito-core-5.14.2.jar,lib/powermock-core-*.jar
Bundle-ClassPath: .,lib/mockito-core-5.14.2.jar,lib/powermock-core-*.jar, lib/byte-buddy-1.17.8.jar, lib/byte-buddy-agent-1.17.8.jar
Automatic-Module-Name: com.checkmarx.ast.eclipse.tests
Binary file not shown.
Binary file not shown.
22 changes: 21 additions & 1 deletion checkmarx-ast-eclipse-plugin-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<test.includes>**/Test*.java,**/*Test.java,**/*Tests.java,**/*TestCase.java</test.includes>
<test.includes>
**/Test*.java,**/*Test.java,**/*Tests.java,**/*TestCase.java</test.includes>
</properties>
<groupId>com.checkmarx.ast.eclipse.tests</groupId>
<artifactId>com.checkmarx.ast.eclipse.tests</artifactId>
Expand All @@ -17,6 +18,23 @@
</parent>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>tycho.testArgLine</propertyName>
<destFile>${project.build.directory}/jacoco.exec</destFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
Expand All @@ -26,11 +44,13 @@
<useUIThread>false</useUIThread>
<providerHint>junit5</providerHint>
<failIfNoTests>true</failIfNoTests>
<argLine>${tycho.testArgLine}</argLine>
<includes>
<include>${test.includes}</include>
</includes>
</configuration>
</plugin>

</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swt.widgets.Decorations;
import org.eclipse.swt.widgets.Tree;

import com.checkmarx.eclipse.utils.PluginConstants;
Expand Down Expand Up @@ -302,18 +303,48 @@ protected static void waitUntilBranchComboIsEnabled() throws TimeoutException {
* Wait for connection response
*/
protected static void waitForConnectionResponse() throws TimeoutException {
int retryIdx = 0;
while (!_bot.text(3).getText().equals(INFO_SUCCESSFUL_CONNECTION)) {
if (retryIdx == 10) {
break;
}
_bot.sleep(1000);
retryIdx++;
}

if (retryIdx == 10) {
throw new TimeoutException("Connection validation timeout after 10000ms.");
}
int retryIdx = 0;
while (retryIdx < 10) {
boolean found = false;
int index = 0;
// Search text widgets
while (true) {
try {
String textValue = _bot.text(index).getText();
System.out.println("[waitForConnectionResponse] text[" + index + "]: '" + textValue + "'");
if (textValue.contains(INFO_SUCCESSFUL_CONNECTION)) {
found = true;
break;
}
index++;
} catch (Exception e) {
break;
}
}
// Search label widgets if not found
if (!found) {
index = 0;
while (true) {
try {
String labelValue = _bot.label(index).getText();
System.out.println("[waitForConnectionResponse] label[" + index + "]: '" + labelValue + "'");
if (labelValue.contains(INFO_SUCCESSFUL_CONNECTION)) {
found = true;
break;
}
index++;
} catch (Exception e) {
break;
}
}
}
if (found) {
return;
}
_bot.sleep(1000);
retryIdx++;
}
throw new TimeoutException("Connection validation timeout after 10000ms. See logs for widget contents.");
}

/**
Expand Down Expand Up @@ -381,4 +412,4 @@ protected SWTBotTree getResultsTree() {
return _bot.tree(0);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package checkmarx.ast.eclipse.plugin.tests.unit.runner;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

import java.io.IOException;

import org.junit.jupiter.api.Test;
import org.mockito.MockedConstruction;
import org.mockito.Mockito;
import org.slf4j.Logger;

import com.checkmarx.ast.wrapper.CxException;
import com.checkmarx.ast.wrapper.CxWrapper;
import com.checkmarx.eclipse.runner.Authenticator;
import com.checkmarx.eclipse.utils.PluginConstants;

class AuthenticatorTest {

@Test
void testDoAuthenticationSuccess() throws Exception {

Logger mockLogger = mock(Logger.class);

try (MockedConstruction<CxWrapper> mocked =
Mockito.mockConstruction(CxWrapper.class,
(mock, context) -> when(mock.authValidate()).thenReturn("SUCCESS"))) {

Authenticator authenticator = new Authenticator(mockLogger);

String result = authenticator.doAuthentication("dummyKey", "--param");

assertEquals("SUCCESS", result);
verify(mockLogger).info("Authentication Status: SUCCESS");
}
}

@Test
void testDoAuthenticationIOException() throws Exception {

Logger mockLogger = mock(Logger.class);

try (MockedConstruction<CxWrapper> mocked =
Mockito.mockConstruction(CxWrapper.class,
(mock, context) -> when(mock.authValidate())
.thenThrow(new IOException("IO error")))) {

Authenticator authenticator = new Authenticator(mockLogger);

String result = authenticator.doAuthentication("dummyKey", "--param");

assertEquals("IO error", result);
verify(mockLogger).error(
eq(String.format(PluginConstants.ERROR_AUTHENTICATING_AST, "IO error")),
any(IOException.class)
);
}
}

@Test
void testDoAuthenticationInterruptedException() throws Exception {

Logger mockLogger = mock(Logger.class);

try (MockedConstruction<CxWrapper> mocked =
Mockito.mockConstruction(CxWrapper.class,
(mock, context) -> when(mock.authValidate())
.thenThrow(new InterruptedException("Interrupted")))) {

Authenticator authenticator = new Authenticator(mockLogger);

String result = authenticator.doAuthentication("dummyKey", "--param");

assertEquals("Interrupted", result);
verify(mockLogger).error(
eq(String.format(PluginConstants.ERROR_AUTHENTICATING_AST, "Interrupted")),
any(InterruptedException.class)
);
}
}

@Test
void testDoAuthenticationCxException() throws Exception {

Logger mockLogger = mock(Logger.class);

try (MockedConstruction<CxWrapper> mocked =
Mockito.mockConstruction(CxWrapper.class,
(mock, context) -> when(mock.authValidate())
.thenThrow(new CxException(1, "Cx error")))) {

Authenticator authenticator = new Authenticator(mockLogger);

String result = authenticator.doAuthentication("dummyKey", "--param");

assertEquals("Cx error", result);
verify(mockLogger).error(
eq(String.format(PluginConstants.ERROR_AUTHENTICATING_AST, "Cx error")),
any(CxException.class)
);
}
}

@Test
void testSingletonInstanceNotNull() {
assertNotNull(Authenticator.INSTANCE);
}
}
Loading