Merge pull request #8042 from heyitsanthony/auth-tests

e2e: add role get and role list e2e tests
This commit is contained in:
Anthony Romano 2017-06-06 21:51:41 -07:00 committed by GitHub
commit e12c7f6dd4

View File

@ -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)
}
}