|
| 1 | +package networking |
| 2 | + |
| 3 | +import ( |
| 4 | + g "github.com/onsi/ginkgo/v2" |
| 5 | + o "github.com/onsi/gomega" |
| 6 | + |
| 7 | + exutil "github.com/openshift/origin/test/extended/util" |
| 8 | +) |
| 9 | + |
| 10 | +var _ = g.Describe("[sig-network] ServiceCIDR", func() { |
| 11 | + oc := exutil.NewCLIWithoutNamespace("servicecidr") |
| 12 | + |
| 13 | + g.BeforeEach(func() { |
| 14 | + // The VAP is created by CNO, which doesn't run on MicroShift |
| 15 | + isMicroshift, err := exutil.IsMicroShiftCluster(oc.AdminKubeClient()) |
| 16 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 17 | + if isMicroshift { |
| 18 | + g.Skip("Feature is not currently blocked on Microshift") |
| 19 | + } |
| 20 | + }) |
| 21 | + |
| 22 | + g.It("should be blocked", func() { |
| 23 | + g.By("Trying to create a new ServiceCIDR") |
| 24 | + yaml := exutil.FixturePath("testdata", "servicecidr.yaml") |
| 25 | + err := oc.AsAdmin().Run("create").Args("-f", yaml).Execute() |
| 26 | + if err == nil { |
| 27 | + // This shouldn't have worked! We'll fail below, but delete the |
| 28 | + // ServiceCIDR first because otherwise it may cause spurious |
| 29 | + // failures throughout the rest of the test run. |
| 30 | + _ = oc.AsAdmin().Run("delete").Args("newcidr1").Execute() |
| 31 | + } |
| 32 | + o.Expect(err).To(o.HaveOccurred(), "Creating a ServiceCIDR should have been blocked by ValidatingAdmissionPolicy") |
| 33 | + |
| 34 | + g.By("Trying to modify an existing ServiceCIDR") |
| 35 | + err = oc.AsAdmin().Run("annotate").Args("servicecidr", "kubernetes", "e2etest=success").Execute() |
| 36 | + o.Expect(err).To(o.HaveOccurred(), "Modifying existing ServiceCIDR should have been blocked by ValidatingAdmissionPolicy") |
| 37 | + }) |
| 38 | +}) |
0 commit comments