Documentation ¶
Index ¶
- Constants
- type RemotePeer
- func (s *RemotePeer) Channel() *bufconn.Listener
- func (s *RemotePeer) ConfirmAddress(ctx context.Context, in *api.Address) (*api.AddressConfirmation, error)
- func (s *RemotePeer) IncrementCalls(rpc string)
- func (s *RemotePeer) KeyExchange(ctx context.Context, in *api.SigningKey) (*api.SigningKey, error)
- func (s *RemotePeer) Reset()
- func (s *RemotePeer) Shutdown()
- func (s *RemotePeer) Status(ctx context.Context, in *api.HealthCheck) (*api.ServiceState, error)
- func (s *RemotePeer) Transfer(ctx context.Context, in *api.SecureEnvelope) (*api.SecureEnvelope, error)
- func (s *RemotePeer) TransferStream(stream api.TRISANetwork_TransferStreamServer) error
- func (s *RemotePeer) UseError(rpc string, code codes.Code, msg string) error
- func (s *RemotePeer) UseFixture(rpc, path string) (err error)
Constants ¶
const ( TransferRPC = "trisa.api.v1beta1.TRISANetwork/Transfer" TransferStreamRPC = "trisa.api.v1beta1.TRISANetwork/TransferStream" KeyExchangeRPC = "trisa.api.v1beta1.TRISANetwork/KeyExchange" ConfirmAddressRPC = "trisa.api.v1beta1.TRISANetwork/ConfirmAddress" StatusRPC = "trisa.api.v1beta1.TRISAHealth/Status" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RemotePeer ¶ added in v0.4.0
type RemotePeer struct { sync.Mutex api.UnimplementedTRISAHealthServer api.UnimplementedTRISANetworkServer Calls map[string]int OnTransfer func(context.Context, *api.SecureEnvelope) (*api.SecureEnvelope, error) OnTransferStream func(api.TRISANetwork_TransferStreamServer) error OnKeyExchange func(context.Context, *api.SigningKey) (*api.SigningKey, error) OnConfirmAddress func(context.Context, *api.Address) (*api.AddressConfirmation, error) OnStatus func(context.Context, *api.HealthCheck) (*api.ServiceState, error) // contains filtered or unexported fields }
RemotePeer implements a mock gRPC server for testing Peer client connections. The desired response of the remote peer can be set by external callers using the OnRPC functions or the WithFixture or WithError functions. The Calls map can be used to count the number of times the remote peer RPC was called.
func New ¶ added in v0.4.0
func New(bufnet *bufconn.Listener) *RemotePeer
New creates a new mock RemotePeer. If bufnet is nil, one is created for the user.
func NewAuth ¶ added in v0.4.0
func NewAuth(bufnet *bufconn.Listener, certs *trust.Provider, pool trust.ProviderPool) (remote *RemotePeer, err error)
NewAuth creates a new mock RemotePeer that enforces mTLS credentials over bufconn.
func (*RemotePeer) Channel ¶ added in v0.4.0
func (s *RemotePeer) Channel() *bufconn.Listener
func (*RemotePeer) ConfirmAddress ¶ added in v0.4.0
func (s *RemotePeer) ConfirmAddress(ctx context.Context, in *api.Address) (*api.AddressConfirmation, error)
func (*RemotePeer) IncrementCalls ¶ added in v0.4.0
func (s *RemotePeer) IncrementCalls(rpc string)
func (*RemotePeer) KeyExchange ¶ added in v0.4.0
func (s *RemotePeer) KeyExchange(ctx context.Context, in *api.SigningKey) (*api.SigningKey, error)
func (*RemotePeer) Reset ¶ added in v0.4.0
func (s *RemotePeer) Reset()
func (*RemotePeer) Shutdown ¶ added in v0.4.0
func (s *RemotePeer) Shutdown()
func (*RemotePeer) Status ¶ added in v0.4.0
func (s *RemotePeer) Status(ctx context.Context, in *api.HealthCheck) (*api.ServiceState, error)
func (*RemotePeer) Transfer ¶ added in v0.4.0
func (s *RemotePeer) Transfer(ctx context.Context, in *api.SecureEnvelope) (*api.SecureEnvelope, error)
func (*RemotePeer) TransferStream ¶ added in v0.4.0
func (s *RemotePeer) TransferStream(stream api.TRISANetwork_TransferStreamServer) error
func (*RemotePeer) UseError ¶ added in v0.4.0
UseError allows you to specify a gRPC status error to return from the specified RPC.
func (*RemotePeer) UseFixture ¶ added in v0.4.0
func (s *RemotePeer) UseFixture(rpc, path string) (err error)
UseFixture loadsa a JSON fixture from disk (usually in a testdata folder) to use as the protocol buffer response to the specified RPC, simplifying handler mocking.