MCPcopy
hub / github.com/grpc/grpc-go / authorityChecker

Function authorityChecker

credentials/credentials_ext_test.go:49–65  ·  view source on GitHub ↗
(ctx context.Context, wantAuthority string)

Source from the content-addressed store, hash-verified

47)
48
49func 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
67func loadTLSCreds(t *testing.T) (grpc.ServerOption, grpc.DialOption) {
68 t.Helper()

Calls 3

FromIncomingContextFunction · 0.92
ErrorFunction · 0.92
ErrorfFunction · 0.92

Tested by

no test coverage detected