diff --git a/policy/policy.go b/policy/policy.go index 4a18b431..dbe3f22e 100644 --- a/policy/policy.go +++ b/policy/policy.go @@ -316,13 +316,12 @@ func (step Step) checkFunctionaries(statements []source.CollectionVerificationRe } if len(statements[i].ValidFunctionaries) == 0 { - result.Rejected = append(result.Rejected, RejectedCollection{Collection: statement, Reason: fmt.Errorf("no verifiers matched with allowed functionaries for step %s", step.Name)}) + result.Rejected = append(result.Rejected, RejectedCollection{Collection: statements[i], Reason: fmt.Errorf("no verifiers matched with allowed functionaries for step %s", step.Name)}) } else { - result.Passed = append(result.Passed, statement) + result.Passed = append(result.Passed, statements[i]) } } else { - statements[i].Errors = append(statement.Errors) - result.Rejected = append(result.Rejected, RejectedCollection{Collection: statement, Reason: fmt.Errorf("no verifiers present to validate against collection verifiers")}) + result.Rejected = append(result.Rejected, RejectedCollection{Collection: statements[i], Reason: fmt.Errorf("no verifiers present to validate against collection verifiers")}) } } diff --git a/policy/policy_test.go b/policy/policy_test.go index 761237c5..e3a766fd 100644 --- a/policy/policy_test.go +++ b/policy/policy_test.go @@ -588,7 +588,7 @@ func TestCheckFunctionaries(t *testing.T) { fmt.Println("running test case: ", testCase.name) result := testCase.step.checkFunctionaries(testCase.statements, testCase.trustBundles) resultCheckFields := []source.CollectionVerificationResult{} - for _, r := range result { + for _, r := range result.Passed { o := source.CollectionVerificationResult{ Errors: r.Errors, Warnings: r.Warnings, @@ -597,6 +597,15 @@ func TestCheckFunctionaries(t *testing.T) { resultCheckFields = append(resultCheckFields, o) } + for _, r := range result.Rejected { + o := source.CollectionVerificationResult{ + Errors: r.Collection.Errors, + Warnings: r.Collection.Warnings, + ValidFunctionaries: r.Collection.ValidFunctionaries, + } + resultCheckFields = append(resultCheckFields, o) + } + assert.Equal(t, testCase.expectedResults, resultCheckFields) } }