diff --git a/e2e/e2e_utils.go b/e2e/e2e_utils.go index 27b67be8..5971b955 100644 --- a/e2e/e2e_utils.go +++ b/e2e/e2e_utils.go @@ -93,6 +93,13 @@ func getCustomResourceData(k8sClient *kubernetes.Clientset, path string) ([]byte DoRaw(context.TODO()) } +func deleteCustomResourceData(k8sClient *kubernetes.Clientset, path string) ([]byte, error) { + return k8sClient.RESTClient(). + Delete(). + AbsPath(path). + DoRaw(context.TODO()) +} + func getCustomResource(k8sClient *kubernetes.Clientset, path string) ([]byte, error) { data, err := getCustomResourceData(k8sClient, path) if err != nil { diff --git a/e2e/generate_filtered_sbom_test.go b/e2e/generate_filtered_sbom_test.go index 72b49972..f079a192 100644 --- a/e2e/generate_filtered_sbom_test.go +++ b/e2e/generate_filtered_sbom_test.go @@ -21,6 +21,7 @@ var ( //go:embed testdata/nginx-sbomspdx-filtered.json nginxSbomSpdxBytesFiltered []byte + expectedSbom string = "nginx-b49026" expectedSbomFiltered string = "pod-nginx-nginx-1ba5-4aaf" ) @@ -66,6 +67,14 @@ var _ = Describe("Generate filtered SBOM", func() { JustAfterEach(func() { err := deletePod(k8sClient, pod) Expect(err).To(BeNil()) + + path := fmt.Sprintf("/apis/%s/namespaces/%s/sbomspdxv2p3s/%s", sbom.APIVersion, sbom.Namespace, expectedSbom) + _, err = deleteCustomResourceData(k8sClient, path) + Expect(err).To(BeNil()) + + path = fmt.Sprintf("/apis/%s/namespaces/%s/sbomspdxv2p3filtereds/%s", sbom.APIVersion, sbom.Namespace, expectedSbomFiltered) + _, err = deleteCustomResourceData(k8sClient, path) + Expect(err).To(BeNil()) }) It("should generate a SBOMSPDXv2p3Filtered resource within 2 minutes", func() {