github.com/wanddynosios/cli@v7.1.0+incompatible/integration/v6/isolated/org_users_command_test.go (about)

     1  package isolated
     2  
     3  import (
     4  	. "github.com/onsi/ginkgo"
     5  	. "github.com/onsi/gomega"
     6  	. "github.com/onsi/gomega/gbytes"
     7  	. "github.com/onsi/gomega/gexec"
     8  
     9  	"code.cloudfoundry.org/cli/integration/helpers"
    10  )
    11  
    12  var _ = Describe("org-users command", func() {
    13  	When("the user is logged in", func() {
    14  		var (
    15  			orgName       string
    16  			adminUsername string
    17  		)
    18  
    19  		BeforeEach(func() {
    20  			adminUsername = helpers.LoginCF()
    21  			orgName = helpers.NewOrgName()
    22  			helpers.CreateOrg(orgName)
    23  		})
    24  
    25  		When("the target org has multiple users with different roles", func() {
    26  			var (
    27  				orgManagerUser1    string
    28  				orgManagerUser2    string
    29  				billingManagerUser string
    30  				orgAuditorUser     string
    31  			)
    32  
    33  			BeforeEach(func() {
    34  				orgManagerUser1, _ = helpers.CreateUserInOrgRole(orgName, "OrgManager")
    35  				orgManagerUser2, _ = helpers.CreateUserInOrgRole(orgName, "OrgManager")
    36  				billingManagerUser, _ = helpers.CreateUserInOrgRole(orgName, "BillingManager")
    37  				orgAuditorUser, _ = helpers.CreateUserInOrgRole(orgName, "OrgAuditor")
    38  			})
    39  
    40  			It("prints the users in the target org under their roles", func() {
    41  				session := helpers.CF("org-users", orgName)
    42  				Eventually(session).Should(Say("Getting users in org %s as %s", orgName, adminUsername))
    43  				Eventually(session).Should(Say("ORG MANAGER"))
    44  				Eventually(session).Should(Say(`\s+%s`, orgManagerUser1))
    45  				Eventually(session).Should(Say(`\s+%s`, orgManagerUser2))
    46  				Eventually(session).Should(Say("BILLING MANAGER"))
    47  				Eventually(session).Should(Say(`\s+%s`, billingManagerUser))
    48  				Eventually(session).Should(Say("ORG AUDITOR"))
    49  				Eventually(session).Should(Say(`\s+%s`, orgAuditorUser))
    50  				Eventually(session).Should(Exit(0))
    51  			})
    52  		})
    53  
    54  		When("the target org has a client-credentials user", func() {
    55  			var clientID string
    56  
    57  			BeforeEach(func() {
    58  				clientID, _ = helpers.SkipIfClientCredentialsNotSet()
    59  				Eventually(helpers.CF("set-org-role", clientID, orgName, "OrgManager", "--client")).Should(Exit(0))
    60  			})
    61  
    62  			It("prints the client-credentials user", func() {
    63  				session := helpers.CF("org-users", orgName)
    64  				Eventually(session).Should(Say("Getting users in org %s as %s", orgName, adminUsername))
    65  				Eventually(session).Should(Say("ORG MANAGER"))
    66  				Eventually(session).Should(Say(`\s+%s \(client\)`, clientID))
    67  				Eventually(session).Should(Say("BILLING MANAGER"))
    68  				Eventually(session).Should(Say(`\s+No BILLING MANAGER found`))
    69  				Eventually(session).Should(Say("ORG AUDITOR"))
    70  				Eventually(session).Should(Say(`\s+No ORG AUDITOR found`))
    71  				Eventually(session).Should(Exit(0))
    72  			})
    73  		})
    74  	})
    75  })