Skip to content

Commit 56d6cb0

Browse files
m-messiahvincepri
authored andcommitted
🐛Fix certwatcher test to be backwards compatible
1 parent eeeac58 commit 56d6cb0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pkg/certwatcher/certwatcher_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package certwatcher_test
1818

1919
import (
20+
"bytes"
2021
"context"
2122
"crypto/rand"
2223
"crypto/rsa"
@@ -114,7 +115,7 @@ var _ = Describe("CertWatcher", func() {
114115
Eventually(func() bool {
115116
secondcert, _ := watcher.GetCertificate(nil)
116117
first := firstcert.PrivateKey.(*rsa.PrivateKey)
117-
return first.Equal(secondcert.PrivateKey) || firstcert.Leaf.SerialNumber == secondcert.Leaf.SerialNumber
118+
return first.Equal(secondcert.PrivateKey) || bytes.Equal(firstcert.Certificate[0], secondcert.Certificate[0])
118119
}).ShouldNot(BeTrue())
119120

120121
ctxCancel()
@@ -144,7 +145,7 @@ var _ = Describe("CertWatcher", func() {
144145
Eventually(func() bool {
145146
secondcert, _ := watcher.GetCertificate(nil)
146147
first := firstcert.PrivateKey.(*rsa.PrivateKey)
147-
return first.Equal(secondcert.PrivateKey) || firstcert.Leaf.SerialNumber == secondcert.Leaf.SerialNumber
148+
return first.Equal(secondcert.PrivateKey) || bytes.Equal(firstcert.Certificate[0], secondcert.Certificate[0])
148149
}).ShouldNot(BeTrue())
149150

150151
ctxCancel()
@@ -171,7 +172,7 @@ var _ = Describe("CertWatcher", func() {
171172
Eventually(func() bool {
172173
secondcert, _ := watcher.GetCertificate(nil)
173174
first := firstcert.PrivateKey.(*rsa.PrivateKey)
174-
return first.Equal(secondcert.PrivateKey) || firstcert.Leaf.SerialNumber == secondcert.Leaf.SerialNumber
175+
return first.Equal(secondcert.PrivateKey) || bytes.Equal(firstcert.Certificate[0], secondcert.Certificate[0])
175176
}, "10s", "1s").ShouldNot(BeTrue())
176177

177178
ctxCancel()

0 commit comments

Comments
 (0)