Skip to content

Commit

Permalink
Fixing Hashi Vault integration test (openservicemesh#2098)
Browse files Browse the repository at this point in the history
Signed-off-by: Delyan Raychev <delyan.raychev@microsoft.com>
  • Loading branch information
draychev authored Nov 20, 2020
1 parent 374d418 commit b58a44f
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pkg/certificate/providers/vault/certificate_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,21 @@ var _ = Describe("Test client helpers", func() {
cm.cache.Store(expiredCertCN, expiredCert)
cm.cache.Store(validCertCN, validCert)

getCachedCertificateCNs := func() []certificate.CommonName {
var commonNames []certificate.CommonName
cm.cache.Range(func(cnInterface interface{}, certInterface interface{}) bool {
cert := certInterface.(*Certificate)
commonNames = append(commonNames, cert.GetCommonName())
return true
})
return commonNames
}

It("gets issuing CA public part", func() {
expectedNumberOfCertsInCache := 2
Expect(len(*cm.cache)).To(Equal(expectedNumberOfCertsInCache))
Expect(len(getCachedCertificateCNs())).To(Equal(expectedNumberOfCertsInCache))
Expect(getCachedCertificateCNs()).To(ContainElement(certificate.CommonName("this.has.expired")))
Expect(getCachedCertificateCNs()).To(ContainElement(certificate.CommonName("valid.certificate")))
certBytes := uuid.New().String()
issue := func(certificate.CommonName, time.Duration) (certificate.Certificater, error) {
cert := Certificate{
Expand All @@ -122,7 +134,9 @@ var _ = Describe("Test client helpers", func() {

// Ensure that cache is NOT affected
Expect(issuingCA).To(Equal([]byte(certBytes)))
Expect(len(*cm.cache)).To(Equal(expectedNumberOfCertsInCache))
Expect(len(getCachedCertificateCNs())).To(Equal(expectedNumberOfCertsInCache))
Expect(getCachedCertificateCNs()).To(ContainElement(certificate.CommonName("this.has.expired")))
Expect(getCachedCertificateCNs()).To(ContainElement(certificate.CommonName("valid.certificate")))
})

It("gets certs from cache", func() {
Expand Down

0 comments on commit b58a44f

Please sign in to comment.