Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Add tests to make sure rukpak enforces limitations #922

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading