github.com/arunkumar7540/cli@v6.45.0+incompatible/integration/shared/isolated/service_brokers_command_test.go (about)

     1  package isolated
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/integration/helpers"
     5  	. "github.com/onsi/ginkgo"
     6  	. "github.com/onsi/gomega"
     7  	. "github.com/onsi/gomega/gbytes"
     8  	. "github.com/onsi/gomega/gexec"
     9  )
    10  
    11  var _ = Describe("service-brokers command", func() {
    12  	Describe("help", func() {
    13  		When("--help flag is set", func() {
    14  			It("Displays command usage to output", func() {
    15  				session := helpers.CF("service-brokers", "--help")
    16  				Eventually(session).Should(Say("NAME:"))
    17  				Eventually(session).Should(Say("service-brokers - List service brokers"))
    18  				Eventually(session).Should(Say("USAGE:"))
    19  				Eventually(session).Should(Say("cf service-brokers"))
    20  				Eventually(session).Should(Say("SEE ALSO:"))
    21  				Eventually(session).Should(Say("delete-service-broker, disable-service-access, enable-service-access"))
    22  				Eventually(session).Should(Exit(0))
    23  			})
    24  		})
    25  	})
    26  
    27  	When("environment is not set up", func() {
    28  		It("displays an error and exits 1", func() {
    29  			Skip("Unrefactored command is writing login errors to STDOUT; remove skip when refactored")
    30  			helpers.CheckEnvironmentTargetedCorrectly(false, false, ReadOnlyOrg, "service-brokers")
    31  		})
    32  	})
    33  
    34  	When("the environment is set up correctly", func() {
    35  		var (
    36  			session *Session
    37  		)
    38  
    39  		BeforeEach(func() {
    40  			helpers.LoginCF()
    41  		})
    42  
    43  		JustBeforeEach(func() {
    44  			session = helpers.CF("service-brokers")
    45  		})
    46  
    47  		When("there is a broker", func() {
    48  			var (
    49  				orgName string
    50  				broker  helpers.ServiceBroker
    51  			)
    52  
    53  			BeforeEach(func() {
    54  				orgName = helpers.NewOrgName()
    55  				spaceName := helpers.NewSpaceName()
    56  				helpers.SetupCF(orgName, spaceName)
    57  				serviceName := helpers.PrefixedRandomName("SERVICE")
    58  				servicePlan := helpers.PrefixedRandomName("SERVICE-PLAN")
    59  				domain := helpers.DefaultSharedDomain()
    60  				broker = helpers.CreateBroker(domain, serviceName, servicePlan)
    61  			})
    62  
    63  			AfterEach(func() {
    64  				helpers.QuickDeleteOrg(orgName)
    65  				broker.Delete()
    66  			})
    67  
    68  			It("prints a table of service brokers", func() {
    69  				Eventually(session).Should(Say("Getting service brokers as admin..."))
    70  				Eventually(session).Should(Say(`name\s+url`))
    71  				Eventually(session).Should(Say(`%s\s+%s`, broker.Name, broker.URL()))
    72  				Eventually(session).Should(Exit(0))
    73  			})
    74  
    75  			When("user is not authorized to see the brokers", func() {
    76  				var unprivilegedUsername string
    77  
    78  				BeforeEach(func() {
    79  					var password string
    80  					unprivilegedUsername, password = helpers.CreateUser()
    81  					helpers.LoginAs(unprivilegedUsername, password)
    82  				})
    83  
    84  				AfterEach(func() {
    85  					helpers.LoginCF()
    86  					helpers.DeleteUser(unprivilegedUsername)
    87  				})
    88  
    89  				It("says that no service brokers were found", func() {
    90  					Eventually(session).Should(Say("Getting service brokers as"))
    91  					Eventually(session).Should(Say("No service brokers found"))
    92  					Eventually(session).Should(Exit(0))
    93  				})
    94  			})
    95  		})
    96  	})
    97  })