mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
e2e: check user deletion during operations
This commit is contained in:
parent
d017814eaa
commit
68bcbdc84e
@ -19,10 +19,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCtlV3AuthEnable(t *testing.T) { testCtl(t, authEnableTest) }
|
func TestCtlV3AuthEnable(t *testing.T) { testCtl(t, authEnableTest) }
|
||||||
func TestCtlV3AuthDisable(t *testing.T) { testCtl(t, authDisableTest) }
|
func TestCtlV3AuthDisable(t *testing.T) { testCtl(t, authDisableTest) }
|
||||||
func TestCtlV3AuthWriteKey(t *testing.T) { testCtl(t, authCredWriteKeyTest) }
|
func TestCtlV3AuthWriteKey(t *testing.T) { testCtl(t, authCredWriteKeyTest) }
|
||||||
func TestCtlV3AuthRoleUpdate(t *testing.T) { testCtl(t, authRoleUpdateTest) }
|
func TestCtlV3AuthRoleUpdate(t *testing.T) { testCtl(t, authRoleUpdateTest) }
|
||||||
|
func TestCtlV3AuthUserDeleteDuringOps(t *testing.T) { testCtl(t, authUserDeleteDuringOpsTest) }
|
||||||
|
|
||||||
func authEnableTest(cx ctlCtx) {
|
func authEnableTest(cx ctlCtx) {
|
||||||
if err := authEnable(cx); err != nil {
|
if err := authEnable(cx); err != nil {
|
||||||
@ -166,6 +167,42 @@ func authRoleUpdateTest(cx ctlCtx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func authUserDeleteDuringOpsTest(cx ctlCtx) {
|
||||||
|
if err := ctlV3Put(cx, "foo", "bar", ""); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := authEnable(cx); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cx.user, cx.pass = "root", "root"
|
||||||
|
authSetupTestUser(cx)
|
||||||
|
|
||||||
|
// create a key
|
||||||
|
cx.user, cx.pass = "test-user", "pass"
|
||||||
|
if err := ctlV3Put(cx, "foo", "bar", ""); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
// confirm put succeeded
|
||||||
|
if err := ctlV3Get(cx, []string{"foo"}, []kv{{"foo", "bar"}}...); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete the user
|
||||||
|
cx.user, cx.pass = "root", "root"
|
||||||
|
err := ctlV3User(cx, []string{"delete", "test-user"}, "User test-user deleted", []string{})
|
||||||
|
if err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// check the user is deleted
|
||||||
|
cx.user, cx.pass = "test-user", "pass"
|
||||||
|
if err := ctlV3PutFailAuth(cx, "foo", "baz"); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func ctlV3PutFailAuth(cx ctlCtx, key, val string) error {
|
func ctlV3PutFailAuth(cx ctlCtx, key, val string) error {
|
||||||
return spawnWithExpect(append(cx.PrefixArgs(), "put", key, val), "authentication failed")
|
return spawnWithExpect(append(cx.PrefixArgs(), "put", key, val), "authentication failed")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user