Coder Social home page Coder Social logo

Comments (4)

atollena avatar atollena commented on September 28, 2024

It's likely that we don't want setting the connection in the context to be a public API just to simplify testing of the usage of RBAC interceptors. The functionality to obtain local and peer addresses are otherwise available via the peer package. I do wonder though why the RBAC filter does not simply use the public peer.LocalAddr which is available in the context.

Alternatively, I tried to set up a full stack, but it increases the preparation complexity and make the test slow.

A lot of the tests in grpc-go work like this, so that's the approach I would recommend. You can look at examples in https://github.com/grpc/grpc-go/blob/c04b085930ce33ee83cc3f92dbe7632031e127a9/authz/grpc_authz_end2end_test.go. Each test that starts a client and a server run in less than 1-2 millisecond. There's maybe a bit more boilerplate for setup, but that's enough to justify making this API public, and it'll make the tests less brittle than relying on internal APIs.

from grpc-go.

atollena avatar atollena commented on September 28, 2024

@zasweq do you happen to remember why we directly want to use the conn.LocalAddr rather than peer.LocalAddr in the RBAC filter code:

// The connection is needed in order to find the destination address and
// port of the incoming RPC Call.
conn := getConnection(ctx)
if conn == nil {
return nil, errors.New("missing connection in incoming context")
}
?

from grpc-go.

atollena avatar atollena commented on September 28, 2024

Anyways, I think your best option for your use case seems to be end to end tests that don't rely on how the RBAC filter communicates with gRPC's transport. Let us know if that doesn't work for you, and why.

from grpc-go.

Zenithar avatar Zenithar commented on September 28, 2024

Ok, thank you. I will find another way to build a policy tester without setting up the complete gRPC stack.

from grpc-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.