浏览代码

e2e: add a test case for invalid management of root user and role

Hitoshi Mitake 8 年之前
父节点
当前提交
8d0d942c47
共有 1 个文件被更改,包括 15 次插入0 次删除
  1. 15 0
      e2e/ctl_v3_auth_test.go

+ 15 - 0
e2e/ctl_v3_auth_test.go

@@ -36,6 +36,7 @@ func TestCtlV3AuthMemberRemove(t *testing.T) {
 func TestCtlV3AuthMemberUpdate(t *testing.T)     { testCtl(t, authTestMemberUpdate) }
 func TestCtlV3AuthMemberUpdate(t *testing.T)     { testCtl(t, authTestMemberUpdate) }
 func TestCtlV3AuthCertCN(t *testing.T)           { testCtl(t, authTestCertCN, withCfg(configClientTLSCertAuth)) }
 func TestCtlV3AuthCertCN(t *testing.T)           { testCtl(t, authTestCertCN, withCfg(configClientTLSCertAuth)) }
 func TestCtlV3AuthRevokeWithDelete(t *testing.T) { testCtl(t, authTestRevokeWithDelete) }
 func TestCtlV3AuthRevokeWithDelete(t *testing.T) { testCtl(t, authTestRevokeWithDelete) }
+func TestCtlV3AuthInvalidMgmt(t *testing.T)      { testCtl(t, authTestInvalidMgmt) }
 
 
 func authEnableTest(cx ctlCtx) {
 func authEnableTest(cx ctlCtx) {
 	if err := authEnable(cx); err != nil {
 	if err := authEnable(cx); err != nil {
@@ -598,3 +599,17 @@ func authTestRevokeWithDelete(cx ctlCtx) {
 		cx.t.Fatal(err)
 		cx.t.Fatal(err)
 	}
 	}
 }
 }
+
+func authTestInvalidMgmt(cx ctlCtx) {
+	if err := authEnable(cx); err != nil {
+		cx.t.Fatal(err)
+	}
+
+	if err := ctlV3Role(cx, []string{"delete", "root"}, "Error:  etcdserver: invalid auth management"); err == nil {
+		cx.t.Fatal("deleting the role root must not be allowed")
+	}
+
+	if err := ctlV3User(cx, []string{"revoke-role", "root", "root"}, "Error:  etcdserver: invalid auth management", []string{}); err == nil {
+		cx.t.Fatal("revoking the role root from the user root must not be allowed")
+	}
+}