Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,4 @@ jobs:
- name: Inspect action report
if: always()
shell: bash
run: cat ./trivy-image-results.txt
run: cat ./trivy-image-results.txt
8 changes: 8 additions & 0 deletions test/integration/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,28 @@ const (

// Test validate with credentials used in test env
func TestAuthValidate(t *testing.T) {
t.Parallel()
err, buffer := executeCommand(t, "auth", "validate")
assertSuccessAuthentication(t, err, buffer, defaultSuccessValidationMessage)
}

func TestAuthValidateClientAndSecret(t *testing.T) {
t.Parallel()
err, buffer := executeCommand(t, "auth", "validate", "--debug", "--apikey", "")
assertSuccessAuthentication(t, err, buffer, defaultSuccessValidationMessage)
}

// Test validate with credentials from flags
func TestAuthValidateMissingFlagsTogether(t *testing.T) {
t.Parallel()
// set base-uri to empty string so that it does not pick up the value from the environment
err, _ := executeCommand(t, "auth", "validate", "--client-id", "fake-client-id", "--client-secret", "fake-client-secret", "--base-uri", "", "--base-auth-uri", "", "--apikey", "")
assertError(t, err, wrappers.MissingURI)
}

// Test validate with credentials from flags
func TestAuthValidateEmptyFlags(t *testing.T) {
t.Parallel()
err, _ := executeCommand(t, "auth", "validate", "--apikey", "", "--client-id", "")
assertError(t, err, commands.FailedAuthError)

Expand Down Expand Up @@ -104,13 +108,15 @@ func TestAuthValidateWithEmptyAuthenticationPath(t *testing.T) {
}

func TestAuthValidateOnlyAPIKey(t *testing.T) {
t.Parallel()
validateCommand, buffer := createRedirectedTestCommand(t)
err := execute(validateCommand, "auth", "validate", "--base-uri", "", "--client-id", "", "--client-secret", "")
assertSuccessAuthentication(t, err, buffer, "")
}

// Register with empty username, password or role
func TestAuthRegisterWithEmptyParameters(t *testing.T) {
t.Parallel()
assertRequiredParameter(
t, "Please provide username flag",
"auth", "register",
Expand Down Expand Up @@ -138,6 +144,7 @@ func TestAuthRegisterWithEmptyParameters(t *testing.T) {

// Register with credentials and validate the obtained id/secret pair
func TestAuthRegister(t *testing.T) {
t.Parallel()
registerCommand, _ := createRedirectedTestCommand(t)

_ = execute(
Expand All @@ -153,6 +160,7 @@ func TestAuthRegister(t *testing.T) {
}

func TestFailProxyAuth(t *testing.T) {
t.Parallel()
proxyUser := viper.GetString(ProxyUserEnv)
proxyPort := viper.GetInt(ProxyPortEnv)
proxyHost := viper.GetString(ProxyHostEnv)
Expand Down
1 change: 1 addition & 0 deletions test/integration/bfl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func TestRunGetBflByScanIdAndQueryId(t *testing.T) {
}

func TestRunGetBflWithInvalidScanIDandQueryID(t *testing.T) {
t.Parallel()

err, _ := executeCommand(
t, "results", "bfl",
Expand Down
3 changes: 3 additions & 0 deletions test/integration/chat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
)

func TestChatKicsInvalidAPIKey(t *testing.T) {
t.Parallel()
args := []string{
"chat", "kics",
"--conversation-id", uuid.New().String(),
Expand All @@ -37,6 +38,7 @@ func TestChatKicsInvalidAPIKey(t *testing.T) {
}

func TestChatSastInvalidAPIKey(t *testing.T) {
t.Parallel()
args := []string{
"chat", "sast",
"--chat-apikey", "invalidApiKey",
Expand All @@ -52,6 +54,7 @@ func TestChatSastInvalidAPIKey(t *testing.T) {
}

func TestChatKicsAzureAIInvalidAPIKey(t *testing.T) {
t.Parallel()
t.Skip("Skipping this test since not all services are deployed to production yet")
createASTIntegrationTestCommand(t)
mockConfig := []*wrappers.TenantConfigurationResponse{
Expand Down
6 changes: 6 additions & 0 deletions test/integration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
const filePath = "data/config.yaml"

func TestLoadConfiguration_EnvVarConfigFilePath(t *testing.T) {
t.Parallel()
os.Setenv("CX_CONFIG_FILE_PATH", filePath)
defer os.Unsetenv("CX_CONFIG_FILE_PATH")

Expand All @@ -24,6 +25,7 @@ func TestLoadConfiguration_EnvVarConfigFilePath(t *testing.T) {
}

func TestLoadConfiguration_FileNotFound(t *testing.T) {
t.Parallel()
os.Setenv("CX_CONFIG_FILE_PATH", "data/nonexistent_config.yaml")
defer os.Unsetenv("CX_CONFIG_FILE_PATH")

Expand All @@ -33,6 +35,7 @@ func TestLoadConfiguration_FileNotFound(t *testing.T) {
assert.ErrorContains(t, err, "The specified file does not exist")
}
func TestLoadConfiguration_ValidDirectory(t *testing.T) {
t.Parallel()
validDirPath := "data"
os.Setenv("CX_CONFIG_FILE_PATH", validDirPath)
defer os.Unsetenv("CX_CONFIG_FILE_PATH")
Expand Down Expand Up @@ -76,16 +79,19 @@ func TestSetConfigProperty_EnvVarConfigFilePath(t *testing.T) {
}

func TestLoadConfiguration_ConfigFilePathFlag(t *testing.T) {
t.Parallel()
err, _ := executeCommand(t, "configure", "show", "--config-file-path", filePath)
assert.NilError(t, err)
}

func TestLoadConfiguration_ConfigFilePathFlagValidDirectory(t *testing.T) {
t.Parallel()
err, _ := executeCommand(t, "configure", "show", "--config-file-path", "data")
assert.ErrorContains(t, err, "The specified path points to a directory, not a file.")
}

func TestLoadConfiguration_ConfigFilePathFlagFileNotFound(t *testing.T) {
t.Parallel()
err, _ := executeCommand(t, "configure", "show", "--config-file-path", "data/nonexistent_config.yaml")
assert.ErrorContains(t, err, "The specified file does not exist.")
}
Expand Down
7 changes: 7 additions & 0 deletions test/integration/container_empty_folder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

// TestContainerScan_EmptyFolderWithExternalImages tests scanning with empty folders and external container images
func TestContainerScan_EmptyFolderWithExternalImages(t *testing.T) {
t.Parallel()
createASTIntegrationTestCommand(t)
testArgs := []string{
"scan", "create",
Expand All @@ -29,6 +30,7 @@ func TestContainerScan_EmptyFolderWithExternalImages(t *testing.T) {

// TestContainerScan_EmptyFolderWithMultipleExternalImages tests scanning empty folder with multiple external images
func TestContainerScan_EmptyFolderWithMultipleExternalImages(t *testing.T) {
t.Parallel()
createASTIntegrationTestCommand(t)
testArgs := []string{
"scan", "create",
Expand All @@ -46,6 +48,7 @@ func TestContainerScan_EmptyFolderWithMultipleExternalImages(t *testing.T) {

// TestContainerScan_EmptyFolderWithExternalImagesAndDebug tests with debug flag enabled
func TestContainerScan_EmptyFolderWithExternalImagesAndDebug(t *testing.T) {
t.Parallel()
createASTIntegrationTestCommand(t)
testArgs := []string{
"scan", "create",
Expand All @@ -64,6 +67,7 @@ func TestContainerScan_EmptyFolderWithExternalImagesAndDebug(t *testing.T) {

// TestContainerScan_EmptyFolderWithComplexImageNames tests empty folder with complex image names
func TestContainerScan_EmptyFolderWithComplexImageNames(t *testing.T) {
t.Parallel()
createASTIntegrationTestCommand(t)
testArgs := []string{
"scan", "create",
Expand All @@ -81,6 +85,7 @@ func TestContainerScan_EmptyFolderWithComplexImageNames(t *testing.T) {

// TestContainerScan_EmptyFolderWithRegistryImages tests empty folder with registry-prefixed images
func TestContainerScan_EmptyFolderWithRegistryImages(t *testing.T) {
t.Parallel()
createASTIntegrationTestCommand(t)
testArgs := []string{
"scan", "create",
Expand All @@ -98,6 +103,7 @@ func TestContainerScan_EmptyFolderWithRegistryImages(t *testing.T) {

// TestContainerScan_EmptyFolderInvalidImageShouldFail tests that validation still works with empty folders
func TestContainerScan_EmptyFolderInvalidImageShouldFail(t *testing.T) {
t.Parallel()
createASTIntegrationTestCommand(t)
testArgs := []string{
"scan", "create",
Expand All @@ -115,6 +121,7 @@ func TestContainerScan_EmptyFolderInvalidImageShouldFail(t *testing.T) {

// TestContainerScan_EmptyFolderMixedValidInvalidImages tests mixed valid/invalid images with empty folder
func TestContainerScan_EmptyFolderMixedValidInvalidImages(t *testing.T) {
t.Parallel()
createASTIntegrationTestCommand(t)
testArgs := []string{
"scan", "create",
Expand Down
5 changes: 5 additions & 0 deletions test/integration/container_images_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

// TestContainerImageValidation_ValidFormats tests that valid container image formats are accepted
func TestContainerImageValidation_ValidFormats(t *testing.T) {
t.Parallel()
tests := []struct {
name string
imageFormat string
Expand Down Expand Up @@ -68,6 +69,7 @@ func TestContainerImageValidation_ValidFormats(t *testing.T) {

// TestContainerImageValidation_InvalidFormats tests that invalid container image formats are rejected
func TestContainerImageValidation_InvalidFormats(t *testing.T) {
t.Parallel()
tests := []struct {
name string
imageFormat string
Expand Down Expand Up @@ -123,6 +125,7 @@ func TestContainerImageValidation_InvalidFormats(t *testing.T) {

// TestContainerImageValidation_MultipleImagesValidation tests validation with multiple container images
func TestContainerImageValidation_MultipleImagesValidation(t *testing.T) {
t.Parallel()
tests := []struct {
name string
imageList string
Expand Down Expand Up @@ -182,6 +185,7 @@ func TestContainerImageValidation_MultipleImagesValidation(t *testing.T) {

// TestContainerImageValidation_TarFiles tests validation of .tar file references
func TestContainerImageValidation_TarFiles(t *testing.T) {
t.Parallel()
// Create a temporary .tar file for testing
tempDir := t.TempDir()
emptyTarFile := filepath.Join(tempDir, "test-image.tar")
Expand Down Expand Up @@ -239,6 +243,7 @@ func TestContainerImageValidation_TarFiles(t *testing.T) {

// TestContainerImageValidation_MixedTarAndRegularImages tests mixing .tar files with regular images
func TestContainerImageValidation_MixedTarAndRegularImages(t *testing.T) {
t.Parallel()
// Create a temporary .tar file for testing
// Note: An empty tar file is NOT a valid container image
tempDir := t.TempDir()
Expand Down
6 changes: 6 additions & 0 deletions test/integration/container_scan_edge_cases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

// TestContainerScan_ErrorHandling_InvalidAndValidScenarios tests error handling improvements
func TestContainerScan_ErrorHandling_InvalidAndValidScenarios(t *testing.T) {
t.Parallel()
t.Run("ValidScanWithAllParameters", func(t *testing.T) {
createASTIntegrationTestCommand(t)
testArgs := []string{
Expand Down Expand Up @@ -47,6 +48,7 @@ func TestContainerScan_ErrorHandling_InvalidAndValidScenarios(t *testing.T) {

// TestContainerScan_TarFileValidation tests .tar file validation scenarios
func TestContainerScan_TarFileValidation(t *testing.T) {
t.Parallel()
tempDir := t.TempDir()

t.Run("EmptyTarFile", func(t *testing.T) {
Expand Down Expand Up @@ -112,6 +114,7 @@ func TestContainerScan_TarFileValidation(t *testing.T) {

// TestContainerScan_SpecialCharactersInImageNames tests handling of special characters
func TestContainerScan_SpecialCharactersInImageNames(t *testing.T) {
t.Parallel()
tests := []struct {
name string
imageName string
Expand Down Expand Up @@ -177,6 +180,7 @@ func TestContainerScan_SpecialCharactersInImageNames(t *testing.T) {

// TestContainerScan_ImageTagVariations tests different tag formats
func TestContainerScan_ImageTagVariations(t *testing.T) {
t.Parallel()
tests := []struct {
name string
imageName string
Expand Down Expand Up @@ -254,6 +258,7 @@ func TestContainerScan_ImageTagVariations(t *testing.T) {

// TestContainerScan_BoundaryConditions tests boundary conditions
func TestContainerScan_BoundaryConditions(t *testing.T) {
t.Parallel()
t.Run("SingleCharacterImageName", func(t *testing.T) {
createASTIntegrationTestCommand(t)
testArgs := []string{
Expand Down Expand Up @@ -308,6 +313,7 @@ func TestContainerScan_BoundaryConditions(t *testing.T) {

// TestContainerScan_CombinedWithOtherScanTypes tests container scans combined with other scan types
func TestContainerScan_CombinedWithOtherScanTypes(t *testing.T) {
t.Parallel()
t.Run("ContainerAndIaC", func(t *testing.T) {
createASTIntegrationTestCommand(t)
testArgs := []string{
Expand Down
2 changes: 2 additions & 0 deletions test/integration/containers-realtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

func TestContainersRealtimeScan_PositiveDockerfile_Success(t *testing.T) {
t.Parallel()
t.Skip("Skipping this test till the RT api for containers will deploy to DEU ENV")
configuration.LoadConfiguration()
args := []string{
Expand All @@ -38,6 +39,7 @@ func TestContainersRealtimeScan_PositiveDockerfile_Success(t *testing.T) {
}

func TestContainersRealtimeScan_EmptyDockerfile_SuccessWithEmptyResponse(t *testing.T) {
t.Parallel()
configuration.LoadConfiguration()
args := []string{
"scan", "containers-realtime",
Expand Down
1 change: 1 addition & 0 deletions test/integration/feature-flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type MockFeatureFlagsWrapper struct {
}

func Test_HandleFeatureFlags_WhenCalled_ThenNoErrorAndCacheNotEmpty(t *testing.T) {
t.Parallel()
createASTIntegrationTestCommand(t)
featureFlagsPath := viper.GetString(commonParams.FeatureFlagsKey)
featureFlagsWrapper := wrappers.NewFeatureFlagsHTTPWrapper(featureFlagsPath)
Expand Down
9 changes: 9 additions & 0 deletions test/integration/iac-realtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func safeRemoveFile(path string) {
}

func TestIacRealtimeScan_TerraformFile_Success(t *testing.T) {
t.Parallel()
configuration.LoadConfiguration()

args := []string{
Expand Down Expand Up @@ -61,6 +62,7 @@ func TestIacRealtimeScan_TerraformFile_Success(t *testing.T) {
}

func TestIacRealtimeScan_DockerFile_Success(t *testing.T) {
t.Parallel()
configuration.LoadConfiguration()

args := []string{
Expand Down Expand Up @@ -94,6 +96,7 @@ func TestIacRealtimeScan_DockerFile_Success(t *testing.T) {
}

func TestIacRealtimeScan_YamlConfigFile_Success(t *testing.T) {
t.Parallel()
configuration.LoadConfiguration()

args := []string{
Expand All @@ -116,6 +119,7 @@ func TestIacRealtimeScan_YamlConfigFile_Success(t *testing.T) {
}

func TestIacRealtimeScan_EmptyDockerFile_Success(t *testing.T) {
t.Parallel()
configuration.LoadConfiguration()

args := []string{
Expand All @@ -137,6 +141,7 @@ func TestIacRealtimeScan_EmptyDockerFile_Success(t *testing.T) {
}

func TestIacRealtimeScan_NonExistentFile_ShouldFail(t *testing.T) {
t.Parallel()
configuration.LoadConfiguration()

args := []string{
Expand All @@ -151,6 +156,7 @@ func TestIacRealtimeScan_NonExistentFile_ShouldFail(t *testing.T) {
}

func TestIacRealtimeScan_UnsupportedFileExtension_ShouldFail(t *testing.T) {
t.Parallel()
configuration.LoadConfiguration()

// Create a temporary file with unsupported extension
Expand All @@ -174,6 +180,7 @@ func TestIacRealtimeScan_UnsupportedFileExtension_ShouldFail(t *testing.T) {
}

func TestIacRealtimeScan_MissingSourceFlag_ShouldFail(t *testing.T) {
t.Parallel()
configuration.LoadConfiguration()

args := []string{
Expand All @@ -187,6 +194,7 @@ func TestIacRealtimeScan_MissingSourceFlag_ShouldFail(t *testing.T) {
}

func TestIacRealtimeScan_WithIgnoredFilePath_Success(t *testing.T) {
t.Parallel()
configuration.LoadConfiguration()

// Create a temporary ignored file
Expand Down Expand Up @@ -217,6 +225,7 @@ func TestIacRealtimeScan_WithIgnoredFilePath_Success(t *testing.T) {
}

func TestIacRealtimeScan_ResultsValidation_DetailedCheck(t *testing.T) {
t.Parallel()
configuration.LoadConfiguration()

args := []string{
Expand Down
Loading
Loading