@@ -42,6 +42,7 @@ var _ = Describe("RouteOptionsPlugin", func() {
42
42
cancel context.CancelFunc
43
43
routeOptionClient sologatewayv1.RouteOptionClient
44
44
statusReporter reporter.StatusReporter
45
+ statusCtx * plugins.StatusContext
45
46
)
46
47
47
48
BeforeEach (func () {
@@ -259,6 +260,81 @@ var _ = Describe("RouteOptionsPlugin", func() {
259
260
})
260
261
})
261
262
263
+ Context ("There is an error reading the RouteOptions" , func () {
264
+ BeforeEach (func () {
265
+ statusCtx = & plugins.StatusContext {
266
+ ProxiesWithReports : []translatorutils.ProxyWithReports {
267
+ {
268
+ Proxy : & v1.Proxy {},
269
+ Reports : translatorutils.TranslationReports {
270
+ ProxyReport : & validation.ProxyReport {},
271
+ ResourceReports : reporter.ResourceReports {},
272
+ },
273
+ },
274
+ },
275
+ }
276
+ })
277
+
278
+ When ("The RouteOption has a TargetRef" , func () {
279
+ It ("errors out" , func () {
280
+ deps := []client.Object {attachedRouteOption ()}
281
+ fakeClient := testutils .BuildIndexedFakeClient (deps , gwquery .IterateIndices , rtoptquery .IterateIndices )
282
+ gwQueries := testutils .BuildGatewayQueriesWithClient (fakeClient )
283
+ plugin := NewPlugin (gwQueries , fakeClient , routeOptionClient , statusReporter )
284
+
285
+ ctx := context .Background ()
286
+ routeCtx := & plugins.RouteContext {
287
+ Route : & gwv1.HTTPRoute {
288
+ ObjectMeta : metav1.ObjectMeta {
289
+ Name : "route" ,
290
+ Namespace : "default" ,
291
+ },
292
+ },
293
+ }
294
+
295
+ outputRoute := & v1.Route {
296
+ Options : & v1.RouteOptions {},
297
+ }
298
+ plugin .ApplyRoutePlugin (ctx , routeCtx , outputRoute )
299
+
300
+ err := plugin .ApplyStatusPlugin (ctx , statusCtx )
301
+ Expect (err ).To (MatchError (ContainSubstring (ReadingRouteOptionErrStr )))
302
+ })
303
+ })
304
+
305
+ When ("The HTTPRoute has an ExtensionRef" , func () {
306
+ It ("errors out" , func () {
307
+ deps := []client.Object {routeOption ()}
308
+ fakeClient := testutils .BuildIndexedFakeClient (deps , gwquery .IterateIndices , rtoptquery .IterateIndices )
309
+ gwQueries := testutils .BuildGatewayQueriesWithClient (fakeClient )
310
+ plugin := NewPlugin (gwQueries , fakeClient , routeOptionClient , statusReporter )
311
+
312
+ rtCtx := & plugins.RouteContext {
313
+ Route : & gwv1.HTTPRoute {},
314
+ Rule : & gwv1.HTTPRouteRule {
315
+ Filters : []gwv1.HTTPRouteFilter {{
316
+ Type : gwv1 .HTTPRouteFilterExtensionRef ,
317
+ ExtensionRef : & gwv1.LocalObjectReference {
318
+ Group : gwv1 .Group (sologatewayv1 .RouteOptionGVK .Group ),
319
+ Kind : gwv1 .Kind (sologatewayv1 .RouteOptionGVK .Kind ),
320
+ Name : "filter-policy" ,
321
+ },
322
+ }},
323
+ },
324
+ }
325
+
326
+ outputRoute := & v1.Route {
327
+ Options : & v1.RouteOptions {},
328
+ }
329
+ plugin .ApplyRoutePlugin (context .Background (), rtCtx , outputRoute )
330
+
331
+ err := plugin .ApplyStatusPlugin (ctx , statusCtx )
332
+ Expect (err ).To (MatchError (ContainSubstring (ReadingRouteOptionErrStr )))
333
+ })
334
+
335
+ })
336
+ })
337
+
262
338
When ("Two RouteOptions are attached correctly with different creation timestamps" , func () {
263
339
It ("correctly adds faultinjection from the earliest created object" , func () {
264
340
routeOptionClient .Write (attachedInternal (), clients.WriteOpts {})
0 commit comments