...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package fixchain
16
17 import (
18 "testing"
19 )
20
21 func TestHashBag(t *testing.T) {
22 hashBagTests := []struct {
23 certList1 []string
24 certList2 []string
25 expEqual bool
26 errMsg string
27 }{
28 {
29 []string{googleLeaf},
30 []string{thawteIntermediate},
31 false,
32 "hash match between Bags containing different certs",
33 },
34 {
35 []string{googleLeaf, thawteIntermediate},
36 []string{thawteIntermediate, googleLeaf},
37 true,
38 "hash mismatch between Bags containing the same certs",
39 },
40 {
41 []string{googleLeaf, thawteIntermediate},
42 []string{thawteIntermediate, googleLeaf, thawteIntermediate},
43 false,
44 "hash match between Bags containing the same certs, but one with duplicates",
45 },
46 }
47
48 for i, test := range hashBagTests {
49 certList1 := extractTestChain(t, i, test.certList1)
50 certList2 := extractTestChain(t, i, test.certList2)
51 if (hashBag(certList1) == hashBag(certList2)) != test.expEqual {
52 t.Errorf("#%d: %s", i, test.errMsg)
53 }
54 }
55 }
56
View as plain text