Browse Source

e2e: add role get and role list e2e tests

Wasn't being covered
Anthony Romano 8 years ago
parent
commit
d8935903a2
1 changed files with 31 additions and 0 deletions
  1. 31 0
      e2e/ctl_v3_auth_test.go

+ 31 - 0
e2e/ctl_v3_auth_test.go

@@ -40,6 +40,9 @@ func TestCtlV3AuthInvalidMgmt(t *testing.T)      { testCtl(t, authTestInvalidMgm
 func TestCtlV3AuthFromKeyPerm(t *testing.T)      { testCtl(t, authTestFromKeyPerm) }
 func TestCtlV3AuthAndWatch(t *testing.T)         { testCtl(t, authTestWatch) }
 
+func TestCtlV3AuthRoleGet(t *testing.T)  { testCtl(t, authTestRoleGet) }
+func TestCtlV3AuthRoleList(t *testing.T) { testCtl(t, authTestRoleList) }
+
 func authEnableTest(cx ctlCtx) {
 	if err := authEnable(cx); err != nil {
 		cx.t.Fatal(err)
@@ -739,3 +742,31 @@ func authTestWatch(cx ctlCtx) {
 	}
 
 }
+
+func authTestRoleGet(cx ctlCtx) {
+	if err := authEnable(cx); err != nil {
+		cx.t.Fatal(err)
+	}
+	cx.user, cx.pass = "root", "root"
+	authSetupTestUser(cx)
+
+	expected := []string{
+		"Role test-role",
+		"KV Read:", "foo",
+		"KV Write:", "foo",
+	}
+	if err := spawnWithExpects(append(cx.PrefixArgs(), "role", "get", "test-role"), expected...); err != nil {
+		cx.t.Fatal(err)
+	}
+}
+
+func authTestRoleList(cx ctlCtx) {
+	if err := authEnable(cx); err != nil {
+		cx.t.Fatal(err)
+	}
+	cx.user, cx.pass = "root", "root"
+	authSetupTestUser(cx)
+	if err := spawnWithExpect(append(cx.PrefixArgs(), "role", "list"), "test-role"); err != nil {
+		cx.t.Fatal(err)
+	}
+}