@@ -66,7 +66,7 @@ func TestObservabilityPoliciesTargetRefKind(t *testing.T) {
66
66
},
67
67
},
68
68
{
69
- name : "Validate TargetRef of kind Gateway is allowed" ,
69
+ name : "Validate TargetRef of kind Gateway is not allowed" ,
70
70
wantErrors : []string {expectedTargetRefMustBeHTTPRouteOrGrpcRouteError },
71
71
spec : ngfAPIv1alpha2.ObservabilityPolicySpec {
72
72
TargetRefs : []gatewayv1alpha2.LocalPolicyTargetReference {
@@ -192,8 +192,7 @@ func TestObservabilityPoliciesTargetRefKindAndNameCombo(t *testing.T) {
192
192
wantErrors []string
193
193
}{
194
194
{
195
- // This test is not throwing an error like we expect it to...
196
- name : "Validate TargetRef Kind and Name combination is unique" ,
195
+ name : "Validate resource is invalid when TargetRef Kind and Name combination is not unique" ,
197
196
wantErrors : []string {expectedTargetRefKindAndNameComboMustBeUnique },
198
197
spec : ngfAPIv1alpha2.ObservabilityPolicySpec {
199
198
TargetRefs : []gatewayv1alpha2.LocalPolicyTargetReference {
@@ -210,6 +209,40 @@ func TestObservabilityPoliciesTargetRefKindAndNameCombo(t *testing.T) {
210
209
},
211
210
},
212
211
},
212
+ {
213
+ name : "Validate resource is valid when TargetRef Kind and Name combination is unique using different kinds" ,
214
+ spec : ngfAPIv1alpha2.ObservabilityPolicySpec {
215
+ TargetRefs : []gatewayv1alpha2.LocalPolicyTargetReference {
216
+ {
217
+ Kind : httpRouteKind ,
218
+ Name : gatewayv1alpha2 .ObjectName (testTargetRefName ),
219
+ Group : gatewayGroup ,
220
+ },
221
+ {
222
+ Kind : grpcRouteKind ,
223
+ Name : gatewayv1alpha2 .ObjectName (testTargetRefName ),
224
+ Group : gatewayGroup ,
225
+ },
226
+ },
227
+ },
228
+ },
229
+ {
230
+ name : "Validate resource is valid when TargetRef Kind and Name combination is unique using different names" ,
231
+ spec : ngfAPIv1alpha2.ObservabilityPolicySpec {
232
+ TargetRefs : []gatewayv1alpha2.LocalPolicyTargetReference {
233
+ {
234
+ Kind : httpRouteKind ,
235
+ Name : gatewayv1alpha2 .ObjectName (uniqueResourceName (testTargetRefName )),
236
+ Group : gatewayGroup ,
237
+ },
238
+ {
239
+ Kind : grpcRouteKind ,
240
+ Name : gatewayv1alpha2 .ObjectName (uniqueResourceName (testTargetRefName )),
241
+ Group : gatewayGroup ,
242
+ },
243
+ },
244
+ },
245
+ },
213
246
}
214
247
215
248
for _ , tt := range tests {
0 commit comments