@@ -150,6 +150,69 @@ func TestPredicateWithInvalidValues(t *testing.T) {
150150 assert .Assert (t , kicsPredicate .TotalCount == 0 , "Predicate with invalid values should have 0 as the result." )
151151}
152152
153+ func TestSastUpdateAndGetPredicatesForNotFoundSimilarityId (t * testing.T ) {
154+ scanID , projectID := getRootScan (t )
155+ _ = executeCmdNilAssertion (
156+ t , "Results show generating JSON report with options should pass" ,
157+ "results" , "show" ,
158+ flag (params .ScanIDFlag ), scanID , flag (params .TargetFormatFlag ), printer .FormatJSON ,
159+ flag (params .TargetPathFlag ), resultsDirectory ,
160+ flag (params .TargetFlag ), fileName ,
161+ )
162+
163+ defer func () {
164+ _ = os .RemoveAll (fmt .Sprintf (resultsDirectory ))
165+ }()
166+
167+ result := wrappers.ScanResultsCollection {}
168+
169+ _ , err := os .Stat (fmt .Sprintf ("%s%s.%s" , resultsDirectory , fileName , printer .FormatJSON ))
170+ assert .NilError (t , err , "Report file should exist for extension " + printer .FormatJSON )
171+
172+ file , err := os .ReadFile (fmt .Sprintf ("%s%s.%s" , resultsDirectory , fileName , printer .FormatJSON ))
173+ assert .NilError (t , err , "error reading file" )
174+
175+ err = json .Unmarshal (file , & result )
176+ assert .NilError (t , err , "error unmarshalling file" )
177+
178+ index := 0
179+ for i := range result .Results {
180+ if strings .EqualFold (result .Results [i ].Type , params .SastType ) {
181+ index = i
182+ break
183+ }
184+ }
185+
186+ similarityID := "1"
187+
188+ state := "CONFIRMED"
189+ if ! strings .EqualFold (result .Results [index ].State , "Urgent" ) {
190+ state = "URGENT"
191+ }
192+ severity := "HIGH"
193+ if ! strings .EqualFold (result .Results [index ].Severity , "Medium" ) {
194+ severity = "MEDIUM"
195+ }
196+ comment := "Testing CLI Command for triage."
197+ scanType := result .Results [index ].Type
198+
199+ args := []string {
200+ "triage" , "update" ,
201+ flag (params .ProjectIDFlag ), projectID ,
202+ flag (params .SimilarityIDFlag ), similarityID ,
203+ flag (params .StateFlag ), state ,
204+ flag (params .SeverityFlag ), severity ,
205+ flag (params .CommentFlag ), comment ,
206+ flag (params .ScanTypeFlag ), scanType ,
207+ }
208+
209+ err , outputBufferForStep1 := executeCommand (t , args ... )
210+ _ , readingError := io .ReadAll (outputBufferForStep1 )
211+ assert .NilError (t , readingError , "Reading result should pass" )
212+
213+ assert .ErrorContains (t , err , "Predicate not found" )
214+ }
215+
153216func TestTriageShowAndUpdateWithCustomStates (t * testing.T ) {
154217 t .Skip ("Skipping this test temporarily until the API becomes available in the DEU environment." )
155218 fmt .Println ("Step 1: Testing the command 'triage show' with predefined values." )
0 commit comments