Skip to content

Commit

Permalink
move context creation to improve test readability
Browse files Browse the repository at this point in the history
  • Loading branch information
hasson82 committed Jun 27, 2024
1 parent 0430481 commit 832789b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/xds/rbac/rbac_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1747,12 +1747,13 @@ func (s) TestChainEngine(t *testing.T) {
// if the chain of RBAC Engines configured as such works as intended.
for _, data := range test.rbacQueries {
func() {
ctxWithTimeout, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
defer cancel()
// Construct the context with three data points that have enough
// information to represent incoming RPC's. This will be how a
// user uses this API. A user will have to put MD, PeerInfo, and
// the connection the RPC is sent on in the context.
ctx, cancel := context.WithTimeout(metadata.NewIncomingContext(context.Background(), data.rpcData.md), defaultTestTimeout)
defer cancel()
ctx := metadata.NewIncomingContext(ctxWithTimeout, data.rpcData.md)
// Make a TCP connection with a certain destination port. The
// address/port of this connection will be used to populate the
// destination ip/port in RPCData struct. This represents what
Expand Down

0 comments on commit 832789b

Please sign in to comment.