From 65fe806f0a4b1fe07eec4042ee78b5bb59f8a3ab Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Mon, 17 Apr 2017 11:26:39 -0700 Subject: [PATCH] integration: test auth API response header revision Signed-off-by: Gyu-Ho Lee --- integration/v3_auth_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/integration/v3_auth_test.go b/integration/v3_auth_test.go index 0ade82db35b5..06ee68ec967a 100644 --- a/integration/v3_auth_test.go +++ b/integration/v3_auth_test.go @@ -78,6 +78,32 @@ func TestV3AuthTokenWithDisable(t *testing.T) { <-donec } +func TestV3AuthRevision(t *testing.T) { + defer testutil.AfterTest(t) + clus := NewClusterV3(t, &ClusterConfig{Size: 1}) + defer clus.Terminate(t) + + api := toGRPC(clus.Client(0)) + + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + presp, perr := api.KV.Put(ctx, &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")}) + cancel() + if perr != nil { + t.Fatal(perr) + } + rev := presp.Header.Revision + + ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second) + aresp, aerr := api.Auth.UserAdd(ctx, &pb.AuthUserAddRequest{Name: "root", Password: "123"}) + cancel() + if aerr != nil { + t.Fatal(aerr) + } + if aresp.Header.Revision != rev { + t.Fatalf("revision expected %d, got %d", rev, aresp.Header.Revision) + } +} + func authSetupRoot(t *testing.T, auth pb.AuthClient) { if _, err := auth.UserAdd(context.TODO(), &pb.AuthUserAddRequest{Name: "root", Password: "123"}); err != nil { t.Fatal(err)