MCPcopy
hub / github.com/etcd-io/etcd / TestAuthTokenBundleNoOverwrite

Function TestAuthTokenBundleNoOverwrite

client/v3/client_test.go:280–318  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

278}
279
280func TestAuthTokenBundleNoOverwrite(t *testing.T) {
281 // This call in particular changes working directory to the tmp dir of
282 // the test. The `etcd-auth-test:0` can be created in local directory,
283 // not exceeding the longest allowed path on OsX.
284 testutil.BeforeTest(t)
285
286 // Create a mock AuthServer to handle Authenticate RPCs.
287 lis, err := net.Listen("unix", "etcd-auth-test:0")
288 require.NoError(t, err)
289 defer lis.Close()
290 addr := "unix://" + lis.Addr().String()
291 srv := grpc.NewServer()
292 etcdserverpb.RegisterAuthServer(srv, mockAuthServer{})
293 go srv.Serve(lis)
294 defer srv.Stop()
295
296 // Create a client, which should call Authenticate on the mock server to
297 // exchange username/password for an auth token.
298 c, err := NewClient(t, Config{
299 DialTimeout: 5 * time.Second,
300 Endpoints: []string{addr},
301 Username: "foo",
302 Password: "bar",
303 })
304 require.NoError(t, err)
305 defer c.Close()
306 oldTokenBundle := c.authTokenBundle
307
308 // Call the public Dial again, which should preserve the original
309 // authTokenBundle.
310 gc, err := c.Dial(addr)
311 require.NoError(t, err)
312 defer gc.Close()
313 newTokenBundle := c.authTokenBundle
314
315 if oldTokenBundle != newTokenBundle {
316 t.Error("Client.authTokenBundle has been overwritten during Client.Dial")
317 }
318}
319
320func TestSyncFiltersMembers(t *testing.T) {
321 c, _ := NewClient(t, Config{Endpoints: []string{"http://254.0.0.1:12345"}})

Callers

nothing calls this directly

Calls 9

CloseMethod · 0.95
DialMethod · 0.95
AddrMethod · 0.80
NewClientFunction · 0.70
BeforeTestMethod · 0.65
CloseMethod · 0.65
StringMethod · 0.65
StopMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…