From 8d272d641e6879fe53fcba2568fb1489a92002be Mon Sep 17 00:00:00 2001 From: Aniket Shinde Date: Tue, 14 Apr 2026 12:38:35 +0530 Subject: [PATCH 1/2] Fix AST-136023: Route authentication logs to Eclipse Error Log Replace SLF4J log calls in Authenticator.doAuthentication() with CxLogger so auth success/failure messages appear in .metadata/.log and the Eclipse Error Log UI instead of being silently dropped. Co-Authored-By: Claude Sonnet 4.6 (1M context) --- .../src/com/checkmarx/eclipse/runner/Authenticator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/checkmarx-ast-eclipse-plugin/src/com/checkmarx/eclipse/runner/Authenticator.java b/checkmarx-ast-eclipse-plugin/src/com/checkmarx/eclipse/runner/Authenticator.java index 9484950e..bea96e2f 100644 --- a/checkmarx-ast-eclipse-plugin/src/com/checkmarx/eclipse/runner/Authenticator.java +++ b/checkmarx-ast-eclipse-plugin/src/com/checkmarx/eclipse/runner/Authenticator.java @@ -33,10 +33,10 @@ public String doAuthentication(String apiKey, String additionalParams) { try { CxWrapper wrapper = new CxWrapper(config, log); String cxValidateOutput = wrapper.authValidate(); - log.info(AUTH_STATUS + cxValidateOutput); + CxLogger.info(AUTH_STATUS + cxValidateOutput); return cxValidateOutput; } catch (IOException | InterruptedException | CxException e) { - log.error(String.format(PluginConstants.ERROR_AUTHENTICATING_AST, e.getMessage()), e); + CxLogger.error(String.format(PluginConstants.ERROR_AUTHENTICATING_AST, e.getMessage()), e); return e.getMessage(); } } From 05e631a74fcb2f56772d13ead009f2ba0840a3d4 Mon Sep 17 00:00:00 2001 From: Aniket Shinde Date: Tue, 14 Apr 2026 12:49:33 +0530 Subject: [PATCH 2/2] Fix AST-136023: Update unit tests to verify CxLogger static calls Replace SLF4J mockLogger verification with MockedStatic to match the updated Authenticator.doAuthentication() which now routes log output through CxLogger instead of the SLF4J instance. Co-Authored-By: Claude Sonnet 4.6 (1M context) --- .../tests/unit/runner/AuthenticatorTest.java | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/unit/runner/AuthenticatorTest.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/unit/runner/AuthenticatorTest.java index 740e12a6..576b3d50 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/unit/runner/AuthenticatorTest.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/unit/runner/AuthenticatorTest.java @@ -7,12 +7,14 @@ import org.junit.jupiter.api.Test; import org.mockito.MockedConstruction; +import org.mockito.MockedStatic; 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.CxLogger; import com.checkmarx.eclipse.utils.PluginConstants; class AuthenticatorTest { @@ -24,14 +26,15 @@ void testDoAuthenticationSuccess() throws Exception { try (MockedConstruction mocked = Mockito.mockConstruction(CxWrapper.class, - (mock, context) -> when(mock.authValidate()).thenReturn("SUCCESS"))) { + (mock, context) -> when(mock.authValidate()).thenReturn("SUCCESS")); + MockedStatic mockedCxLogger = Mockito.mockStatic(CxLogger.class)) { Authenticator authenticator = new Authenticator(mockLogger); String result = authenticator.doAuthentication("dummyKey", "--param"); assertEquals("SUCCESS", result); - verify(mockLogger).info("Authentication Status: SUCCESS"); + mockedCxLogger.verify(() -> CxLogger.info("Authentication Status: SUCCESS")); } } @@ -43,17 +46,18 @@ void testDoAuthenticationIOException() throws Exception { try (MockedConstruction mocked = Mockito.mockConstruction(CxWrapper.class, (mock, context) -> when(mock.authValidate()) - .thenThrow(new IOException("IO error")))) { + .thenThrow(new IOException("IO error"))); + MockedStatic mockedCxLogger = Mockito.mockStatic(CxLogger.class)) { 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) - ); + mockedCxLogger.verify(() -> CxLogger.error( + eq(String.format(PluginConstants.ERROR_AUTHENTICATING_AST, "IO error")), + any(IOException.class) + )); } } @@ -65,17 +69,18 @@ void testDoAuthenticationInterruptedException() throws Exception { try (MockedConstruction mocked = Mockito.mockConstruction(CxWrapper.class, (mock, context) -> when(mock.authValidate()) - .thenThrow(new InterruptedException("Interrupted")))) { + .thenThrow(new InterruptedException("Interrupted"))); + MockedStatic mockedCxLogger = Mockito.mockStatic(CxLogger.class)) { 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) - ); + mockedCxLogger.verify(() -> CxLogger.error( + eq(String.format(PluginConstants.ERROR_AUTHENTICATING_AST, "Interrupted")), + any(InterruptedException.class) + )); } } @@ -87,17 +92,18 @@ void testDoAuthenticationCxException() throws Exception { try (MockedConstruction mocked = Mockito.mockConstruction(CxWrapper.class, (mock, context) -> when(mock.authValidate()) - .thenThrow(new CxException(1, "Cx error")))) { + .thenThrow(new CxException(1, "Cx error"))); + MockedStatic mockedCxLogger = Mockito.mockStatic(CxLogger.class)) { 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) - ); + mockedCxLogger.verify(() -> CxLogger.error( + eq(String.format(PluginConstants.ERROR_AUTHENTICATING_AST, "Cx error")), + any(CxException.class) + )); } }