@@ -265,9 +265,13 @@ func (s) TestServerSideXDS_RouteConfiguration(t *testing.T) {
265265 // This Unary Call should match to a route with an incorrect action. Thus,
266266 // this RPC should not go through as per A36, and this call should receive
267267 // 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 {
269270 t .Fatalf ("client.UnaryCall() = _, %v, want _, error code %s" , err , codes .Unavailable )
270271 }
272+ if ! strings .Contains (err .Error (), nodeID ) {
273+ t .Fatalf ("client.UnaryCall() = %v, want xDS node id %q" , err , nodeID )
274+ }
271275
272276 // This Streaming Call should match to a route with an incorrect action.
273277 // 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) {
276280 if err != nil {
277281 t .Fatalf ("StreamingInputCall(_) = _, %v, want <nil>" , err )
278282 }
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 )
281290 }
282291
283292 // 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) {
286295 if err != nil {
287296 t .Fatalf ("FullDuplexCall(_) = _, %v, want <nil>" , err )
288297 }
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 )
291305 }
292306}
293307
@@ -826,7 +840,7 @@ func serverListenerWithBadRouteConfiguration(t *testing.T, host string, port uin
826840 }
827841}
828842
829- func (s ) TestRBACToggledOn_WithBadRouteConfiguration (t * testing.T ) {
843+ func (s ) TestRBAC_WithBadRouteConfiguration (t * testing.T ) {
830844 managementServer , nodeID , bootstrapContents , xdsResolver := setup .ManagementServerAndResolver (t )
831845
832846 lis , cleanup2 := setupGRPCServer (t , bootstrapContents )
@@ -867,11 +881,19 @@ func (s) TestRBACToggledOn_WithBadRouteConfiguration(t *testing.T) {
867881 defer cc .Close ()
868882
869883 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 )
872894 }
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 )
875897 }
876898}
877899
0 commit comments