MCPcopy Index your code
hub / github.com/cloudfoundry/cli / GetUsersV3

Function GetUsersV3

integration/helpers/user.go:61–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

59}
60
61func GetUsersV3() []User {
62 var userPagesResponse struct {
63 Pagination struct {
64 NextURL *string `json:"next_url"`
65 } `json:"pagination"`
66 Resources []struct {
67 GUID string `json:"guid"`
68 Origin string `json:"origin"`
69 Username string `json:"username"`
70 } `json:"resources"`
71 }
72
73 var allUsers []User
74 nextURL := "/v3/users?per_page=50"
75
76 for {
77 session := CF("curl", nextURL)
78 Eventually(session).Should(Exit(0))
79
80 err := json.Unmarshal(session.Out.Contents(), &userPagesResponse)
81 Expect(err).NotTo(HaveOccurred())
82 for _, resource := range userPagesResponse.Resources {
83 allUsers = append(allUsers, User{
84 Origin: resource.Origin,
85 Username: resource.Username,
86 })
87 }
88
89 if userPagesResponse.Pagination.NextURL == nil {
90 break
91 }
92 nextURL = *userPagesResponse.Pagination.NextURL
93 }
94
95 return allUsers
96}
97
98// CreateUser creates a user with a random username and password and returns both.
99func CreateUser() (string, string) {

Callers 1

Calls 1

CFFunction · 0.85

Tested by

no test coverage detected