github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/integration/v6/isolated/service_brokers_command_test.go (about)

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