-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI | Fix config retrieval logic (AST-76622) #957
base: main
Are you sure you want to change the base?
CLI | Fix config retrieval logic (AST-76622) #957
Conversation
Introduce a new integration test to verify handling of the resubmit flag during scan creation for non-existent projects, ensuring successful creation with default config. Additionally, fix the logic to retrieve configuration only when scans are available, preventing potential nil pointer dereferences.
No New Or Fixed Issues Found |
internal/commands/scan.go
Outdated
actualScanTypes = strings.Join(engines, ",") | ||
|
||
if len(allScansModel.Scans) > 0 { | ||
config = allScansModel.Scans[0].Metadata.Configs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allScansModel.Scans[0]
-> you can extract the value once and then use it.
@@ -1972,3 +1972,17 @@ func TestCreateAsyncScan_CallExportServiceBeforeScanFinishWithRetry_Success(t *t | |||
asserts.Nil(t, err) | |||
assert.Assert(t, exportRes != nil, "Export response should not be nil") | |||
} | |||
|
|||
func TestCreateScanWithResubmitFlag_ProjectNotExist_ScanCreatedSuccessfullyWithDefaultConfig(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we some how assert the config to check it is the default configs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can probably create unit test for this function that will check that the config that got returned is empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added unit test
Simplified the retrieval of config and engines by using a single variable, `scanModelResponse`, to improve code readability and maintainability. This change consolidates access to elements of `allScansModel.Scans[0]` into one clear reference point, making the code easier to understand and modify in the future.
Updated the ScansMockWrapper's Get method to return an empty configuration if the project ID is "non-existent-project". Added a test to ensure that the method behaves correctly in this scenario, verifying that an empty configuration is returned when attempting to resubmit a scan for a non-existent project.
Introduce a new integration test to verify handling of the resubmit flag during scan creation for non-existent projects, ensuring successful creation with default config. Additionally, fix the logic to retrieve configuration only when scans are available, preventing potential nil pointer dereferences.
By submitting a PR to this repository, you agree to the terms within the Checkmarx Code of Conduct. Please see the contributing guidelines for how to create and submit a high-quality PR for this repo.
Description
References
Testing
Checklist