Skip to content

Commit a15151a

Browse files
committed
fix: r
Signed-off-by: Ashing Zheng <[email protected]>
1 parent b656d2b commit a15151a

File tree

3 files changed

+151
-198
lines changed

3 files changed

+151
-198
lines changed

test/e2e/framework/manifests/webhook.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ webhooks:
146146
- gatewayproxies
147147
failurePolicy: Fail
148148
sideEffects: None
149-
<<<<<<< HEAD
150-
=======
151149
- name: vgrpcroute-v1.kb.io
152150
clientConfig:
153151
service:
@@ -190,7 +188,6 @@ webhooks:
190188
- httproutes
191189
failurePolicy: Fail
192190
sideEffects: None
193-
>>>>>>> 501b4e89 (test: add e2e test case for webhook (#2585))
194191
- name: vingress-v1.kb.io
195192
clientConfig:
196193
service:
@@ -233,8 +230,6 @@ webhooks:
233230
- ingressclasses
234231
failurePolicy: Fail
235232
sideEffects: None
236-
<<<<<<< HEAD
237-
=======
238233
- name: vtcproute-v1alpha2.kb.io
239234
clientConfig:
240235
service:
@@ -256,4 +251,3 @@ webhooks:
256251
- tcproutes
257252
failurePolicy: Fail
258253
sideEffects: None
259-
>>>>>>> 501b4e89 (test: add e2e test case for webhook (#2585))

test/e2e/webhook/gateway.go

Lines changed: 0 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -93,188 +93,4 @@ spec:
9393
Expect(err).ShouldNot(HaveOccurred())
9494
})
9595
})
96-
97-
Context("GatewayProxy configuration conflicts", func() {
98-
It("should reject GatewayProxy that reuses the same Service and AdminKey Secret as an existing one on create and update", func() {
99-
serviceTemplate := `
100-
apiVersion: v1
101-
kind: Service
102-
metadata:
103-
name: %s
104-
spec:
105-
selector:
106-
app: dummy-control-plane
107-
ports:
108-
- name: admin
109-
port: 9180
110-
targetPort: 9180
111-
`
112-
secretTemplate := `
113-
apiVersion: v1
114-
kind: Secret
115-
metadata:
116-
name: %s
117-
type: Opaque
118-
stringData:
119-
%s: %s
120-
`
121-
gatewayProxyTemplate := `
122-
apiVersion: apisix.apache.org/v1alpha1
123-
kind: GatewayProxy
124-
metadata:
125-
name: %s
126-
spec:
127-
provider:
128-
type: ControlPlane
129-
controlPlane:
130-
service:
131-
name: %s
132-
port: 9180
133-
auth:
134-
type: AdminKey
135-
adminKey:
136-
valueFrom:
137-
secretKeyRef:
138-
name: %s
139-
key: token
140-
`
141-
142-
serviceName := "gatewayproxy-shared-service"
143-
secretName := "gatewayproxy-shared-secret"
144-
initialProxy := "gatewayproxy-shared-primary"
145-
conflictingProxy := "gatewayproxy-shared-conflict"
146-
147-
Expect(s.CreateResourceFromString(fmt.Sprintf(serviceTemplate, serviceName))).ShouldNot(HaveOccurred(), "creating shared Service")
148-
Expect(s.CreateResourceFromString(fmt.Sprintf(secretTemplate, secretName, "token", "value"))).ShouldNot(HaveOccurred(), "creating shared Secret")
149-
150-
err := s.CreateResourceFromString(fmt.Sprintf(gatewayProxyTemplate, initialProxy, serviceName, secretName))
151-
Expect(err).ShouldNot(HaveOccurred(), "creating initial GatewayProxy")
152-
153-
time.Sleep(2 * time.Second)
154-
155-
err = s.CreateResourceFromString(fmt.Sprintf(gatewayProxyTemplate, conflictingProxy, serviceName, secretName))
156-
Expect(err).Should(HaveOccurred(), "expecting conflict for duplicated GatewayProxy")
157-
Expect(err.Error()).To(ContainSubstring("gateway proxy configuration conflict"))
158-
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("%s/%s", s.Namespace(), conflictingProxy)))
159-
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("%s/%s", s.Namespace(), initialProxy)))
160-
Expect(err.Error()).To(ContainSubstring("Service"))
161-
Expect(err.Error()).To(ContainSubstring("AdminKey secret"))
162-
163-
Expect(s.DeleteResource("GatewayProxy", initialProxy)).ShouldNot(HaveOccurred())
164-
Expect(s.DeleteResource("Service", serviceName)).ShouldNot(HaveOccurred())
165-
Expect(s.DeleteResource("Secret", secretName)).ShouldNot(HaveOccurred())
166-
})
167-
168-
It("should reject GatewayProxy that overlaps endpoints when sharing inline AdminKey value", func() {
169-
gatewayProxyTemplate := `
170-
apiVersion: apisix.apache.org/v1alpha1
171-
kind: GatewayProxy
172-
metadata:
173-
name: %s
174-
spec:
175-
provider:
176-
type: ControlPlane
177-
controlPlane:
178-
endpoints:
179-
- %s
180-
- %s
181-
auth:
182-
type: AdminKey
183-
adminKey:
184-
value: "%s"
185-
`
186-
187-
existingProxy := "gatewayproxy-inline-primary"
188-
conflictingProxy := "gatewayproxy-inline-conflict"
189-
endpointA := "https://127.0.0.1:9443"
190-
endpointB := "https://10.0.0.1:9443"
191-
endpointC := "https://192.168.0.1:9443"
192-
inlineKey := "inline-credential"
193-
194-
err := s.CreateResourceFromString(fmt.Sprintf(gatewayProxyTemplate, existingProxy, endpointA, endpointB, inlineKey))
195-
Expect(err).ShouldNot(HaveOccurred(), "creating GatewayProxy with inline AdminKey")
196-
197-
time.Sleep(2 * time.Second)
198-
199-
err = s.CreateResourceFromString(fmt.Sprintf(gatewayProxyTemplate, conflictingProxy, endpointB, endpointC, inlineKey))
200-
Expect(err).Should(HaveOccurred(), "expecting conflict for overlapping endpoints with shared AdminKey")
201-
Expect(err.Error()).To(ContainSubstring("gateway proxy configuration conflict"))
202-
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("%s/%s", s.Namespace(), conflictingProxy)))
203-
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("%s/%s", s.Namespace(), existingProxy)))
204-
Expect(err.Error()).To(ContainSubstring("control plane endpoints"))
205-
Expect(err.Error()).To(ContainSubstring("inline AdminKey value"))
206-
})
207-
208-
It("should reject GatewayProxy update that creates conflict with another GatewayProxy", func() {
209-
serviceTemplate := `
210-
apiVersion: v1
211-
kind: Service
212-
metadata:
213-
name: %s
214-
spec:
215-
selector:
216-
app: dummy-control-plane
217-
ports:
218-
- name: admin
219-
port: 9180
220-
targetPort: 9180
221-
`
222-
secretTemplate := `
223-
apiVersion: v1
224-
kind: Secret
225-
metadata:
226-
name: %s
227-
type: Opaque
228-
stringData:
229-
%s: %s
230-
`
231-
gatewayProxyTemplate := `
232-
apiVersion: apisix.apache.org/v1alpha1
233-
kind: GatewayProxy
234-
metadata:
235-
name: %s
236-
spec:
237-
provider:
238-
type: ControlPlane
239-
controlPlane:
240-
service:
241-
name: %s
242-
port: 9180
243-
auth:
244-
type: AdminKey
245-
adminKey:
246-
valueFrom:
247-
secretKeyRef:
248-
name: %s
249-
key: token
250-
`
251-
252-
sharedServiceName := "gatewayproxy-update-shared-service"
253-
sharedSecretName := "gatewayproxy-update-shared-secret"
254-
uniqueServiceName := "gatewayproxy-update-unique-service"
255-
proxyA := "gatewayproxy-update-a"
256-
proxyB := "gatewayproxy-update-b"
257-
258-
Expect(s.CreateResourceFromString(fmt.Sprintf(serviceTemplate, sharedServiceName))).ShouldNot(HaveOccurred(), "creating shared Service")
259-
Expect(s.CreateResourceFromString(fmt.Sprintf(serviceTemplate, uniqueServiceName))).ShouldNot(HaveOccurred(), "creating unique Service")
260-
Expect(s.CreateResourceFromString(fmt.Sprintf(secretTemplate, sharedSecretName, "token", "value"))).ShouldNot(HaveOccurred(), "creating shared Secret")
261-
262-
err := s.CreateResourceFromString(fmt.Sprintf(gatewayProxyTemplate, proxyA, sharedServiceName, sharedSecretName))
263-
Expect(err).ShouldNot(HaveOccurred(), "creating GatewayProxy A with shared Service and Secret")
264-
265-
time.Sleep(2 * time.Second)
266-
267-
err = s.CreateResourceFromString(fmt.Sprintf(gatewayProxyTemplate, proxyB, uniqueServiceName, sharedSecretName))
268-
Expect(err).ShouldNot(HaveOccurred(), "creating GatewayProxy B with unique Service but same Secret")
269-
270-
time.Sleep(2 * time.Second)
271-
272-
By("updating GatewayProxy B to use the same Service as GatewayProxy A, causing conflict")
273-
err = s.CreateResourceFromString(fmt.Sprintf(gatewayProxyTemplate, proxyB, sharedServiceName, sharedSecretName))
274-
Expect(err).Should(HaveOccurred(), "expecting conflict when updating to same Service")
275-
Expect(err.Error()).To(ContainSubstring("gateway proxy configuration conflict"))
276-
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("%s/%s", s.Namespace(), proxyA)))
277-
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("%s/%s", s.Namespace(), proxyB)))
278-
})
279-
})
28096
})

0 commit comments

Comments
 (0)