(t *testing.T)
| 278 | } |
| 279 | |
| 280 | func 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 | |
| 320 | func TestSyncFiltersMembers(t *testing.T) { |
| 321 | c, _ := NewClient(t, Config{Endpoints: []string{"http://254.0.0.1:12345"}}) |
nothing calls this directly
no test coverage detected
searching dependent graphs…