github.com/arunkumar7540/cli@v6.45.0+incompatible/integration/v6/isolated/bind_route_service_command_test.go (about) 1 package isolated 2 3 import ( 4 "regexp" 5 6 "code.cloudfoundry.org/cli/integration/helpers" 7 . "github.com/onsi/ginkgo" 8 . "github.com/onsi/gomega" 9 . "github.com/onsi/gomega/gbytes" 10 . "github.com/onsi/gomega/gexec" 11 ) 12 13 var _ = Describe("bind-route-service command", func() { 14 Describe("help", func() { 15 It("includes a description of the options", func() { 16 session := helpers.CF("help", "bind-route-service") 17 Eventually(session).Should(Say("NAME:")) 18 Eventually(session).Should(Say("bind-route-service - Bind a service instance to an HTTP route")) 19 Eventually(session).Should(Say("USAGE:")) 20 Eventually(session).Should(Say(regexp.QuoteMeta("cf bind-route-service DOMAIN [--hostname HOSTNAME] [--path PATH] SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]"))) 21 Eventually(session).Should(Say("EXAMPLES:")) 22 Eventually(session).Should(Say(regexp.QuoteMeta("cf bind-route-service example.com --hostname myapp --path foo myratelimiter"))) 23 Eventually(session).Should(Say(regexp.QuoteMeta("cf bind-route-service example.com myratelimiter -c file.json"))) 24 Eventually(session).Should(Say(regexp.QuoteMeta(`cf bind-route-service example.com myratelimiter -c '{"valid":"json"}'`))) 25 Eventually(session).Should(Say(regexp.QuoteMeta(`In Windows PowerShell use double-quoted, escaped JSON: "{\"valid\":\"json\"}"`))) 26 Eventually(session).Should(Say(regexp.QuoteMeta(`In Windows Command Line use single-quoted, escaped JSON: '{\"valid\":\"json\"}'`))) 27 Eventually(session).Should(Say("ALIAS:")) 28 Eventually(session).Should(Say("brs")) 29 Eventually(session).Should(Say("OPTIONS:")) 30 Eventually(session).Should(Say(`-c\s+Valid JSON object containing service-specific configuration parameters, provided inline or in a file\. For a list of supported configuration parameters, see documentation for the particular service offering.`)) 31 Eventually(session).Should(Say(`--hostname, -n\s+Hostname used in combination with DOMAIN to specify the route to bind`)) 32 Eventually(session).Should(Say(`--path\s+Path used in combination with HOSTNAME and DOMAIN to specify the route to bind`)) 33 Eventually(session).Should(Say(`SEE ALSO:`)) 34 Eventually(session).Should(Say(`routes, services`)) 35 Eventually(session).Should(Exit(0)) 36 }) 37 }) 38 39 Describe("Targeted space requirements", func() { 40 Context("when an org or space is not targeted", func() { 41 It("display an error that no org or space is targeted", func() { 42 helpers.LoginCF() 43 session := helpers.CF("bind-route-service", "www.example.org", "myInstance") 44 Eventually(session).Should(Say("No org and space targeted, use 'cf target -o ORG -s SPACE' to target an org and space")) 45 }) 46 }) 47 48 Context("when an org or space is targeted", func() { 49 var ( 50 orgName string 51 spaceName string 52 domain string 53 host string 54 serviceInstanceName string 55 ) 56 57 BeforeEach(func() { 58 orgName = helpers.NewOrgName() 59 spaceName = helpers.NewSpaceName() 60 host = helpers.PrefixedRandomName("host") 61 62 helpers.SetupCF(orgName, spaceName) 63 domain = helpers.DefaultSharedDomain() 64 65 serviceInstanceName = helpers.PrefixedRandomName("instance") 66 servicePlanName := "fake-plan" 67 serviceName := "fake-service" 68 broker := helpers.NewServiceBroker( 69 helpers.NewServiceBrokerName(), 70 helpers.NewAssets().ServiceBroker, 71 helpers.DefaultSharedDomain(), 72 serviceName, 73 servicePlanName, 74 ) 75 broker.Push() 76 broker.Service.Requires = `["route_forwarding"]` 77 broker.Configure(true) 78 broker.Create() 79 80 Eventually(helpers.CF("enable-service-access", serviceName)).Should(Exit(0)) 81 Eventually(helpers.CF("create-service", serviceName, servicePlanName, serviceInstanceName)).Should(Exit(0)) 82 Eventually(helpers.CF("create-route", spaceName, domain, "--hostname", host)).Should(Exit(0)) 83 }) 84 85 AfterEach(func() { 86 helpers.QuickDeleteOrg(orgName) 87 }) 88 89 It("succeeds", func() { 90 session := helpers.CF("bind-route-service", domain, serviceInstanceName, "--hostname", host) 91 Eventually(session).Should(Say("OK")) 92 }) 93 }) 94 }) 95 })