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

Method TestAuthInfoFromContext

credentials/alts/utils_test.go:44–72  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42)
43
44func (s) TestAuthInfoFromContext(t *testing.T) {
45 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
46 defer cancel()
47 altsAuthInfo := &fakeALTSAuthInfo{}
48 p := &peer.Peer{
49 AuthInfo: altsAuthInfo,
50 }
51 for _, tc := range []struct {
52 desc string
53 ctx context.Context
54 success bool
55 out AuthInfo
56 }{
57 {
58 "working case",
59 peer.NewContext(ctx, p),
60 true,
61 altsAuthInfo,
62 },
63 } {
64 authInfo, err := AuthInfoFromContext(tc.ctx)
65 if got, want := (err == nil), tc.success; got != want {
66 t.Errorf("%v: AuthInfoFromContext(_)=(err=nil)=%v, want %v", tc.desc, got, want)
67 }
68 if got, want := authInfo, tc.out; got != want {
69 t.Errorf("%v:, AuthInfoFromContext(_)=(%v, _), want (%v, _)", tc.desc, got, want)
70 }
71 }
72}
73
74func (s) TestAuthInfoFromPeer(t *testing.T) {
75 altsAuthInfo := &fakeALTSAuthInfo{}

Callers

nothing calls this directly

Calls 3

NewContextFunction · 0.92
AuthInfoFromContextFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected