mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-05 20:32:57 +02:00
core/zero: add usage reporter (#5281)
* wip * add response * handle empty email * use set, update log * add test * add coalesce, comments, test * add test, fix bug * use builtin cmp.Or * remove wait ready call * use api error
This commit is contained in:
parent
82a9dbe42a
commit
146efc1b13
13 changed files with 697 additions and 2 deletions
44
internal/testutil/grpc.go
Normal file
44
internal/testutil/grpc.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
package testutil
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/test/bufconn"
|
||||
)
|
||||
|
||||
// NewGRPCServer starts a gRPC server and returns a client connection to it.
|
||||
func NewGRPCServer(t testing.TB, register func(s *grpc.Server)) *grpc.ClientConn {
|
||||
t.Helper()
|
||||
|
||||
li := bufconn.Listen(1024 * 1024)
|
||||
s := grpc.NewServer()
|
||||
register(s)
|
||||
go func() {
|
||||
err := s.Serve(li)
|
||||
if errors.Is(err, grpc.ErrServerStopped) {
|
||||
err = nil
|
||||
}
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
t.Cleanup(func() {
|
||||
s.Stop()
|
||||
})
|
||||
|
||||
cc, err := grpc.NewClient("passthrough://bufnet",
|
||||
grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) {
|
||||
return li.Dial()
|
||||
}),
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
cc.Close()
|
||||
})
|
||||
|
||||
return cc
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue