Skip to content

Commit

Permalink
test: Verify registry server certificate rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
dlipovetsky authored and jimmidyson committed Nov 11, 2024
1 parent 8687f4e commit c035cf5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
9 changes: 5 additions & 4 deletions test/e2e/helmbundle/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func GenerateCertificateAndKeyWithIPSAN(

func ValidateChartIsAvailable(
t ginkgo.GinkgoTInterface,
g gomega.Gomega,
addr string,
port int,
chartName, chartVersion string,
Expand All @@ -196,9 +197,9 @@ func ValidateChartIsAvailable(
chartVersion,
pullOpts...,
)
gomega.ExpectWithOffset(1, err).NotTo(gomega.HaveOccurred())
g.ExpectWithOffset(1, err).NotTo(gomega.HaveOccurred())
chrt, err := helm.LoadChart(d)
gomega.ExpectWithOffset(1, err).NotTo(gomega.HaveOccurred())
gomega.ExpectWithOffset(1, chrt.Metadata.Name).To(gomega.Equal(chartName))
gomega.ExpectWithOffset(1, chrt.Metadata.Version).To(gomega.Equal(chartVersion))
g.ExpectWithOffset(1, err).NotTo(gomega.HaveOccurred())
g.ExpectWithOffset(1, chrt.Metadata.Name).To(gomega.Equal(chartName))
g.ExpectWithOffset(1, chrt.Metadata.Version).To(gomega.Equal(chartVersion))
}
2 changes: 2 additions & 0 deletions test/e2e/helmbundle/push_bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ var _ = Describe("Push Bundle", func() {

helpers.ValidateChartIsAvailable(
GinkgoT(),
Default,
"127.0.0.1",
port,
"podinfo",
Expand All @@ -85,6 +86,7 @@ var _ = Describe("Push Bundle", func() {

helpers.ValidateChartIsAvailable(
GinkgoT(),
Default,
"127.0.0.1",
port,
"node-feature-discovery",
Expand Down
24 changes: 22 additions & 2 deletions test/e2e/helmbundle/serve_bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"path/filepath"
"strconv"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -68,6 +69,7 @@ var _ = Describe("Serve Helm Bundle", func() {

helpers.ValidateChartIsAvailable(
GinkgoT(),
Default,
"127.0.0.1",
port,
"podinfo",
Expand All @@ -77,6 +79,7 @@ var _ = Describe("Serve Helm Bundle", func() {

helpers.ValidateChartIsAvailable(
GinkgoT(),
Default,
"127.0.0.1",
port,
"node-feature-discovery",
Expand Down Expand Up @@ -126,9 +129,26 @@ var _ = Describe("Serve Helm Bundle", func() {

helpers.WaitForTCPPort(GinkgoT(), ipAddr.String(), port)

helpers.ValidateChartIsAvailable(GinkgoT(), ipAddr.String(), port, "podinfo", "6.2.0", helm.CAFileOpt(caCertFile))
// First check mindthegap is // First check that the helm chart is accessible with the old certificate.
helpers.ValidateChartIsAvailable(GinkgoT(), Default, ipAddr.String(), port, "podinfo", "6.2.0", helm.CAFileOpt(caCertFile))

helpers.ValidateChartIsAvailable(GinkgoT(), ipAddr.String(), port, "node-feature-discovery", "0.15.2", helm.CAFileOpt(caCertFile))
helpers.ValidateChartIsAvailable(GinkgoT(), Default, ipAddr.String(), port, "node-feature-discovery", "0.15.2", helm.CAFileOpt(caCertFile))

// Create a new certificate. This can happen at any time the server is running,
// and the server is expected to eventually use the new certificate.
// This also generates a new CA file which is even better because we can check
// that the server is using the certificate issued by the new CA.
caCertFile, _, _, _ = helpers.GenerateCertificateAndKeyWithIPSAN(
GinkgoT(),
tempCertDir,
ipAddr,
)

Eventually(func(g Gomega) {
helpers.ValidateChartIsAvailable(GinkgoT(), g, ipAddr.String(), port, "podinfo", "6.2.0", helm.CAFileOpt(caCertFile))

helpers.ValidateChartIsAvailable(GinkgoT(), g, ipAddr.String(), port, "node-feature-discovery", "0.15.2", helm.CAFileOpt(caCertFile))
}).WithTimeout(time.Second * 5).WithPolling(time.Second * 1).Should(Succeed())

close(stopCh)

Expand Down

0 comments on commit c035cf5

Please sign in to comment.