Example #1
0
func TestUsersList(t *testing.T) {
	client, err := clients.NewIdentityV2AdminClient()
	if err != nil {
		t.Fatalf("Unable to obtain an identity client: %v", err)
	}

	allPages, err := users.List(client).AllPages()
	if err != nil {
		t.Fatalf("Unable to list users: %v", err)
	}

	allUsers, err := users.ExtractUsers(allPages)
	if err != nil {
		t.Fatalf("Unable to extract users: %v", err)
	}

	for _, user := range allUsers {
		PrintUser(t, &user)
	}
}
Example #2
0
func TestList(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()

	MockListUserResponse(t)

	count := 0

	err := users.List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
		count++
		actual, err := users.ExtractUsers(page)
		th.AssertNoErr(t, err)

		expected := []users.User{
			{
				ID:       "u1000",
				Name:     "John Smith",
				Username: "******",
				Email:    "*****@*****.**",
				Enabled:  true,
				TenantID: "12345",
			},
			{
				ID:       "u1001",
				Name:     "Jane Smith",
				Username: "******",
				Email:    "*****@*****.**",
				Enabled:  true,
				TenantID: "12345",
			},
		}
		th.CheckDeepEquals(t, expected, actual)
		return true, nil
	})
	th.AssertNoErr(t, err)
	th.AssertEquals(t, 1, count)
}