@@ -368,154 +368,6 @@ func TestRefsEnvoyProxy(t *testing.T) {
368368 }
369369}
370370
371- func TestClassRefsEnvoyProxy (t * testing.T ) {
372- gcCtrlName := gwapiv1 .GatewayController (egv1a1 .GatewayControllerName )
373-
374- testCases := []struct {
375- name string
376- gc * gwapiv1.GatewayClass
377- ep * egv1a1.EnvoyProxy
378- expected bool
379- }{
380- {
381- name : "nil gatewayclass and envoyproxy" ,
382- gc : nil ,
383- ep : nil ,
384- expected : false ,
385- },
386- {
387- name : "gatewayclass references envoyproxy" ,
388- gc : & gwapiv1.GatewayClass {
389- ObjectMeta : metav1.ObjectMeta {
390- Name : "test-gc" ,
391- },
392- Spec : gwapiv1.GatewayClassSpec {
393- ControllerName : gcCtrlName ,
394- ParametersRef : & gwapiv1.ParametersReference {
395- Group : gwapiv1 .Group (egv1a1 .GroupVersion .Group ),
396- Kind : gwapiv1 .Kind (egv1a1 .KindEnvoyProxy ),
397- Name : "test-ep" ,
398- Namespace : gatewayapi .NamespacePtr (config .DefaultNamespace ),
399- },
400- },
401- },
402- ep : & egv1a1.EnvoyProxy {
403- ObjectMeta : metav1.ObjectMeta {
404- Namespace : config .DefaultNamespace ,
405- Name : "test-ep" ,
406- },
407- },
408- expected : true ,
409- },
410- {
411- name : "gatewayclass does not reference envoyproxy" ,
412- gc : & gwapiv1.GatewayClass {
413- ObjectMeta : metav1.ObjectMeta {
414- Name : "test-gc" ,
415- },
416- Spec : gwapiv1.GatewayClassSpec {
417- ControllerName : gcCtrlName ,
418- ParametersRef : & gwapiv1.ParametersReference {
419- Group : gwapiv1 .Group (egv1a1 .GroupVersion .Group ),
420- Kind : gwapiv1 .Kind (egv1a1 .KindEnvoyProxy ),
421- Name : "not-test-ep" ,
422- Namespace : gatewayapi .NamespacePtr (config .DefaultNamespace ),
423- },
424- },
425- },
426- ep : & egv1a1.EnvoyProxy {
427- ObjectMeta : metav1.ObjectMeta {
428- Namespace : config .DefaultNamespace ,
429- Name : "test-ep" ,
430- },
431- },
432- expected : false ,
433- },
434- {
435- name : "gatewayclass references invalid kind" ,
436- gc : & gwapiv1.GatewayClass {
437- ObjectMeta : metav1.ObjectMeta {
438- Name : "test-gc" ,
439- },
440- Spec : gwapiv1.GatewayClassSpec {
441- ControllerName : gcCtrlName ,
442- ParametersRef : & gwapiv1.ParametersReference {
443- Group : gwapiv1 .Group (egv1a1 .GroupVersion .Group ),
444- Kind : gwapiv1 .Kind ("UnsupportedKind" ),
445- Name : "test-ep" ,
446- Namespace : gatewayapi .NamespacePtr (config .DefaultNamespace ),
447- },
448- },
449- },
450- ep : & egv1a1.EnvoyProxy {
451- ObjectMeta : metav1.ObjectMeta {
452- Namespace : config .DefaultNamespace ,
453- Name : "test-ep" ,
454- },
455- },
456- expected : false ,
457- },
458- {
459- name : "gatewayclass references invalid group" ,
460- gc : & gwapiv1.GatewayClass {
461- ObjectMeta : metav1.ObjectMeta {
462- Name : "test-gc" ,
463- },
464- Spec : gwapiv1.GatewayClassSpec {
465- ControllerName : gcCtrlName ,
466- ParametersRef : & gwapiv1.ParametersReference {
467- Group : gwapiv1 .Group ("UnsupportedGroup" ),
468- Kind : gwapiv1 .Kind (egv1a1 .KindEnvoyProxy ),
469- Name : "test-ep" ,
470- Namespace : gatewayapi .NamespacePtr (config .DefaultNamespace ),
471- },
472- },
473- },
474- ep : & egv1a1.EnvoyProxy {
475- ObjectMeta : metav1.ObjectMeta {
476- Namespace : config .DefaultNamespace ,
477- Name : "test-ep" ,
478- },
479- },
480- expected : false ,
481- },
482- {
483- name : "gatewayclass references envoyproxy without namespace" ,
484- gc : & gwapiv1.GatewayClass {
485- ObjectMeta : metav1.ObjectMeta {
486- Name : "test-gc" ,
487- },
488- Spec : gwapiv1.GatewayClassSpec {
489- ControllerName : gcCtrlName ,
490- ParametersRef : & gwapiv1.ParametersReference {
491- Group : gwapiv1 .Group (egv1a1 .GroupVersion .Group ),
492- Kind : gwapiv1 .Kind (egv1a1 .KindEnvoyProxy ),
493- Name : "test-ep" ,
494- },
495- },
496- },
497- ep : & egv1a1.EnvoyProxy {
498- ObjectMeta : metav1.ObjectMeta {
499- Namespace : config .DefaultNamespace ,
500- Name : "test-ep" ,
501- },
502- },
503- expected : false ,
504- },
505- }
506-
507- for i := range testCases {
508- tc := testCases [i ]
509-
510- // Run the test cases.
511- t .Run (tc .name , func (t * testing.T ) {
512- // Process the test case objects.
513- res := classRefsEnvoyProxy (tc .gc , tc .ep )
514- require .Equal (t , tc .expected , res )
515- })
516- }
517- }
518-
519371func TestClassAccepted (t * testing.T ) {
520372 gcCtrlName := gwapiv1 .GatewayController (egv1a1 .GatewayControllerName )
521373
0 commit comments