From 1a3d5609350adcb8917b3bd355235db32c8ebf6b Mon Sep 17 00:00:00 2001 From: John Kjell Date: Thu, 10 Oct 2024 10:09:57 -0500 Subject: [PATCH] Update test to handle new StepResult structs Signed-off-by: John Kjell --- policy/policy.go | 7 +++---- policy/policy_test.go | 11 ++++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) 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) } }