(ctx context.Context, wantAuthority string)
| 47 | ) |
| 48 | |
| 49 | func authorityChecker(ctx context.Context, wantAuthority string) error { |
| 50 | md, ok := metadata.FromIncomingContext(ctx) |
| 51 | if !ok { |
| 52 | return status.Error(codes.InvalidArgument, "failed to parse metadata") |
| 53 | } |
| 54 | auths, ok := md[":authority"] |
| 55 | if !ok { |
| 56 | return status.Error(codes.InvalidArgument, "no authority header") |
| 57 | } |
| 58 | if len(auths) != 1 { |
| 59 | return status.Errorf(codes.InvalidArgument, "expected exactly one authority header, got %v", auths) |
| 60 | } |
| 61 | if auths[0] != wantAuthority { |
| 62 | return status.Errorf(codes.InvalidArgument, "invalid authority header %q, want %q", auths[0], wantAuthority) |
| 63 | } |
| 64 | return nil |
| 65 | } |
| 66 | |
| 67 | func loadTLSCreds(t *testing.T) (grpc.ServerOption, grpc.DialOption) { |
| 68 | t.Helper() |
no test coverage detected