return true
}
- // Every expected chain should match 1 returned chain
+ // Every expected chain should match one (or more) returned chain. We tolerate multiple
+ // matches, as due to root store semantics it is plausible that (at least on the system
+ // verifiers) multiple identical (looking) chains may be returned when two roots with the
+ // same subject are present.
for _, expectedChain := range test.expectedChains {
- nChainMatched := 0
+ var match bool
for _, chain := range chains {
if doesMatch(expectedChain, chain) {
- nChainMatched++
+ match = true
+ break
}
}
- if nChainMatched != 1 {
- t.Errorf("Got %v matches instead of %v for expected chain %v", nChainMatched, 1, expectedChain)
- for _, chain := range chains {
- if doesMatch(expectedChain, chain) {
- t.Errorf("\t matched %v", chainToDebugString(chain))
- }
- }
+ if !match {
+ t.Errorf("No match found for %v", expectedChain)
}
}