diff --git a/chaoscenter/graphql/server/pkg/chaos_experiment_run/fuzz_tests/service_fuzz_test.go b/chaoscenter/graphql/server/pkg/chaos_experiment_run/fuzz_tests/service_fuzz_test.go index 5ae50c6ef7b..31ff3b9aa5f 100644 --- a/chaoscenter/graphql/server/pkg/chaos_experiment_run/fuzz_tests/service_fuzz_test.go +++ b/chaoscenter/graphql/server/pkg/chaos_experiment_run/fuzz_tests/service_fuzz_test.go @@ -12,7 +12,6 @@ import ( fuzz "github.com/AdaLogics/go-fuzz-headers" store "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/data-store" - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb" "github.com/stretchr/testify/mock" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" @@ -47,39 +46,6 @@ func NewMockServices() *MockServices { } } -func FuzzProcessExperimentRunDelete(f *testing.F) { - f.Fuzz(func(t *testing.T, data []byte) { - fuzzConsumer := fuzz.NewConsumer(data) - targetStruct := &struct { - Query bson.D - WorkflowRunID *string - ExperimentRun dbChaosExperimentRun.ChaosExperimentRun - Workflow dbChaosExperiment.ChaosExperimentRequest - Username string - StoreStateData *store.StateData - }{} - err := fuzzConsumer.GenerateStruct(targetStruct) - if err != nil { - return - } - mockServices := NewMockServices() - mockServices.MongodbOperator.On("Update", mock.Anything, mongodb.ChaosExperimentRunsCollection, mock.Anything, mock.Anything, mock.Anything).Return(&mongo.UpdateResult{}, nil).Once() - - err = mockServices.ChaosExperimentRunService.ProcessExperimentRunDelete( - context.Background(), - targetStruct.Query, - targetStruct.WorkflowRunID, - targetStruct.ExperimentRun, - targetStruct.Workflow, - targetStruct.Username, - targetStruct.StoreStateData, - ) - if err != nil { - t.Errorf("ProcessExperimentRunDelete() error = %v", err) - } - }) -} - func FuzzProcessExperimentRunStop(f *testing.F) { f.Fuzz(func(t *testing.T, data []byte) { fuzzConsumer := fuzz.NewConsumer(data) diff --git a/chaoscenter/graphql/server/pkg/chaoshub/handler/handler_fuzz_test.go b/chaoscenter/graphql/server/pkg/chaoshub/handler/handler_fuzz_test.go index 5a83fe5c04b..a505ad5a44c 100644 --- a/chaoscenter/graphql/server/pkg/chaoshub/handler/handler_fuzz_test.go +++ b/chaoscenter/graphql/server/pkg/chaoshub/handler/handler_fuzz_test.go @@ -41,51 +41,6 @@ func FuzzGetChartsPath(f *testing.F) { }) } -func FuzzReadExperimentFile(f *testing.F) { - f.Fuzz(func(t *testing.T, data []byte, filename string) { - fuzzConsumer := fuzz.NewConsumer(data) - - // Create a temporary directory - tmpDir, err := os.MkdirTemp("", "*-fuzztest") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(tmpDir) // clean up - - // Ensure the filename is valid and unique - safeFilename := filepath.Clean(filepath.Base(filename)) - if isInvalidFilename(safeFilename) { - safeFilename = "test.yaml" - } - filePath := filepath.Join(tmpDir, safeFilename) - content := ChaosChart{} - err = fuzzConsumer.GenerateStruct(&content) - if err != nil { - return - } - - jsonContent, _ := json.Marshal(content) - err = os.WriteFile(filePath, jsonContent, 0644) - if err != nil { - t.Fatal(err) - } - - _, err = ReadExperimentFile(filePath) - - if err != nil && !isInvalidYAML(jsonContent) { - t.Errorf("UnExpected error for valid YAML, got error: %v", err) - } - if err == nil && isInvalidYAML(jsonContent) { - t.Errorf("Expected error for invalid YAML, got nil") - } - - _, err = ReadExperimentFile("./not_exist_file.yaml") - if err == nil { - t.Errorf("Expected error for file does not exist, got nil") - } - }) -} - func FuzzGetExperimentData(f *testing.F) { f.Fuzz(func(t *testing.T, data []byte, filename string) { fuzzConsumer := fuzz.NewConsumer(data)