github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/integration/v7/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("environment is not set up", func() { 29 It("displays an error and exits 1", func() { 30 helpers.CheckEnvironmentTargetedCorrectly(false, false, ReadOnlyOrg, "service-brokers") 31 }) 32 }) 33 34 When("the environment is set up correctly", func() { 35 var ( 36 username string 37 session *Session 38 ) 39 40 BeforeEach(func() { 41 username = helpers.LoginCF() 42 }) 43 44 JustBeforeEach(func() { 45 session = helpers.CF("service-brokers") 46 }) 47 48 When("there is a broker", func() { 49 var ( 50 orgName string 51 spaceName string 52 broker *fakeservicebroker.FakeServiceBroker 53 ) 54 55 BeforeEach(func() { 56 orgName = helpers.NewOrgName() 57 spaceName = helpers.NewSpaceName() 58 helpers.SetupCF(orgName, spaceName) 59 broker = fakeservicebroker.New().EnsureBrokerIsAvailable() 60 }) 61 62 AfterEach(func() { 63 broker.Destroy() 64 helpers.QuickDeleteOrg(orgName) 65 }) 66 67 It("prints a table of service brokers", func() { 68 Eventually(session).Should(Say("Getting service brokers as %s...", username)) 69 Eventually(session).Should(Say(`name\s+url\s+status`)) 70 Eventually(session).Should(Say(`%s\s+%s\s+%s`, broker.Name(), broker.URL(), "available")) 71 Eventually(session).Should(Exit(0)) 72 }) 73 74 When("user is not authorized to see the brokers", func() { 75 var unprivilegedUsername string 76 77 BeforeEach(func() { 78 var password string 79 unprivilegedUsername, password = helpers.CreateUser() 80 helpers.LogoutCF() 81 helpers.LoginAs(unprivilegedUsername, password) 82 }) 83 84 AfterEach(func() { 85 helpers.LoginCF() 86 helpers.TargetOrgAndSpace(orgName, spaceName) 87 helpers.DeleteUser(unprivilegedUsername) 88 }) 89 90 It("says that no service brokers were found", func() { 91 Eventually(session).Should(Say("Getting service brokers as")) 92 Eventually(session).Should(Say("No service brokers found")) 93 Eventually(session).Should(Exit(0)) 94 }) 95 }) 96 }) 97 98 When("the broker was created via the V2 API", func() { 99 var ( 100 orgName string 101 spaceName string 102 broker *fakeservicebroker.FakeServiceBroker 103 ) 104 105 BeforeEach(func() { 106 orgName = helpers.NewOrgName() 107 spaceName = helpers.NewSpaceName() 108 helpers.SetupCF(orgName, spaceName) 109 broker = fakeservicebroker.New() 110 broker.EnsureRegisteredViaV2() 111 }) 112 113 AfterEach(func() { 114 broker.Destroy() 115 helpers.QuickDeleteOrg(orgName) 116 }) 117 118 It("shows as 'available'", func() { 119 Eventually(session).Should(Say("Getting service brokers as %s...", username)) 120 Eventually(session).Should(Say(`name\s+url\s+status`)) 121 Eventually(session).Should(Say(`%s\s+%s\s+%s`, broker.Name(), broker.URL(), "available")) 122 Eventually(session).Should(Exit(0)) 123 }) 124 }) 125 }) 126 })