MCPcopy Create free account
hub / github.com/clouditor/clouditor / TestReflectionNoAuth

Function TestReflectionNoAuth

server/grpc_test.go:50–81  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

48}
49
50func TestReflectionNoAuth(t *testing.T) {
51 var (
52 session *cli.Session
53 conn *grpc.ClientConn
54 client grpc_reflection_v1.ServerReflectionClient
55 sclient grpc_reflection_v1.ServerReflection_ServerReflectionInfoClient
56 res *grpc_reflection_v1.ServerReflectionResponse
57 err error
58 )
59
60 session, err = cli.ContinueSession()
61 assert.NoError(t, err)
62
63 // Only use the host from the session, but not the (authentication) connection, since we want to test, whether we
64 // can access the reflection without authentication
65 conn, err = grpc.NewClient(session.URL, grpc.WithTransportCredentials(insecure.NewCredentials()))
66 assert.NoError(t, err)
67
68 client = grpc_reflection_v1.NewServerReflectionClient(conn)
69 sclient, err = client.ServerReflectionInfo(context.TODO())
70 assert.NoError(t, err)
71
72 err = sclient.Send(&grpc_reflection_v1.ServerReflectionRequest{
73 Host: "localhost",
74 MessageRequest: &grpc_reflection_v1.ServerReflectionRequest_ListServices{},
75 })
76 assert.NoError(t, err)
77
78 res, err = sclient.Recv()
79 assert.NoError(t, err)
80 assert.NotNil(t, res)
81}

Callers

nothing calls this directly

Calls 4

ContinueSessionFunction · 0.92
NotNilFunction · 0.92
SendMethod · 0.45
RecvMethod · 0.45

Tested by

no test coverage detected