From 8d38db41a9aa3c0e17a7d2db52dec137f914d09b Mon Sep 17 00:00:00 2001 From: Mikalai Radchuk Date: Mon, 17 Jun 2024 13:46:42 +0200 Subject: [PATCH] Add tests to make sure rukpak enforces limitations Currently we do not allow: * Bundles with webhook definitions * Bundles which provide API Service definitions Signed-off-by: Mikalai Radchuk --- pkg/convert/registryv1_test.go | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/pkg/convert/registryv1_test.go b/pkg/convert/registryv1_test.go index 1c8a6c4d..33ed9781 100644 --- a/pkg/convert/registryv1_test.go +++ b/pkg/convert/registryv1_test.go @@ -382,6 +382,55 @@ var _ = Describe("RegistryV1 Suite", func() { }) }) + Context("Should enforce limitations", func() { + It("should not allow bundles with webhooks", func() { + By("creating a registry v1 bundle") + csv := v1alpha1.ClusterServiceVersion{ + ObjectMeta: metav1.ObjectMeta{ + Name: "testCSV", + }, + Spec: v1alpha1.ClusterServiceVersionSpec{ + InstallModes: []v1alpha1.InstallMode{{Type: v1alpha1.InstallModeTypeAllNamespaces, Supported: true}}, + WebhookDefinitions: []v1alpha1.WebhookDescription{{ConversionCRDs: []string{"fake-webhook.package-with-webhooks.io"}}}, + }, + } + watchNamespaces := []string{metav1.NamespaceAll} + registryv1Bundle = RegistryV1{ + PackageName: "testPkg", + CSV: csv, + } + + By("converting to plain") + plainBundle, err := Convert(registryv1Bundle, installNamespace, watchNamespaces) + Expect(err).To(MatchError(ContainSubstring("webhookDefinitions are not supported"))) + Expect(plainBundle).To(BeNil()) + }) + + It("should not allow bundles with API service definitions", func() { + By("creating a registry v1 bundle") + csv := v1alpha1.ClusterServiceVersion{ + ObjectMeta: metav1.ObjectMeta{ + Name: "testCSV", + }, + Spec: v1alpha1.ClusterServiceVersionSpec{ + InstallModes: []v1alpha1.InstallMode{{Type: v1alpha1.InstallModeTypeAllNamespaces, Supported: true}}, + APIServiceDefinitions: v1alpha1.APIServiceDefinitions{ + Owned: []v1alpha1.APIServiceDescription{{Name: "fake-owned-api-definition"}}, + }, + }, + } + watchNamespaces := []string{metav1.NamespaceAll} + registryv1Bundle = RegistryV1{ + PackageName: "testPkg", + CSV: csv, + } + + By("converting to plain") + plainBundle, err := Convert(registryv1Bundle, installNamespace, watchNamespaces) + Expect(err).To(MatchError(ContainSubstring("apiServiceDefintions are not supported"))) + Expect(plainBundle).To(BeNil()) + }) + }) }) })