From f13e558ab438c24f374b90b7aa0747a402a3d110 Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Tue, 12 Apr 2016 11:15:06 -0700 Subject: [PATCH 1/2] e2e: test etcdtl user list on root user --- e2e/ctl_v2_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/e2e/ctl_v2_test.go b/e2e/ctl_v2_test.go index 394203d71..5b2574176 100644 --- a/e2e/ctl_v2_test.go +++ b/e2e/ctl_v2_test.go @@ -183,7 +183,10 @@ func testCtlV2GetRoleUser(t *testing.T, cfg *etcdProcessClusterConfig) { } } -func TestCtlV2UserList(t *testing.T) { +func TestCtlV2UserListUsername(t *testing.T) { testCtlV2UserList(t, "username") } +func TestCtlV2UserListRoot(t *testing.T) { testCtlV2UserList(t, "root") } + +func testCtlV2UserList(t *testing.T, username string) { defer testutil.AfterTest(t) epc := setupEtcdctlTest(t, &configWithProxy, false) @@ -193,10 +196,10 @@ func TestCtlV2UserList(t *testing.T) { } }() - if err := etcdctlUserAdd(epc, "username", "password"); err != nil { + if err := etcdctlUserAdd(epc, username, "password"); err != nil { t.Fatalf("failed to add user (%v)", err) } - if err := etcdctlUserList(epc, "username"); err != nil { + if err := etcdctlUserList(epc, username); err != nil { t.Fatalf("failed to list users (%v)", err) } } From c9ce92f635aa932d67ab03047f09f3e7cc6a4804 Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Tue, 12 Apr 2016 12:38:29 -0700 Subject: [PATCH 2/2] client: accept roles in response for ListUser Fixes #5046 --- client/auth_user.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/auth_user.go b/client/auth_user.go index 6af1c2886..f86f083c6 100644 --- a/client/auth_user.go +++ b/client/auth_user.go @@ -36,6 +36,12 @@ type User struct { Revoke []string `json:"revoke,omitempty"` } +// userListEntry is the user representation given by the server for ListUsers +type userListEntry struct { + User string `json:"user"` + Roles []Role `json:"roles"` +} + type UserRoles struct { User string `json:"user"` Roles []Role `json:"roles"` @@ -194,7 +200,7 @@ func (u *httpAuthUserAPI) ListUsers(ctx context.Context) ([]string, error) { } var userList struct { - Users []User `json:"users"` + Users []userListEntry `json:"users"` } if err = json.Unmarshal(body, &userList); err != nil {