Skip to content

Commit

Permalink
Update test to handle new StepResult structs
Browse files Browse the repository at this point in the history
Signed-off-by: John Kjell <john@testifysec.com>
  • Loading branch information
jkjell committed Oct 10, 2024
1 parent 8ae13c2 commit 1a3d560
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 3 additions & 4 deletions policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")})
}
}

Expand Down
11 changes: 10 additions & 1 deletion policy/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
}
}

0 comments on commit 1a3d560

Please sign in to comment.