MCPcopy
hub / github.com/dgraph-io/dgraph / DgraphClientWithCerts

Function DgraphClientWithCerts

testutil/client.go:350–368  ·  view source on GitHub ↗

DgraphClientWithCerts creates a Dgraph client with TLS configured using the given viper configuration. It is intended to be called from TestMain() to establish a Dgraph connection shared by all tests, so there is no testing.T instance for it to use.

(serviceAddr string, conf *viper.Viper)

Source from the content-addressed store, hash-verified

348// It is intended to be called from TestMain() to establish a Dgraph connection shared
349// by all tests, so there is no testing.T instance for it to use.
350func DgraphClientWithCerts(serviceAddr string, conf *viper.Viper) (*dgo.Dgraph, error) {
351 tlsCfg, err := x.LoadClientTLSConfig(conf)
352 if err != nil {
353 return nil, err
354 }
355
356 dialOpts := []grpc.DialOption{}
357 if tlsCfg != nil {
358 dialOpts = append(dialOpts, grpc.WithTransportCredentials(credentials.NewTLS(tlsCfg)))
359 } else {
360 dialOpts = append(dialOpts, grpc.WithTransportCredentials(insecure.NewCredentials()))
361 }
362 conn, err := grpc.NewClient(serviceAddr, dialOpts...)
363 if err != nil {
364 return nil, err
365 }
366 dg := dgo.NewDgraphClient(api.NewDgraphClient(conn))
367 return dg, nil
368}
369
370// DropAll drops all the data in the Dgraph instance associated with the given client.
371func DropAll(t *testing.T, dg *dgo.Dgraph) {

Callers 8

TestBackupMinioEFunction · 0.92
TestLoaderXidmapFunction · 0.92
TestAccessWithClientCertFunction · 0.92
TestAccessWithCaCertFunction · 0.92
TestLoginOverTLSFunction · 0.92
TestAccessWithClientCertFunction · 0.92

Calls 1

LoadClientTLSConfigFunction · 0.92

Tested by 8

TestBackupMinioEFunction · 0.74
TestLoaderXidmapFunction · 0.74
TestAccessWithClientCertFunction · 0.74
TestAccessWithCaCertFunction · 0.74
TestLoginOverTLSFunction · 0.74
TestAccessWithClientCertFunction · 0.74