From 8c7225f5de066bd52a7520aa7b234794ae85fe1c Mon Sep 17 00:00:00 2001 From: elchananarb Date: Mon, 2 Dec 2024 10:59:19 +0200 Subject: [PATCH] update test --- .../cx-wrapper-tests/ASCATest.cs | 1 + .../CxWrapper/CxWrapper.cs | 33 +++++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/ast-visual-studio-extension-tests/cx-unit-tests/cx-wrapper-tests/ASCATest.cs b/ast-visual-studio-extension-tests/cx-unit-tests/cx-wrapper-tests/ASCATest.cs index d3212bb..18b11d5 100644 --- a/ast-visual-studio-extension-tests/cx-unit-tests/cx-wrapper-tests/ASCATest.cs +++ b/ast-visual-studio-extension-tests/cx-unit-tests/cx-wrapper-tests/ASCATest.cs @@ -20,6 +20,7 @@ public void TestInstallAsca() agent: CxConstants.EXTENSION_AGENT ); Assert.NotNull(result); + Assert.Contains("asca engine is running successfully", result.Message); } diff --git a/ast-visual-studio-extension/CxWrapper/CxWrapper.cs b/ast-visual-studio-extension/CxWrapper/CxWrapper.cs index 597e479..994210f 100644 --- a/ast-visual-studio-extension/CxWrapper/CxWrapper.cs +++ b/ast-visual-studio-extension/CxWrapper/CxWrapper.cs @@ -37,24 +37,37 @@ public CxAsca ScanAsca(string fileSource, bool ascaLatestVersion = false, string { logger.Info(string.Format(CxConstants.LOG_RUNNING_ASCA_SCAN_CMD, fileSource)); - List arguments = new List - { - CxConstants.CLI_SCAN_CMD, - CxConstants.CLI_ASCA_CMD, - CxConstants.FLAG_FILE_SOURCE, - fileSource - }; + List arguments; - if (ascaLatestVersion) + if (string.IsNullOrWhiteSpace(fileSource)) + { + arguments = new List + { + CxConstants.CLI_SCAN_CMD, + CxConstants.CLI_ASCA_CMD, + CxConstants.FLAG_ASCA_LATEST_VERSION + }; + } + else { - arguments.Add(CxConstants.FLAG_ASCA_LATEST_VERSION); + arguments = new List + { + CxConstants.CLI_SCAN_CMD, + CxConstants.CLI_ASCA_CMD, + CxConstants.FLAG_FILE_SOURCE, + fileSource + }; + + if (ascaLatestVersion) + { + arguments.Add(CxConstants.FLAG_ASCA_LATEST_VERSION); + } } AppendAgentToArguments(agent, arguments); string result = Execution.ExecuteCommand(WithConfigArguments(arguments), Execution.CheckValidJSONString); return JsonConvert.DeserializeObject(result); - } ///