(ctx context.Context, expectedAuthority string)
| 44 | ) |
| 45 | |
| 46 | func authorityChecker(ctx context.Context, expectedAuthority string) (*testpb.Empty, error) { |
| 47 | md, ok := metadata.FromIncomingContext(ctx) |
| 48 | if !ok { |
| 49 | return nil, status.Error(codes.InvalidArgument, "failed to parse metadata") |
| 50 | } |
| 51 | auths, ok := md[":authority"] |
| 52 | if !ok { |
| 53 | return nil, status.Error(codes.InvalidArgument, "no authority header") |
| 54 | } |
| 55 | if len(auths) != 1 { |
| 56 | return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("no authority header, auths = %v", auths)) |
| 57 | } |
| 58 | if auths[0] != expectedAuthority { |
| 59 | return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid authority header %v, expected %v", auths[0], expectedAuthority)) |
| 60 | } |
| 61 | return &testpb.Empty{}, nil |
| 62 | } |
| 63 | |
| 64 | func runUnixTest(t *testing.T, address, target, expectedAuthority string, dialer func(context.Context, string) (net.Conn, error)) { |
| 65 | if !strings.HasPrefix(target, "unix-abstract:") { |
no test coverage detected