@@ -265,9 +265,13 @@ func (s) TestServerSideXDS_RouteConfiguration(t *testing.T) {
265
265
// This Unary Call should match to a route with an incorrect action. Thus,
266
266
// this RPC should not go through as per A36, and this call should receive
267
267
// an error with codes.Unavailable.
268
- if _ , err = client .UnaryCall (ctx , & testpb.SimpleRequest {}); status .Code (err ) != codes .Unavailable {
268
+ _ , err = client .UnaryCall (ctx , & testpb.SimpleRequest {})
269
+ if status .Code (err ) != codes .Unavailable {
269
270
t .Fatalf ("client.UnaryCall() = _, %v, want _, error code %s" , err , codes .Unavailable )
270
271
}
272
+ if ! strings .Contains (err .Error (), nodeID ) {
273
+ t .Fatalf ("client.UnaryCall() = %v, want xDS node id %q" , err , nodeID )
274
+ }
271
275
272
276
// This Streaming Call should match to a route with an incorrect action.
273
277
// Thus, this RPC should not go through as per A36, and this call should
@@ -276,8 +280,13 @@ func (s) TestServerSideXDS_RouteConfiguration(t *testing.T) {
276
280
if err != nil {
277
281
t .Fatalf ("StreamingInputCall(_) = _, %v, want <nil>" , err )
278
282
}
279
- if _ , err = stream .CloseAndRecv (); status .Code (err ) != codes .Unavailable || ! strings .Contains (err .Error (), "the incoming RPC matched to a route that was not of action type non forwarding" ) {
280
- t .Fatalf ("streaming RPC should have been denied" )
283
+ _ , err = stream .CloseAndRecv ()
284
+ const wantStreamingErr = "the incoming RPC matched to a route that was not of action type non forwarding"
285
+ if status .Code (err ) != codes .Unavailable || ! strings .Contains (err .Error (), wantStreamingErr ) {
286
+ t .Fatalf ("client.StreamingInputCall() = %v, want error with code %s and message %q" , err , codes .Unavailable , wantStreamingErr )
287
+ }
288
+ if ! strings .Contains (err .Error (), nodeID ) {
289
+ t .Fatalf ("client.StreamingInputCall() = %v, want xDS node id %q" , err , nodeID )
281
290
}
282
291
283
292
// This Full Duplex should not match to a route, and thus should return an
@@ -286,8 +295,13 @@ func (s) TestServerSideXDS_RouteConfiguration(t *testing.T) {
286
295
if err != nil {
287
296
t .Fatalf ("FullDuplexCall(_) = _, %v, want <nil>" , err )
288
297
}
289
- if _ , err = dStream .Recv (); status .Code (err ) != codes .Unavailable || ! strings .Contains (err .Error (), "the incoming RPC did not match a configured Route" ) {
290
- t .Fatalf ("streaming RPC should have been denied" )
298
+ _ , err = dStream .Recv ()
299
+ const wantFullDuplexErr = "the incoming RPC did not match a configured Route"
300
+ if status .Code (err ) != codes .Unavailable || ! strings .Contains (err .Error (), wantFullDuplexErr ) {
301
+ t .Fatalf ("client.FullDuplexCall() = %v, want error with code %s and message %q" , err , codes .Unavailable , wantFullDuplexErr )
302
+ }
303
+ if ! strings .Contains (err .Error (), nodeID ) {
304
+ t .Fatalf ("client.FullDuplexCall() = %v, want xDS node id %q" , err , nodeID )
291
305
}
292
306
}
293
307
@@ -826,7 +840,7 @@ func serverListenerWithBadRouteConfiguration(t *testing.T, host string, port uin
826
840
}
827
841
}
828
842
829
- func (s ) TestRBACToggledOn_WithBadRouteConfiguration (t * testing.T ) {
843
+ func (s ) TestRBAC_WithBadRouteConfiguration (t * testing.T ) {
830
844
managementServer , nodeID , bootstrapContents , xdsResolver := setup .ManagementServerAndResolver (t )
831
845
832
846
lis , cleanup2 := setupGRPCServer (t , bootstrapContents )
@@ -867,11 +881,19 @@ func (s) TestRBACToggledOn_WithBadRouteConfiguration(t *testing.T) {
867
881
defer cc .Close ()
868
882
869
883
client := testgrpc .NewTestServiceClient (cc )
870
- if _ , err := client .EmptyCall (ctx , & testpb.Empty {}); status .Code (err ) != codes .Unavailable {
871
- t .Fatalf ("EmptyCall() returned err with status: %v, if RBAC is disabled all RPC's should proceed as normal" , status .Code (err ))
884
+ _ , err = client .EmptyCall (ctx , & testpb.Empty {})
885
+ if status .Code (err ) != codes .Unavailable {
886
+ t .Fatalf ("EmptyCall() returned %v, want Unavailable" , err )
887
+ }
888
+ if ! strings .Contains (err .Error (), nodeID ) {
889
+ t .Fatalf ("EmptyCall() = %v, want xDS node id %q" , err , nodeID )
890
+ }
891
+ _ , err = client .UnaryCall (ctx , & testpb.SimpleRequest {})
892
+ if status .Code (err ) != codes .Unavailable {
893
+ t .Fatalf ("UnaryCall() returned %v, want Unavailable" , err )
872
894
}
873
- if _ , err := client . UnaryCall ( ctx , & testpb. SimpleRequest {}); status . Code ( err ) != codes . Unavailable {
874
- t .Fatalf ("UnaryCall() returned err with status: %v, if RBAC is disabled all RPC's should proceed as normal " , status . Code ( err ) )
895
+ if ! strings . Contains ( err . Error (), nodeID ) {
896
+ t .Fatalf ("UnaryCall() = %v, want xDS node id %q " , err , nodeID )
875
897
}
876
898
}
877
899
0 commit comments