v3_auth_test.go (etcd-3.5.6) | : | v3_auth_test.go (etcd-3.5.7) | ||
---|---|---|---|---|
skipping to change at line 502 | skipping to change at line 502 | |||
clus.Members[0].Stop(t) | clus.Members[0].Stop(t) | |||
err = clus.Members[0].Restart(t) | err = clus.Members[0].Restart(t) | |||
testutil.AssertNil(t, err) | testutil.AssertNil(t, err) | |||
clus.Members[0].WaitOK(t) | clus.Members[0].WaitOK(t) | |||
// nothing has changed, but it fails without refreshing cache after resta rt | // nothing has changed, but it fails without refreshing cache after resta rt | |||
_, err = c2.Put(context.TODO(), "foo", "bar2") | _, err = c2.Put(context.TODO(), "foo", "bar2") | |||
testutil.AssertNil(t, err) | testutil.AssertNil(t, err) | |||
} | } | |||
func TestV3AuthWatchAndTokenExpire(t *testing.T) { | ||||
BeforeTest(t) | ||||
clus := NewClusterV3(t, &ClusterConfig{Size: 1, AuthTokenTTL: 3}) | ||||
defer clus.Terminate(t) | ||||
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second) | ||||
defer cancel() | ||||
authSetupRoot(t, toGRPC(clus.Client(0)).Auth) | ||||
c, cerr := NewClient(t, clientv3.Config{Endpoints: clus.Client(0).Endpoin | ||||
ts(), Username: "root", Password: "123"}) | ||||
if cerr != nil { | ||||
t.Fatal(cerr) | ||||
} | ||||
defer c.Close() | ||||
_, err := c.Put(ctx, "key", "val") | ||||
if err != nil { | ||||
t.Fatalf("Unexpected error from Put: %v", err) | ||||
} | ||||
// The first watch gets a valid auth token through watcher.newWatcherGrpc | ||||
Stream() | ||||
// We should discard the first one by waiting TTL after the first watch. | ||||
wChan := c.Watch(ctx, "key", clientv3.WithRev(1)) | ||||
watchResponse := <-wChan | ||||
time.Sleep(5 * time.Second) | ||||
wChan = c.Watch(ctx, "key", clientv3.WithRev(1)) | ||||
watchResponse = <-wChan | ||||
testutil.AssertNil(t, watchResponse.Err()) | ||||
} | ||||
func TestV3AuthWatchErrorAndWatchId0(t *testing.T) { | func TestV3AuthWatchErrorAndWatchId0(t *testing.T) { | |||
BeforeTest(t) | BeforeTest(t) | |||
clus := NewClusterV3(t, &ClusterConfig{Size: 3}) | clus := NewClusterV3(t, &ClusterConfig{Size: 3}) | |||
defer clus.Terminate(t) | defer clus.Terminate(t) | |||
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second) | ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second) | |||
defer cancel() | defer cancel() | |||
users := []user{ | users := []user{ | |||
{ | { | |||
End of changes. 1 change blocks. | ||||
35 lines changed or deleted | 0 lines changed or added |