|
| 1 | +package operators |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "encoding/json" |
| 6 | + "fmt" |
| 7 | + "os" |
| 8 | + "path/filepath" |
| 9 | + |
| 10 | + g "github.com/onsi/ginkgo/v2" |
| 11 | + o "github.com/onsi/gomega" |
| 12 | + "github.com/openshift/library-go/pkg/certs/cert-inspection/certgraphanalysis" |
| 13 | + "github.com/openshift/origin/pkg/monitortestlibrary/platformidentification" |
| 14 | + exutil "github.com/openshift/origin/test/extended/util" |
| 15 | +) |
| 16 | + |
| 17 | +var _ = g.Describe("[sig-arch][Late]", func() { |
| 18 | + defer g.GinkgoRecover() |
| 19 | + |
| 20 | + oc := exutil.NewCLIWithoutNamespace("certificate-checker") |
| 21 | + |
| 22 | + g.It("collect certificate data", func() { |
| 23 | + |
| 24 | + ctx := context.Background() |
| 25 | + kubeClient := oc.AdminKubeClient() |
| 26 | + if ok, _ := exutil.IsMicroShiftCluster(kubeClient); ok { |
| 27 | + g.Skip("microshift does not auto-collect TLS.") |
| 28 | + } |
| 29 | + jobType, err := platformidentification.GetJobType(context.TODO(), oc.AdminConfig()) |
| 30 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 31 | + tlsArtifactFilename := fmt.Sprintf("raw-tls-artifacts-%s-%s-%s-%s.json", jobType.Topology, jobType.Architecture, jobType.Platform, jobType.Network) |
| 32 | + |
| 33 | + currentPKIContent, err := certgraphanalysis.GatherCertsFromPlatformNamespaces(ctx, kubeClient) |
| 34 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 35 | + |
| 36 | + jsonBytes, err := json.MarshalIndent(currentPKIContent, "", " ") |
| 37 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 38 | + |
| 39 | + pkiDir := filepath.Join(exutil.ArtifactDirPath(), "rawTLSInfo") |
| 40 | + err = os.MkdirAll(pkiDir, 0755) |
| 41 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 42 | + err = os.WriteFile(filepath.Join(pkiDir, tlsArtifactFilename), jsonBytes, 0644) |
| 43 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 44 | + }) |
| 45 | + |
| 46 | +}) |
0 commit comments