|
35 | 35 | //go:embed t/node-entity-allow-cnp.yaml |
36 | 36 | nodeEntityAllowCiliumNetworkPolicy []byte |
37 | 37 |
|
| 38 | + //go:embed t/world-entity-allow-cnp.yaml |
| 39 | + worldEntityAllowCiliumNetworkPolicy []byte |
| 40 | + |
38 | 41 | //go:embed t/legal-cnp.yaml |
39 | 42 | legalCiliumNetworkPolicy []byte |
40 | 43 | ) |
@@ -317,6 +320,26 @@ var _ = Describe("NetworkPolicyAdmissionRule", func() { |
317 | 320 | }).Should(Succeed()) |
318 | 321 | }) |
319 | 322 |
|
| 323 | + It("should not accept CiliumNetworkPolicy with forbidden rules except for excluded namespaces using expressions", func() { |
| 324 | + By("setting up namespace") |
| 325 | + ns := uuid.NewString() |
| 326 | + kubectlSafe(nil, "create", "ns", ns) |
| 327 | + necoNS := uuid.NewString() |
| 328 | + kubectlSafe(nil, "create", "ns", necoNS) |
| 329 | + kubectlSafe(nil, "label", "ns", necoNS, "team=neco") |
| 330 | + tenantNS := uuid.NewString() |
| 331 | + kubectlSafe(nil, "create", "ns", tenantNS) |
| 332 | + kubectlSafe(nil, "label", "ns", tenantNS, "team=tenant") |
| 333 | + |
| 334 | + By("applying world entity CiliumNetworkPolicy which is forbidden in namespaces except for neco") |
| 335 | + _, err := kubectl(worldEntityAllowCiliumNetworkPolicy, "apply", "-n", ns, "-f", "-") |
| 336 | + Expect(err).To(HaveOccurred()) |
| 337 | + _, err = kubectl(worldEntityAllowCiliumNetworkPolicy, "apply", "-n", necoNS, "-f", "-") |
| 338 | + Expect(err).NotTo(HaveOccurred()) |
| 339 | + _, err = kubectl(worldEntityAllowCiliumNetworkPolicy, "apply", "-n", tenantNS, "-f", "-") |
| 340 | + Expect(err).NotTo(HaveOccurred()) |
| 341 | + }) |
| 342 | + |
320 | 343 | It("should not reject a legal CiliumNetworkPolicy", func() { |
321 | 344 | By("setting up namespace") |
322 | 345 | nsName := uuid.NewString() |
|
0 commit comments