github.com/wanddynosios/cli@v7.1.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/servicebrokerstub"
     7  
     8  	"code.cloudfoundry.org/cli/integration/helpers"
     9  	. "github.com/onsi/ginkgo"
    10  	. "github.com/onsi/gomega"
    11  	. "github.com/onsi/gomega/gbytes"
    12  	. "github.com/onsi/gomega/gexec"
    13  )
    14  
    15  var _ = Describe("bind-route-service command", func() {
    16  	Describe("help", func() {
    17  		It("includes a description of the options", func() {
    18  			session := helpers.CF("help", "bind-route-service")
    19  			Eventually(session).Should(Say("NAME:"))
    20  			Eventually(session).Should(Say("bind-route-service - Bind a service instance to an HTTP route"))
    21  			Eventually(session).Should(Say("USAGE:"))
    22  			Eventually(session).Should(Say(regexp.QuoteMeta("cf bind-route-service DOMAIN [--hostname HOSTNAME] [--path PATH] SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]")))
    23  			Eventually(session).Should(Say("EXAMPLES:"))
    24  			Eventually(session).Should(Say(regexp.QuoteMeta("cf bind-route-service example.com --hostname myapp --path foo myratelimiter")))
    25  			Eventually(session).Should(Say(regexp.QuoteMeta("cf bind-route-service example.com myratelimiter -c file.json")))
    26  			Eventually(session).Should(Say(regexp.QuoteMeta(`cf bind-route-service example.com myratelimiter -c '{"valid":"json"}'`)))
    27  			Eventually(session).Should(Say(regexp.QuoteMeta(`In Windows PowerShell use double-quoted, escaped JSON: "{\"valid\":\"json\"}"`)))
    28  			Eventually(session).Should(Say(regexp.QuoteMeta(`In Windows Command Line use single-quoted, escaped JSON: '{\"valid\":\"json\"}'`)))
    29  			Eventually(session).Should(Say("ALIAS:"))
    30  			Eventually(session).Should(Say("brs"))
    31  			Eventually(session).Should(Say("OPTIONS:"))
    32  			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.`))
    33  			Eventually(session).Should(Say(`--hostname, -n\s+Hostname used in combination with DOMAIN to specify the route to bind`))
    34  			Eventually(session).Should(Say(`--path\s+Path used in combination with HOSTNAME and DOMAIN to specify the route to bind`))
    35  			Eventually(session).Should(Say(`SEE ALSO:`))
    36  			Eventually(session).Should(Say(`routes, services`))
    37  			Eventually(session).Should(Exit(0))
    38  		})
    39  	})
    40  
    41  	Describe("Targeted space requirements", func() {
    42  		Context("when an org or space is not targeted", func() {
    43  			It("display an error that no org or space is targeted", func() {
    44  				helpers.LoginCF()
    45  				session := helpers.CF("bind-route-service", "www.example.org", "myInstance")
    46  				Eventually(session).Should(Say("No org and space targeted, use 'cf target -o ORG -s SPACE' to target an org and space"))
    47  			})
    48  		})
    49  
    50  		Context("when an org or space is targeted", func() {
    51  			var (
    52  				orgName             string
    53  				spaceName           string
    54  				domain              string
    55  				host                string
    56  				serviceInstanceName string
    57  				broker              *servicebrokerstub.ServiceBrokerStub
    58  			)
    59  
    60  			BeforeEach(func() {
    61  				orgName = helpers.NewOrgName()
    62  				spaceName = helpers.NewSpaceName()
    63  				host = helpers.PrefixedRandomName("host")
    64  
    65  				helpers.SetupCF(orgName, spaceName)
    66  				domain = helpers.DefaultSharedDomain()
    67  
    68  				serviceInstanceName = helpers.PrefixedRandomName("instance")
    69  				broker = servicebrokerstub.New()
    70  				broker.Services[0].Requires = []string{"route_forwarding"}
    71  				broker.EnableServiceAccess()
    72  
    73  				Eventually(helpers.CF("create-service", broker.FirstServiceOfferingName(), broker.FirstServicePlanName(), serviceInstanceName)).Should(Exit(0))
    74  				Eventually(helpers.CF("create-route", spaceName, domain, "--hostname", host)).Should(Exit(0))
    75  			})
    76  
    77  			AfterEach(func() {
    78  				broker.Forget()
    79  				helpers.QuickDeleteOrg(orgName)
    80  			})
    81  
    82  			It("succeeds", func() {
    83  				session := helpers.CF("bind-route-service", domain, serviceInstanceName, "--hostname", host)
    84  				Eventually(session).Should(Say("OK"))
    85  			})
    86  		})
    87  	})
    88  })