Skip to content

Commit

Permalink
Add tests to make sure rukpak enforces limitations
Browse files Browse the repository at this point in the history
Currently we do not allow:
* Bundles with webhook definitions
* Bundles which provide API Service definitions

Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
  • Loading branch information
m1kola committed Jun 17, 2024
1 parent ad595f1 commit 8d38db4
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions pkg/convert/registryv1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
})
})
})

Expand Down

0 comments on commit 8d38db4

Please sign in to comment.