@@ -142,7 +142,7 @@ func TestEvaluationLogToOSCALAssessmentResults_AssessmentLogEntries(t *testing.T
142142 assert .Contains (t , result .AssessmentLog .Entries [1 ].Title , "REQ-2" )
143143}
144144
145- func TestEvaluationLogToOSCALAssessmentResults_TargetComponent (t * testing.T ) {
145+ func TestEvaluationLogToOSCALAssessmentResults_TargetInventoryItem (t * testing.T ) {
146146 log := makeEvaluationLog (gemara.Actor {Name : "tool" , Type : gemara .Software }, []* gemara.AssessmentLog {
147147 makeAssessmentLog ("REQ-1" , "check" , gemara .Passed , "" , nil ),
148148 })
@@ -153,12 +153,15 @@ func TestEvaluationLogToOSCALAssessmentResults_TargetComponent(t *testing.T) {
153153
154154 result := ar .Results [0 ]
155155 require .NotNil (t , result .LocalDefinitions )
156- require .NotNil (t , result .LocalDefinitions .Components )
157- require .Len (t , * result .LocalDefinitions .Components , 1 )
158-
159- comp := (* result .LocalDefinitions .Components )[0 ]
160- assert .Equal (t , "Production System" , comp .Title )
161- assert .Equal (t , "The prod system" , comp .Description )
156+ require .NotNil (t , result .LocalDefinitions .InventoryItems )
157+ require .Len (t , * result .LocalDefinitions .InventoryItems , 1 )
158+
159+ item := (* result .LocalDefinitions .InventoryItems )[0 ]
160+ assert .Equal (t , "The prod system" , item .Description )
161+ require .NotNil (t , item .Props )
162+ props := * item .Props
163+ assert .Equal (t , "my-sys" , props [0 ].Value )
164+ assert .Equal (t , "Production System" , props [1 ].Value )
162165}
163166
164167func TestEvaluationLogConverter_ToOSCALAssessmentResults (t * testing.T ) {
@@ -173,6 +176,43 @@ func TestEvaluationLogConverter_ToOSCALAssessmentResults(t *testing.T) {
173176 assert .Contains (t , ar .Results [0 ].Title , "eval-converter" )
174177}
175178
179+ func TestEvaluationLogToOSCALAssessmentResults_BackMatter (t * testing.T ) {
180+ log := makeEvaluationLog (gemara.Actor {Name : "tool" , Type : gemara .Software }, []* gemara.AssessmentLog {
181+ makeAssessmentLog ("REQ-1" , "check" , gemara .Passed , "" , nil ),
182+ })
183+ log .Metadata .MappingReferences = []gemara.MappingReference {
184+ {
185+ Id : "CNSC" ,
186+ Title : "Cloud Native Security Controls" ,
187+ Version : "1.0.0" ,
188+ Description : "CNCF security controls catalog" ,
189+ Url : "https://example.com/cnsc" ,
190+ },
191+ }
192+
193+ ar , err := EvaluationLogToOSCALAssessmentResults (log )
194+ require .NoError (t , err )
195+
196+ require .NotNil (t , ar .BackMatter )
197+ require .NotNil (t , ar .BackMatter .Resources )
198+ require .Len (t , * ar .BackMatter .Resources , 1 )
199+
200+ resource := (* ar .BackMatter .Resources )[0 ]
201+ assert .Equal (t , "Cloud Native Security Controls" , resource .Title )
202+ assert .NotEmpty (t , resource .UUID )
203+ assertValidJSON (t , ar )
204+ }
205+
206+ func TestEvaluationLogToOSCALAssessmentResults_NoBackMatterWhenEmpty (t * testing.T ) {
207+ log := makeEvaluationLog (gemara.Actor {Name : "tool" , Type : gemara .Software }, []* gemara.AssessmentLog {
208+ makeAssessmentLog ("REQ-1" , "check" , gemara .Passed , "" , nil ),
209+ })
210+
211+ ar , err := EvaluationLogToOSCALAssessmentResults (log )
212+ require .NoError (t , err )
213+ assert .Nil (t , ar .BackMatter )
214+ }
215+
176216func TestMapActorType (t * testing.T ) {
177217 assert .Equal (t , "person" , mapActorType (gemara .Human ))
178218 assert .Equal (t , "tool" , mapActorType (gemara .Software ))
0 commit comments