Skip to content

Commit ffa79f7

Browse files
authored
More detailed error on test connection feature of plugin (#21)
1 parent b38a98c commit ffa79f7

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.checkmarx.ast.results;
2+
3+
4+
import lombok.Data;
5+
6+
@Data
7+
public class CxValidateOutput {
8+
private int exitCode;
9+
private String message;
10+
}

src/main/java/com/checkmarx/ast/scans/CxAuth.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.checkmarx.ast.exceptions.CxException;
44
import com.checkmarx.ast.executionservice.ExecutionService;
55
import com.checkmarx.ast.results.CxCommandOutput;
6+
import com.checkmarx.ast.results.CxValidateOutput;
67
import com.checkmarx.ast.results.structure.CxResultOutput;
78
import com.fasterxml.jackson.core.JsonParser;
89
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -346,14 +347,23 @@ public List<String> initialCommands() {
346347
return commands;
347348
}
348349

349-
public Integer cxAuthValidate() throws IOException, InterruptedException {
350+
public CxValidateOutput cxAuthValidate() throws IOException, InterruptedException {
350351
log.info("Initialize auth validate command");
351352
List<String> commands = initialCommandsCommon();
352353
commands.add("auth");
353354
commands.add("validate");
354355

355356
ExecutionService executionService = new ExecutionService();
356-
return executionService.executeCommandSync(commands);
357+
Process process = executionService.executeCommand(commands);
358+
359+
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
360+
process.waitFor();
361+
362+
CxValidateOutput cxValidateOutput = new CxValidateOutput();
363+
cxValidateOutput.setExitCode(process.exitValue());
364+
cxValidateOutput.setMessage(br.readLine());
365+
366+
return cxValidateOutput;
357367
}
358368

359369
public CxCommandOutput cxAstScanList() throws IOException, InterruptedException {

src/test/java/com/checkmarx/ast/CxAuthTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.checkmarx.ast;
22

33
import com.checkmarx.ast.results.CxCommandOutput;
4+
import com.checkmarx.ast.results.CxResultFormatType;
5+
import com.checkmarx.ast.results.CxValidateOutput;
46
import com.checkmarx.ast.results.structure.CxResultOutput;
57
import com.checkmarx.ast.scans.CxAuth;
68
import com.checkmarx.ast.scans.CxParamType;
@@ -72,8 +74,8 @@ public void cxScanShow() throws InterruptedException, IOException {
7274

7375
@Test
7476
public void cxAstAuthValidate() throws IOException, InterruptedException {
75-
Integer validate = auth.cxAuthValidate();
76-
assertEquals(VALID_RETURN_CODE, validate.intValue());
77+
CxValidateOutput validate = auth.cxAuthValidate();
78+
assertEquals(VALID_RETURN_CODE, validate.getExitCode());
7779
}
7880

7981
@Test

0 commit comments

Comments
 (0)