Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

test(*): Adds test to certificate_manager.go #3617

Merged
merged 1 commit into from
Jun 24, 2021

Conversation

shalier
Copy link
Contributor

@shalier shalier commented Jun 17, 2021

Adds unit tests to functions in certificate_manager.go
and resolves #3435.

Signed-off-by: Shalier Xia [email protected]

Description:

Affected area:

Functional Area
New Functionality [ ]
Documentation [ ]
Install [ ]
CLI Tool [ ]
Certificate Management [ ]
Control Plane [ ]
Ingress [ ]
Egress [ ]
Networking [ ]
Observability [ ]
SMI Policy [ ]
Sidecar Injection [ ]
Security [ ]
Upgrade [ ]
Tests [x ]
CI System [ ]
Demo [ ]
Performance [ ]
Other [ ]

Please answer the following questions with yes/no.

  1. Does this change contain code from or inspired by another project? no

    • Did you notify the maintainers and provide attribution?
  2. Is this a breaking change? no

@shalier shalier requested a review from a team as a code owner June 17, 2021 17:20
@codecov-commenter
Copy link

codecov-commenter commented Jun 17, 2021

Codecov Report

Merging #3617 (4aca35d) into main (cd0bf12) will increase coverage by 0.04%.
The diff coverage is 25.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3617      +/-   ##
==========================================
+ Coverage   67.22%   67.27%   +0.04%     
==========================================
  Files         175      177       +2     
  Lines        8497     8589      +92     
==========================================
+ Hits         5712     5778      +66     
- Misses       2754     2780      +26     
  Partials       31       31              
Flag Coverage Δ
unittests 67.27% <25.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/certificate/encode.go 73.91% <0.00%> (ø)
...icate/providers/certmanager/certificate_manager.go 87.90% <100.00%> (+18.54%) ⬆️
pkg/validator/server.go 25.75% <0.00%> (-17.84%) ⬇️
cmd/osm-controller/osm-controller.go 14.38% <0.00%> (-0.84%) ⬇️
pkg/envoy/lds/inmesh.go 77.23% <0.00%> (-0.11%) ⬇️
pkg/envoy/lds/listener.go 90.00% <0.00%> (ø)
pkg/envoy/lds/response.go 67.30% <0.00%> (ø)
pkg/envoy/lds/gateway.go 82.92% <0.00%> (ø)
pkg/validator/patch.go 0.00% <0.00%> (ø)
pkg/kubernetes/event_handlers.go 69.44% <0.00%> (+3.59%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd0bf12...4aca35d. Read the comment docs.

Adds unit tests to functions in `certificate_manager.go`
and resolves openservicemesh#3435.

Signed-off-by: Shalier Xia <[email protected]>
@shalier shalier force-pushed the testsForCertManager branch from ca158c5 to 4aca35d Compare June 17, 2021 17:35
var errNoPrivateKeyInPEM = errors.New("no private Key in PEM")

// ErrNoCertificateInPEM is the errror for no certificate in PEM
var ErrNoCertificateInPEM = errors.New("no certificate in PEM")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this is public?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think because it is used in another package, certmanager, for testing purpose.

@@ -52,7 +52,7 @@ func (cm *CertManager) GetCertificate(cn certificate.CommonName) (certificate.Ce
if cert := cm.getFromCache(cn); cert != nil {
return cert, nil
}
return nil, fmt.Errorf("failed to find certificate with CN=%s", cn)
return nil, errCertNotFound
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error is now being used in the vault and cert-manager packages. We could move the errCertNotFound definition to pkg/certificate/providers/errors.go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure for vault's case, but it creates an import cycle for cert-manager if we do this

@shalier shalier merged commit 660aef4 into openservicemesh:main Jun 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test: pkg/certificate/providers/certmanager/certificate_manager.go functions
5 participants