github.com/nimakaviani/cli@v6.37.1-0.20180619223813-e734901a73fa+incompatible/integration/global/service_command_test.go (about)

     1  package global
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccversion"
     5  	"code.cloudfoundry.org/cli/integration/helpers"
     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 command", func() {
    13  	var serviceInstanceName string
    14  
    15  	BeforeEach(func() {
    16  		serviceInstanceName = helpers.PrefixedRandomName("SI")
    17  	})
    18  
    19  	Describe("help", func() {
    20  		Context("when --help flag is set", func() {
    21  			It("displays command usage to output", func() {
    22  				session := helpers.CF("service", "--help")
    23  				Eventually(session).Should(Say("NAME:"))
    24  				Eventually(session).Should(Say("\\s+service - Show service instance info"))
    25  				Eventually(session).Should(Say("USAGE:"))
    26  				Eventually(session).Should(Say("\\s+cf service SERVICE_INSTANCE"))
    27  				Eventually(session).Should(Say("OPTIONS:"))
    28  				Eventually(session).Should(Say("\\s+\\-\\-guid\\s+Retrieve and display the given service's guid\\. All other output for the service is suppressed\\."))
    29  				Eventually(session).Should(Say("SEE ALSO:"))
    30  				Eventually(session).Should(Say("\\s+bind-service, rename-service, update-service"))
    31  				Eventually(session).Should(Exit(0))
    32  			})
    33  		})
    34  	})
    35  
    36  	Context("when the environment is not setup correctly", func() {
    37  		It("fails with the appropriate errors", func() {
    38  			helpers.CheckEnvironmentTargetedCorrectly(true, true, ReadOnlyOrg, "service", "some-service")
    39  		})
    40  	})
    41  
    42  	Context("when an api is targeted, the user is logged in, and an org and space are targeted", func() {
    43  		var (
    44  			orgName   string
    45  			spaceName string
    46  			userName  string
    47  		)
    48  
    49  		BeforeEach(func() {
    50  			orgName = helpers.NewOrgName()
    51  			spaceName = helpers.NewSpaceName()
    52  			helpers.SetupCF(orgName, spaceName)
    53  
    54  			userName, _ = helpers.GetCredentials()
    55  		})
    56  
    57  		AfterEach(func() {
    58  			helpers.QuickDeleteOrg(orgName)
    59  		})
    60  
    61  		Context("when the service instance does not exist", func() {
    62  			It("returns an error and exits 1", func() {
    63  				session := helpers.CF("service", serviceInstanceName)
    64  				Eventually(session).Should(Say("Showing info of service %s in org %s / space %s as %s", serviceInstanceName, orgName, spaceName, userName))
    65  				Eventually(session).Should(Say(""))
    66  				Eventually(session).Should(Say("FAILED"))
    67  				Eventually(session.Err).Should(Say("Service instance %s not found", serviceInstanceName))
    68  				Eventually(session).Should(Exit(1))
    69  			})
    70  		})
    71  
    72  		Context("when the service instance belongs to this space", func() {
    73  			Context("when the service instance is a user provided service instance", func() {
    74  				BeforeEach(func() {
    75  					Eventually(helpers.CF("create-user-provided-service", serviceInstanceName)).Should(Exit(0))
    76  				})
    77  
    78  				AfterEach(func() {
    79  					Eventually(helpers.CF("delete-service", serviceInstanceName, "-f")).Should(Exit(0))
    80  				})
    81  
    82  				Context("when the --guid flag is provided", func() {
    83  					It("displays the service instance GUID", func() {
    84  						session := helpers.CF("service", serviceInstanceName, "--guid")
    85  						Consistently(session).ShouldNot(Say("Showing info of service %s in org %s / space %s as %s", serviceInstanceName, orgName, spaceName, userName))
    86  						Eventually(session).Should(Say(helpers.UserProvidedServiceInstanceGUID(serviceInstanceName)))
    87  						Eventually(session).Should(Exit(0))
    88  					})
    89  				})
    90  
    91  				Context("when no apps are bound to the service instance", func() {
    92  					It("displays service instance info", func() {
    93  						session := helpers.CF("service", serviceInstanceName)
    94  						Eventually(session).Should(Say("Showing info of service %s in org %s / space %s as %s", serviceInstanceName, orgName, spaceName, userName))
    95  						Eventually(session).Should(Say(""))
    96  						Eventually(session).Should(Say("name:\\s+%s", serviceInstanceName))
    97  						Eventually(session).Should(Say("service:\\s+user-provided"))
    98  						Eventually(session).Should(Say(""))
    99  						Eventually(session).Should(Say("There are no bound apps for this service."))
   100  						Eventually(session).Should(Say(""))
   101  						Eventually(session).Should(Exit(0))
   102  					})
   103  				})
   104  
   105  				Context("when apps are bound to the service instance", func() {
   106  					var (
   107  						appName1 string
   108  						appName2 string
   109  					)
   110  
   111  					BeforeEach(func() {
   112  						appName1 = helpers.PrefixedRandomName("1-INTEGRATION-APP")
   113  						appName2 = helpers.PrefixedRandomName("2-INTEGRATION-APP")
   114  
   115  						helpers.WithHelloWorldApp(func(appDir string) {
   116  							Eventually(helpers.CF("push", appName1, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0))
   117  							Eventually(helpers.CF("push", appName2, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0))
   118  						})
   119  					})
   120  
   121  					AfterEach(func() {
   122  						Eventually(helpers.CF("delete", appName1, "-f")).Should(Exit(0))
   123  						Eventually(helpers.CF("delete", appName2, "-f")).Should(Exit(0))
   124  					})
   125  
   126  					Context("when the service bindings do not have binding names", func() {
   127  						BeforeEach(func() {
   128  							Eventually(helpers.CF("bind-service", appName1, serviceInstanceName)).Should(Exit(0))
   129  							Eventually(helpers.CF("bind-service", appName2, serviceInstanceName)).Should(Exit(0))
   130  						})
   131  
   132  						AfterEach(func() {
   133  							Eventually(helpers.CF("unbind-service", appName1, serviceInstanceName)).Should(Exit(0))
   134  							Eventually(helpers.CF("unbind-service", appName2, serviceInstanceName)).Should(Exit(0))
   135  						})
   136  
   137  						It("displays service instance info", func() {
   138  							session := helpers.CF("service", serviceInstanceName)
   139  							Eventually(session).Should(Say("Showing info of service %s in org %s / space %s as %s", serviceInstanceName, orgName, spaceName, userName))
   140  							Eventually(session).Should(Say(""))
   141  							Eventually(session).Should(Say("name:\\s+%s", serviceInstanceName))
   142  							Eventually(session).Should(Say("service:\\s+user-provided"))
   143  							Eventually(session).Should(Say(""))
   144  							Eventually(session).Should(Say("bound apps:"))
   145  							Eventually(session).Should(Say("name\\s+binding name"))
   146  							Eventually(session).Should(Say(appName1))
   147  							Eventually(session).Should(Say(appName2))
   148  
   149  							Eventually(session).Should(Exit(0))
   150  						})
   151  					})
   152  
   153  					Context("when the service bindings have binding names", func() {
   154  						var (
   155  							bindingName1 string
   156  							bindingName2 string
   157  						)
   158  
   159  						BeforeEach(func() {
   160  							helpers.SkipIfVersionLessThan(ccversion.MinVersionBindingNameV2)
   161  							bindingName1 = helpers.PrefixedRandomName("BINDING-NAME")
   162  							bindingName2 = helpers.PrefixedRandomName("BINDING-NAME")
   163  							Eventually(helpers.CF("bind-service", appName1, serviceInstanceName, "--binding-name", bindingName1)).Should(Exit(0))
   164  							Eventually(helpers.CF("bind-service", appName2, serviceInstanceName, "--binding-name", bindingName2)).Should(Exit(0))
   165  						})
   166  
   167  						AfterEach(func() {
   168  							Eventually(helpers.CF("unbind-service", appName1, serviceInstanceName)).Should(Exit(0))
   169  							Eventually(helpers.CF("unbind-service", appName2, serviceInstanceName)).Should(Exit(0))
   170  						})
   171  
   172  						It("displays service instance info", func() {
   173  							session := helpers.CF("service", serviceInstanceName)
   174  							Eventually(session).Should(Say("Showing info of service %s in org %s / space %s as %s", serviceInstanceName, orgName, spaceName, userName))
   175  							Eventually(session).Should(Say(""))
   176  							Eventually(session).Should(Say("name:\\s+%s", serviceInstanceName))
   177  							Eventually(session).Should(Say("service:\\s+user-provided"))
   178  							Eventually(session).Should(Say(""))
   179  							Eventually(session).Should(Say("bound apps:"))
   180  							Eventually(session).Should(Say("name\\s+binding name"))
   181  							Eventually(session).Should(Say("%s\\s+%s", appName1, bindingName1))
   182  							Eventually(session).Should(Say("%s\\s+%s", appName2, bindingName2))
   183  							Eventually(session).Should(Say(""))
   184  							Eventually(session).Should(Exit(0))
   185  						})
   186  					})
   187  				})
   188  
   189  				Context("when we update the user provided service instance with tags", func() {
   190  					BeforeEach(func() {
   191  						helpers.SkipIfVersionLessThan(ccversion.MinVersionUserProvidedServiceTagsV2)
   192  						Eventually(helpers.CF("update-user-provided-service", serviceInstanceName,
   193  							"-t", "foo, bar")).Should(Exit(0))
   194  					})
   195  
   196  					It("displays service instance info", func() {
   197  						session := helpers.CF("service", serviceInstanceName)
   198  						Eventually(session).Should(Say("Showing info of service %s in org %s / space %s as %s", serviceInstanceName, orgName, spaceName, userName))
   199  						Eventually(session).Should(Say("tags:\\s+foo, bar"))
   200  						Eventually(session).Should(Exit(0))
   201  					})
   202  				})
   203  
   204  			})
   205  
   206  			Context("when a user-provided service instance is created with tags", func() {
   207  				BeforeEach(func() {
   208  					helpers.SkipIfVersionLessThan(ccversion.MinVersionUserProvidedServiceTagsV2)
   209  					Eventually(helpers.CF("create-user-provided-service", serviceInstanceName, "-t", "database, email")).Should(Exit(0))
   210  				})
   211  
   212  				It("displays tag info", func() {
   213  					session := helpers.CF("service", serviceInstanceName)
   214  					Eventually(session).Should(Say("Showing info of service %s in org %s / space %s as %s", serviceInstanceName, orgName, spaceName, userName))
   215  					Eventually(session).Should(Say("tags:\\s+database, email"))
   216  					Eventually(session).Should(Exit(0))
   217  				})
   218  			})
   219  
   220  			Context("when the service instance is a managed service instance", func() {
   221  				var (
   222  					domain      string
   223  					service     string
   224  					servicePlan string
   225  					broker      helpers.ServiceBroker
   226  				)
   227  
   228  				BeforeEach(func() {
   229  					domain = helpers.DefaultSharedDomain()
   230  					service = helpers.PrefixedRandomName("SERVICE")
   231  					servicePlan = helpers.PrefixedRandomName("SERVICE-PLAN")
   232  
   233  					broker = helpers.NewServiceBroker(helpers.NewServiceBrokerName(), helpers.NewAssets().ServiceBroker, domain, service, servicePlan)
   234  					broker.Push()
   235  					broker.Configure(true)
   236  					broker.Create()
   237  
   238  					Eventually(helpers.CF("enable-service-access", service)).Should(Exit(0))
   239  					Eventually(helpers.CF("create-service", service, servicePlan, serviceInstanceName, "-t", "database, email")).Should(Exit(0))
   240  				})
   241  
   242  				AfterEach(func() {
   243  					Eventually(helpers.CF("delete-service", serviceInstanceName, "-f")).Should(Exit(0))
   244  					broker.Destroy()
   245  				})
   246  
   247  				Context("when the --guid flag is provided", func() {
   248  					It("displays the service instance GUID", func() {
   249  						session := helpers.CF("service", serviceInstanceName, "--guid")
   250  						Consistently(session).ShouldNot(Say("Showing info of service %s in org %s / space %s as %s", serviceInstanceName, orgName, spaceName, userName))
   251  						Eventually(session).Should(Say(helpers.ManagedServiceInstanceGUID(serviceInstanceName)))
   252  						Eventually(session).Should(Exit(0))
   253  					})
   254  				})
   255  
   256  				Context("when apps are bound to the service instance", func() {
   257  					var (
   258  						appName1 string
   259  						appName2 string
   260  					)
   261  
   262  					BeforeEach(func() {
   263  						appName1 = helpers.PrefixedRandomName("1-INTEGRATION-APP")
   264  						appName2 = helpers.PrefixedRandomName("2-INTEGRATION-APP")
   265  
   266  						helpers.WithHelloWorldApp(func(appDir string) {
   267  							Eventually(helpers.CF("push", appName1, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0))
   268  							Eventually(helpers.CF("push", appName2, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0))
   269  						})
   270  					})
   271  
   272  					AfterEach(func() {
   273  						Eventually(helpers.CF("delete", appName1, "-f")).Should(Exit(0))
   274  						Eventually(helpers.CF("delete", appName2, "-f")).Should(Exit(0))
   275  					})
   276  
   277  					Context("when the service bindings do not have binding names", func() {
   278  						BeforeEach(func() {
   279  							Eventually(helpers.CF("bind-service", appName1, serviceInstanceName)).Should(Exit(0))
   280  							Eventually(helpers.CF("bind-service", appName2, serviceInstanceName)).Should(Exit(0))
   281  						})
   282  
   283  						AfterEach(func() {
   284  							Eventually(helpers.CF("unbind-service", appName1, serviceInstanceName)).Should(Exit(0))
   285  							Eventually(helpers.CF("unbind-service", appName2, serviceInstanceName)).Should(Exit(0))
   286  						})
   287  
   288  						It("displays service instance info", func() {
   289  							session := helpers.CF("service", serviceInstanceName)
   290  							Eventually(session).Should(Say("Showing info of service %s in org %s / space %s as %s\\.\\.\\.", serviceInstanceName, orgName, spaceName, userName))
   291  							Eventually(session).Should(Say("\n\n"))
   292  							Eventually(session).Should(Say("name:\\s+%s", serviceInstanceName))
   293  							Consistently(session).ShouldNot(Say("shared from:"))
   294  							Eventually(session).Should(Say("service:\\s+%s", service))
   295  							Eventually(session).Should(Say("tags:\\s+database, email"))
   296  							Eventually(session).Should(Say("plan:\\s+%s", servicePlan))
   297  							Eventually(session).Should(Say("description:\\s+fake service"))
   298  							Eventually(session).Should(Say("documentation:"))
   299  							Eventually(session).Should(Say("dashboard:\\s+http://example\\.com"))
   300  							Eventually(session).Should(Say("\n\n"))
   301  							Eventually(session).Should(Say("bound apps:"))
   302  							Eventually(session).Should(Say("name\\s+binding name"))
   303  							Eventually(session).Should(Say(appName1))
   304  							Eventually(session).Should(Say(appName2))
   305  							Eventually(session).Should(Say("\n\n"))
   306  							Consistently(session).ShouldNot(Say("shared with spaces:"))
   307  							Eventually(session).Should(Say("Showing status of last operation from service %s\\.\\.\\.", serviceInstanceName))
   308  							Eventually(session).Should(Say("\n\n"))
   309  							Eventually(session).Should(Say("status:\\s+create succeeded"))
   310  							Eventually(session).Should(Say("message:"))
   311  							Eventually(session).Should(Say("started:\\s+\\d{4}-[01]\\d-[0-3]\\dT[0-2][0-9]:[0-5]\\d:[0-5]\\dZ"))
   312  							Eventually(session).Should(Say("updated:\\s+\\d{4}-[01]\\d-[0-3]\\dT[0-2][0-9]:[0-5]\\d:[0-5]\\dZ"))
   313  
   314  							Eventually(session).Should(Exit(0))
   315  						})
   316  					})
   317  
   318  					Context("when the service bindings have binding names", func() {
   319  						var (
   320  							bindingName1 string
   321  							bindingName2 string
   322  						)
   323  
   324  						BeforeEach(func() {
   325  							helpers.SkipIfVersionLessThan(ccversion.MinVersionBindingNameV2)
   326  							bindingName1 = helpers.PrefixedRandomName("BINDING-NAME")
   327  							bindingName2 = helpers.PrefixedRandomName("BINDING-NAME")
   328  							Eventually(helpers.CF("bind-service", appName1, serviceInstanceName, "--binding-name", bindingName1)).Should(Exit(0))
   329  							Eventually(helpers.CF("bind-service", appName2, serviceInstanceName, "--binding-name", bindingName2)).Should(Exit(0))
   330  						})
   331  
   332  						AfterEach(func() {
   333  							Eventually(helpers.CF("unbind-service", appName1, serviceInstanceName)).Should(Exit(0))
   334  							Eventually(helpers.CF("unbind-service", appName2, serviceInstanceName)).Should(Exit(0))
   335  						})
   336  
   337  						It("displays service instance info", func() {
   338  							session := helpers.CF("service", serviceInstanceName)
   339  							Eventually(session).Should(Say("Showing info of service %s in org %s / space %s as %s\\.\\.\\.", serviceInstanceName, orgName, spaceName, userName))
   340  							Eventually(session).Should(Say("\n\n"))
   341  							Eventually(session).Should(Say("name:\\s+%s", serviceInstanceName))
   342  							Consistently(session).ShouldNot(Say("shared from:"))
   343  							Eventually(session).Should(Say("service:\\s+%s", service))
   344  							Eventually(session).Should(Say("tags:\\s+database, email"))
   345  							Eventually(session).Should(Say("plan:\\s+%s", servicePlan))
   346  							Eventually(session).Should(Say("description:\\s+fake service"))
   347  							Eventually(session).Should(Say("documentation:"))
   348  							Eventually(session).Should(Say("dashboard:\\s+http://example\\.com"))
   349  							Eventually(session).Should(Say("\n\n"))
   350  							Eventually(session).Should(Say("bound apps:"))
   351  							Eventually(session).Should(Say("name\\s+binding name"))
   352  							Eventually(session).Should(Say("%s\\s+%s", appName1, bindingName1))
   353  							Eventually(session).Should(Say("%s\\s+%s", appName2, bindingName2))
   354  							Eventually(session).Should(Say("\n\n"))
   355  							Consistently(session).ShouldNot(Say("shared with spaces:"))
   356  							Eventually(session).Should(Say("Showing status of last operation from service %s\\.\\.\\.", serviceInstanceName))
   357  							Eventually(session).Should(Say("\n\n"))
   358  							Eventually(session).Should(Say("status:\\s+create succeeded"))
   359  							Eventually(session).Should(Say("message:"))
   360  							Eventually(session).Should(Say("started:\\s+\\d{4}-[01]\\d-[0-3]\\dT[0-2][0-9]:[0-5]\\d:[0-5]\\dZ"))
   361  							Eventually(session).Should(Say("updated:\\s+\\d{4}-[01]\\d-[0-3]\\dT[0-2][0-9]:[0-5]\\d:[0-5]\\dZ"))
   362  
   363  							Eventually(session).Should(Exit(0))
   364  						})
   365  					})
   366  				})
   367  			})
   368  		})
   369  	})
   370  
   371  	Context("service instance sharing when there are multiple spaces", func() {
   372  		var (
   373  			orgName         string
   374  			sourceSpaceName string
   375  
   376  			service     string
   377  			servicePlan string
   378  			broker      helpers.ServiceBroker
   379  		)
   380  
   381  		BeforeEach(func() {
   382  			helpers.SkipIfVersionLessThan(ccversion.MinVersionShareServiceV3)
   383  			orgName = helpers.NewOrgName()
   384  			sourceSpaceName = helpers.NewSpaceName()
   385  			helpers.SetupCF(orgName, sourceSpaceName)
   386  
   387  			domain := helpers.DefaultSharedDomain()
   388  			service = helpers.PrefixedRandomName("SERVICE")
   389  			servicePlan = helpers.PrefixedRandomName("SERVICE-PLAN")
   390  			broker = helpers.NewServiceBroker(helpers.NewServiceBrokerName(), helpers.NewAssets().ServiceBroker, domain, service, servicePlan)
   391  			broker.Push()
   392  			broker.Configure(true)
   393  			broker.Create()
   394  
   395  			Eventually(helpers.CF("enable-service-access", service)).Should(Exit(0))
   396  			Eventually(helpers.CF("create-service", service, servicePlan, serviceInstanceName)).Should(Exit(0))
   397  		})
   398  
   399  		AfterEach(func() {
   400  			// need to login as admin
   401  			helpers.LoginCF()
   402  			helpers.TargetOrgAndSpace(orgName, sourceSpaceName)
   403  			broker.Destroy()
   404  			helpers.QuickDeleteOrg(orgName)
   405  		})
   406  
   407  		Context("service has no type of shares", func() {
   408  			Context("when the service is shareable", func() {
   409  				It("should not display shared from or shared with information, but DOES display not currently shared info", func() {
   410  					session := helpers.CF("service", serviceInstanceName)
   411  					Eventually(session).Should(Say("This service is not currently shared."))
   412  					Eventually(session).Should(Exit(0))
   413  				})
   414  			})
   415  		})
   416  
   417  		Context("service is shared between two spaces", func() {
   418  			var (
   419  				targetSpaceName string
   420  			)
   421  
   422  			BeforeEach(func() {
   423  				targetSpaceName = helpers.NewSpaceName()
   424  				helpers.CreateOrgAndSpace(orgName, targetSpaceName)
   425  				helpers.TargetOrgAndSpace(orgName, sourceSpaceName)
   426  				Eventually(helpers.CF("share-service", serviceInstanceName, "-s", targetSpaceName)).Should(Exit(0))
   427  			})
   428  
   429  			Context("when the user is targeted to the source space", func() {
   430  				Context("when there are externally bound apps to the service", func() {
   431  					BeforeEach(func() {
   432  						helpers.TargetOrgAndSpace(orgName, targetSpaceName)
   433  						helpers.WithHelloWorldApp(func(appDir string) {
   434  							appName1 := helpers.NewAppName()
   435  							Eventually(helpers.CF("push", appName1, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0))
   436  							Eventually(helpers.CF("bind-service", appName1, serviceInstanceName)).Should(Exit(0))
   437  
   438  							appName2 := helpers.NewAppName()
   439  							Eventually(helpers.CF("push", appName2, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0))
   440  							Eventually(helpers.CF("bind-service", appName2, serviceInstanceName)).Should(Exit(0))
   441  						})
   442  						helpers.TargetOrgAndSpace(orgName, sourceSpaceName)
   443  					})
   444  
   445  					It("should display the number of bound apps next to the target space name", func() {
   446  						session := helpers.CF("service", serviceInstanceName)
   447  						Eventually(session).Should(Say("shared with spaces:"))
   448  						Eventually(session).Should(Say("org\\s+space\\s+bindings"))
   449  						Eventually(session).Should(Say("%s\\s+%s\\s+2", orgName, targetSpaceName))
   450  						Eventually(session).Should(Exit(0))
   451  					})
   452  				})
   453  
   454  				Context("when there are no externally bound apps to the service", func() {
   455  					It("should NOT display the number of bound apps next to the target space name", func() {
   456  						session := helpers.CF("service", serviceInstanceName)
   457  						Eventually(session).Should(Say("shared with spaces:"))
   458  						Eventually(session).Should(Say("org\\s+space\\s+bindings"))
   459  						Eventually(session).Should(Exit(0))
   460  					})
   461  				})
   462  
   463  				Context("when the service is no longer shareable", func() {
   464  					Context("due to global settings", func() {
   465  						BeforeEach(func() {
   466  							helpers.DisableFeatureFlag("service_instance_sharing")
   467  						})
   468  
   469  						AfterEach(func() {
   470  							helpers.EnableFeatureFlag("service_instance_sharing")
   471  						})
   472  
   473  						It("should display that the service instance feature flag is disabled", func() {
   474  							session := helpers.CF("service", serviceInstanceName)
   475  							Eventually(session).Should(Say(`The "service_instance_sharing" feature flag is disabled for this Cloud Foundry platform.`))
   476  							Eventually(session).Should(Exit(0))
   477  						})
   478  					})
   479  
   480  					Context("due to service broker settings", func() {
   481  						BeforeEach(func() {
   482  							broker.Configure(false)
   483  							broker.Update()
   484  						})
   485  
   486  						It("should display that service instance sharing is disabled for this service", func() {
   487  							session := helpers.CF("service", serviceInstanceName)
   488  							Eventually(session).Should(Say("Service instance sharing is disabled for this service."))
   489  							Eventually(session).Should(Exit(0))
   490  						})
   491  					})
   492  
   493  					Context("due to global settings AND service broker settings", func() {
   494  						BeforeEach(func() {
   495  							helpers.DisableFeatureFlag("service_instance_sharing")
   496  							broker.Configure(false)
   497  							broker.Update()
   498  						})
   499  
   500  						AfterEach(func() {
   501  							helpers.EnableFeatureFlag("service_instance_sharing")
   502  						})
   503  
   504  						It("should display that service instance sharing is disabled for this service", func() {
   505  							session := helpers.CF("service", serviceInstanceName)
   506  							Eventually(session).Should(Say(`The "service_instance_sharing" feature flag is disabled for this Cloud Foundry platform. Also, service instance sharing is disabled for this service.`))
   507  							Eventually(session).Should(Exit(0))
   508  						})
   509  					})
   510  				})
   511  			})
   512  
   513  			Context("when the user is targeted to the target space", func() {
   514  				var appName1, appName2 string
   515  
   516  				BeforeEach(func() {
   517  					// We test that the app names are listed in alphanumeric sort order
   518  					appName1 = helpers.PrefixedRandomName("2-INTEGRATION-APP")
   519  					appName2 = helpers.PrefixedRandomName("1-INTEGRATION-APP")
   520  					helpers.TargetOrgAndSpace(orgName, targetSpaceName)
   521  					helpers.WithHelloWorldApp(func(appDir string) {
   522  						Eventually(helpers.CF("push", appName1, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0))
   523  						Eventually(helpers.CF("bind-service", appName1, serviceInstanceName)).Should(Exit(0))
   524  
   525  						Eventually(helpers.CF("push", appName2, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0))
   526  						Eventually(helpers.CF("bind-service", appName2, serviceInstanceName)).Should(Exit(0))
   527  					})
   528  				})
   529  
   530  				Context("when there are bound apps to the service with no binding names", func() {
   531  					It("should display the bound apps in alphanumeric sort order", func() {
   532  						session := helpers.CF("service", serviceInstanceName)
   533  						Eventually(session).Should(Say("shared from org/space:\\s+%s / %s", orgName, sourceSpaceName))
   534  						Eventually(session).Should(Say("\n\n"))
   535  						Eventually(session).Should(Say("bound apps:"))
   536  						Eventually(session).Should(Say("name\\s+binding name"))
   537  						Eventually(session).Should(Say(appName2))
   538  						Eventually(session).Should(Say(appName1))
   539  						Eventually(session).Should(Exit(0))
   540  					})
   541  				})
   542  			})
   543  		})
   544  	})
   545  })