@@ -360,11 +360,12 @@ func TestCalculatePostureReportV2(t *testing.T) {
360
360
const (
361
361
expectedForFramework1 = float32 (62.577965 )
362
362
expectedForFramework2 = float32 (46.42857 )
363
+ expectedForFramework3 = float32 (100 )
363
364
expectedSummary = float32 (51.280453 )
364
365
)
365
366
366
367
t .Run ("assert control scores" , func (t * testing.T ) {
367
- require .Len (t , report .SummaryDetails .Controls , 4 )
368
+ require .Len (t , report .SummaryDetails .Controls , 5 )
368
369
for _ , control := range report .SummaryDetails .Controls {
369
370
var expectedForControl float64
370
371
@@ -377,6 +378,8 @@ func TestCalculatePostureReportV2(t *testing.T) {
377
378
expectedForControl = 66.666664
378
379
case "control-4" :
379
380
expectedForControl = 0 // passed
381
+ case "control-5" :
382
+ expectedForControl = 0 // passed
380
383
}
381
384
382
385
assert .InDeltaf (t , expectedForControl , control .Score , 1e-6 ,
@@ -392,6 +395,9 @@ func TestCalculatePostureReportV2(t *testing.T) {
392
395
assert .InDeltaf (t , expectedForFramework2 , report .SummaryDetails .Frameworks [1 ].Score , 1e-6 ,
393
396
"unexpected summarized score for framework[1]" ,
394
397
)
398
+ assert .InDeltaf (t , expectedForFramework3 , report .SummaryDetails .Frameworks [2 ].Score , 1e-6 ,
399
+ "unexpected summarized score for framework[2]" ,
400
+ )
395
401
})
396
402
397
403
t .Run ("assert final score" , func (t * testing.T ) {
@@ -594,6 +600,25 @@ func mockPostureReportV2(t testing.TB) (map[string]workloadinterface.IMetadata,
594
600
},
595
601
},
596
602
},
603
+ {
604
+ // expected score: 100%
605
+ Name : "mock-fw-summary-3" ,
606
+ Controls : reportsummary.ControlSummaries {
607
+ // 0 failed resources
608
+ // All resources passed (control is irrelevant)
609
+ // expected control score: 100%
610
+ "summary-1" : reportsummary.ControlSummary {
611
+ Name : "mock-control-5" ,
612
+ ControlID : "control-5" ,
613
+ ResourceIDs : helpers.AllLists {},
614
+ ScoreFactor : 7.00 ,
615
+ StatusInfo : apis.StatusInfo {
616
+ InnerStatus : apis .StatusPassed ,
617
+ SubStatus : apis .SubStatusIrrelevant ,
618
+ },
619
+ },
620
+ },
621
+ },
597
622
},
598
623
},
599
624
Results : []resourcesresults.Result {},
@@ -957,13 +982,15 @@ func TestSetPostureReportComplianceScores(t *testing.T) {
957
982
const (
958
983
expectedScoreFramework1 = float32 (62.577965 )
959
984
expectedScoreFramework2 = float32 (46.42857 )
985
+ expectedScoreFramework3 = float32 (100 )
960
986
expectedComplianceScoreFramework1 = float32 (66.66667 )
961
987
expectedComplianceScoreFramework2 = float32 (75 )
962
- expectedSummary = float32 (70.833336 )
988
+ expectedComplianceScoreFramework3 = float32 (100 )
989
+ expectedSummary = float32 (76.66667 )
963
990
)
964
991
965
992
t .Run ("assert control scores" , func (t * testing.T ) {
966
- require .Len (t , report .SummaryDetails .Controls , 4 )
993
+ require .Len (t , report .SummaryDetails .Controls , 5 )
967
994
for _ , control := range report .SummaryDetails .Controls {
968
995
var expectedComplianceScore float64
969
996
var expectedScore float64
@@ -981,6 +1008,9 @@ func TestSetPostureReportComplianceScores(t *testing.T) {
981
1008
case "control-4" :
982
1009
expectedComplianceScore = 100 // passed
983
1010
expectedScore = 0
1011
+ case "control-5" :
1012
+ expectedComplianceScore = 100 // passed
1013
+ expectedScore = 0
984
1014
}
985
1015
986
1016
assert .InDeltaf (t , expectedComplianceScore , * control .ComplianceScore , 1e-6 ,
@@ -1000,6 +1030,9 @@ func TestSetPostureReportComplianceScores(t *testing.T) {
1000
1030
assert .InDeltaf (t , expectedScoreFramework2 , report .SummaryDetails .Frameworks [1 ].Score , 1e-6 ,
1001
1031
"unexpected summarized score for framework[1]" ,
1002
1032
)
1033
+ assert .InDeltaf (t , expectedScoreFramework3 , report .SummaryDetails .Frameworks [2 ].Score , 1e-6 ,
1034
+ "unexpected summarized score for framework[2]" ,
1035
+ )
1003
1036
})
1004
1037
1005
1038
t .Run ("assert framework compliance scores" , func (t * testing.T ) {
@@ -1009,6 +1042,9 @@ func TestSetPostureReportComplianceScores(t *testing.T) {
1009
1042
assert .InDeltaf (t , expectedComplianceScoreFramework2 , report .SummaryDetails .Frameworks [1 ].ComplianceScore , 1e-6 ,
1010
1043
"unexpected summarized compliance score for framework[1]" ,
1011
1044
)
1045
+ assert .InDeltaf (t , expectedComplianceScoreFramework3 , report .SummaryDetails .Frameworks [2 ].ComplianceScore , 1e-6 ,
1046
+ "unexpected summarized compliance score for framework[2]" ,
1047
+ )
1012
1048
})
1013
1049
1014
1050
t .Run ("assert final score" , func (t * testing.T ) {
0 commit comments