@@ -66,7 +66,7 @@ func TestObservabilityPoliciesTargetRefKind(t *testing.T) {
6666 },
6767 },
6868 {
69- name : "Validate TargetRef of kind Gateway is allowed" ,
69+ name : "Validate TargetRef of kind Gateway is not allowed" ,
7070 wantErrors : []string {expectedTargetRefMustBeHTTPRouteOrGrpcRouteError },
7171 spec : ngfAPIv1alpha2.ObservabilityPolicySpec {
7272 TargetRefs : []gatewayv1alpha2.LocalPolicyTargetReference {
@@ -192,8 +192,7 @@ func TestObservabilityPoliciesTargetRefKindAndNameCombo(t *testing.T) {
192192 wantErrors []string
193193 }{
194194 {
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" ,
197196 wantErrors : []string {expectedTargetRefKindAndNameComboMustBeUnique },
198197 spec : ngfAPIv1alpha2.ObservabilityPolicySpec {
199198 TargetRefs : []gatewayv1alpha2.LocalPolicyTargetReference {
@@ -210,6 +209,40 @@ func TestObservabilityPoliciesTargetRefKindAndNameCombo(t *testing.T) {
210209 },
211210 },
212211 },
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+ },
213246 }
214247
215248 for _ , tt := range tests {
0 commit comments