@@ -692,3 +692,36 @@ func TestRiskManagementResults_ReturnResults(t *testing.T) {
692692
693693 assert .Assert (t , (len (result .Results ) <= 20 ), "Should have results" )
694694}
695+
696+ func TestResultsIncludePublishedAtJsonOutput (t * testing.T ) {
697+ scanID , _ := getRootScan (t )
698+ _ = executeCmdNilAssertion (
699+ t , "Results show generating JSON report with options should pass" ,
700+ "results" , "show" ,
701+ flag (params .ScanIDFlag ), scanID ,
702+ flag (params .TargetFormatFlag ), printer .FormatJSON ,
703+ flag (params .TargetPathFlag ), resultsDirectory ,
704+ flag (params .TargetFlag ), fileName ,
705+ )
706+
707+ defer func () {
708+ _ = os .RemoveAll (fmt .Sprintf (resultsDirectory ))
709+ }()
710+
711+ result := wrappers.ScanResultsCollection {}
712+
713+ _ , err := os .Stat (fmt .Sprintf ("%s%s.%s" , resultsDirectory , fileName , printer .FormatJSON ))
714+ assert .NilError (t , err , "Report file should exist for extension " + printer .FormatJSON )
715+
716+ file , err := os .ReadFile (fmt .Sprintf ("%s%s.%s" , resultsDirectory , fileName , printer .FormatJSON ))
717+ assert .NilError (t , err , "error reading file" )
718+
719+ err = json .Unmarshal (file , & result )
720+ assert .NilError (t , err , "error unmarshalling file" )
721+
722+ for _ , res := range result .Results {
723+ if res .Type == "sca" {
724+ assert .Assert (t , res .ScanResultData .PublishedAt != "" , "PublishedAt should not be empty for SCA results" )
725+ }
726+ }
727+ }
0 commit comments