mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #8145 from mitake/non-authorized-rpcs
integration: add a test case for non authorized RPCs
This commit is contained in:
commit
6ea5676db4
@ -270,3 +270,25 @@ func authSetupRoot(t *testing.T, auth pb.AuthClient) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestV3AuthNonAuthorizedRPCs(t *testing.T) {
|
||||
defer testutil.AfterTest(t)
|
||||
clus := NewClusterV3(t, &ClusterConfig{Size: 1})
|
||||
defer clus.Terminate(t)
|
||||
|
||||
nonAuthedKV := clus.Client(0).KV
|
||||
|
||||
key := "foo"
|
||||
val := "bar"
|
||||
_, err := nonAuthedKV.Put(context.TODO(), key, val)
|
||||
if err != nil {
|
||||
t.Fatalf("couldn't put key (%v)", err)
|
||||
}
|
||||
|
||||
authSetupRoot(t, toGRPC(clus.Client(0)).Auth)
|
||||
|
||||
respput, err := nonAuthedKV.Put(context.TODO(), key, val)
|
||||
if !eqErrGRPC(err, rpctypes.ErrGRPCUserEmpty) {
|
||||
t.Fatalf("could put key (%v), it should cause an error of permission denied", respput)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user