github.com/arunkumar7540/cli@v6.45.0+incompatible/integration/shared/isolated/service_command_test.go (about) 1 package isolated 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 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 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 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 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 When("the service instance belongs to this space", func() { 73 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 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 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 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 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\s+status\s+message`)) 146 Eventually(session).Should(Say(appName1)) 147 Eventually(session).Should(Say(appName2)) 148 149 Eventually(session).Should(Exit(0)) 150 }) 151 }) 152 153 When("the service bindings have binding names", func() { 154 var ( 155 bindingName1 string 156 bindingName2 string 157 ) 158 159 BeforeEach(func() { 160 bindingName1 = helpers.PrefixedRandomName("BINDING-NAME") 161 bindingName2 = helpers.PrefixedRandomName("BINDING-NAME") 162 Eventually(helpers.CF("bind-service", appName1, serviceInstanceName, "--binding-name", bindingName1)).Should(Exit(0)) 163 Eventually(helpers.CF("bind-service", appName2, serviceInstanceName, "--binding-name", bindingName2)).Should(Exit(0)) 164 }) 165 166 AfterEach(func() { 167 Eventually(helpers.CF("unbind-service", appName1, serviceInstanceName)).Should(Exit(0)) 168 Eventually(helpers.CF("unbind-service", appName2, serviceInstanceName)).Should(Exit(0)) 169 }) 170 171 It("displays service instance info", func() { 172 session := helpers.CF("service", serviceInstanceName) 173 Eventually(session).Should(Say("Showing info of service %s in org %s / space %s as %s", serviceInstanceName, orgName, spaceName, userName)) 174 Eventually(session).Should(Say("")) 175 Eventually(session).Should(Say(`name:\s+%s`, serviceInstanceName)) 176 Eventually(session).Should(Say(`service:\s+user-provided`)) 177 Eventually(session).Should(Say("")) 178 Eventually(session).Should(Say("bound apps:")) 179 Eventually(session).Should(Say(`name\s+binding name\s+status\s+message`)) 180 Eventually(session).Should(Say(`%s\s+%s`, appName1, bindingName1)) 181 Eventually(session).Should(Say(`%s\s+%s`, appName2, bindingName2)) 182 Eventually(session).Should(Say("")) 183 Eventually(session).Should(Exit(0)) 184 }) 185 }) 186 }) 187 188 When("we update the user provided service instance with tags", func() { 189 BeforeEach(func() { 190 helpers.SkipIfVersionLessThan(ccversion.MinVersionUserProvidedServiceTagsV2) 191 Eventually(helpers.CF("update-user-provided-service", serviceInstanceName, 192 "-t", "foo, bar")).Should(Exit(0)) 193 }) 194 195 It("displays service instance info", func() { 196 session := helpers.CF("service", serviceInstanceName) 197 Eventually(session).Should(Say("Showing info of service %s in org %s / space %s as %s", serviceInstanceName, orgName, spaceName, userName)) 198 Eventually(session).Should(Say(`tags:\s+foo, bar`)) 199 Eventually(session).Should(Exit(0)) 200 }) 201 }) 202 }) 203 204 When("a user-provided service instance is created with tags", func() { 205 BeforeEach(func() { 206 helpers.SkipIfVersionLessThan(ccversion.MinVersionUserProvidedServiceTagsV2) 207 Eventually(helpers.CF("create-user-provided-service", serviceInstanceName, "-t", "database, email")).Should(Exit(0)) 208 }) 209 210 It("displays tag info", func() { 211 session := helpers.CF("service", serviceInstanceName) 212 Eventually(session).Should(Say("Showing info of service %s in org %s / space %s as %s", serviceInstanceName, orgName, spaceName, userName)) 213 Eventually(session).Should(Say(`tags:\s+database, email`)) 214 Eventually(session).Should(Exit(0)) 215 }) 216 }) 217 218 When("the service instance is a managed service instance", func() { 219 var ( 220 domain string 221 service string 222 servicePlan string 223 broker helpers.ServiceBroker 224 ) 225 226 BeforeEach(func() { 227 domain = helpers.DefaultSharedDomain() 228 service = helpers.PrefixedRandomName("SERVICE") 229 servicePlan = helpers.PrefixedRandomName("SERVICE-PLAN") 230 231 broker = helpers.CreateBroker(domain, service, servicePlan) 232 233 Eventually(helpers.CF("enable-service-access", service)).Should(Exit(0)) 234 Eventually(helpers.CF("create-service", service, servicePlan, serviceInstanceName, "-t", "database, email")).Should(Exit(0)) 235 }) 236 237 AfterEach(func() { 238 Eventually(helpers.CF("delete-service", serviceInstanceName, "-f")).Should(Exit(0)) 239 broker.Destroy() 240 }) 241 242 When("the --guid flag is provided", func() { 243 It("displays the service instance GUID", func() { 244 session := helpers.CF("service", serviceInstanceName, "--guid") 245 Consistently(session).ShouldNot(Say("Showing info of service %s in org %s / space %s as %s", serviceInstanceName, orgName, spaceName, userName)) 246 Eventually(session).Should(Say(helpers.ManagedServiceInstanceGUID(serviceInstanceName))) 247 Eventually(session).Should(Exit(0)) 248 }) 249 }) 250 251 When("apps are bound to the service instance", func() { 252 var ( 253 appName1 string 254 appName2 string 255 ) 256 257 BeforeEach(func() { 258 appName1 = helpers.PrefixedRandomName("1-INTEGRATION-APP") 259 appName2 = helpers.PrefixedRandomName("2-INTEGRATION-APP") 260 261 helpers.WithHelloWorldApp(func(appDir string) { 262 Eventually(helpers.CF("push", appName1, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0)) 263 Eventually(helpers.CF("push", appName2, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0)) 264 }) 265 }) 266 267 AfterEach(func() { 268 Eventually(helpers.CF("delete", appName1, "-f")).Should(Exit(0)) 269 Eventually(helpers.CF("delete", appName2, "-f")).Should(Exit(0)) 270 }) 271 272 When("the service bindings do not have binding names", func() { 273 BeforeEach(func() { 274 Eventually(helpers.CF("bind-service", appName1, serviceInstanceName)).Should(Exit(0)) 275 Eventually(helpers.CF("bind-service", appName2, serviceInstanceName)).Should(Exit(0)) 276 }) 277 278 AfterEach(func() { 279 Eventually(helpers.CF("unbind-service", appName1, serviceInstanceName)).Should(Exit(0)) 280 Eventually(helpers.CF("unbind-service", appName2, serviceInstanceName)).Should(Exit(0)) 281 }) 282 283 When("cc api version < 2.125.0", func() { 284 BeforeEach(func() { 285 helpers.SkipIfVersionAtLeast(ccversion.MinVersionMultiServiceRegistrationV2) 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:\s+http://documentation\.url`)) 299 Eventually(session).Should(Say(`dashboard:\s+http://example\.com`)) 300 Eventually(session).Should(Say(`service broker:`)) 301 Consistently(session).ShouldNot(Say(broker.Name)) 302 Eventually(session).Should(Say("\n\n")) 303 Consistently(session).ShouldNot(Say("shared with spaces:")) 304 Eventually(session).Should(Say(`Showing status of last operation from service %s\.\.\.`, serviceInstanceName)) 305 Eventually(session).Should(Say("\n\n")) 306 Eventually(session).Should(Say(`status:\s+create succeeded`)) 307 Eventually(session).Should(Say("message:")) 308 Eventually(session).Should(Say(`started:\s+\d{4}-[01]\d-[0-3]\dT[0-2][0-9]:[0-5]\d:[0-5]\dZ`)) 309 Eventually(session).Should(Say(`updated:\s+\d{4}-[01]\d-[0-3]\dT[0-2][0-9]:[0-5]\d:[0-5]\dZ`)) 310 Eventually(session).Should(Say("\n\n")) 311 Eventually(session).Should(Say("bound apps:")) 312 Eventually(session).Should(Say(`name\s+binding name\s+status\s+message`)) 313 Eventually(session).Should(Say(appName1)) 314 Eventually(session).Should(Say(appName2)) 315 Eventually(session).Should(Exit(0)) 316 }) 317 }) 318 319 When("cc api version >= 2.125.0", func() { 320 BeforeEach(func() { 321 helpers.SkipIfVersionLessThan(ccversion.MinVersionMultiServiceRegistrationV2) 322 }) 323 324 It("displays service instance info", func() { 325 session := helpers.CF("service", serviceInstanceName) 326 Eventually(session).Should(Say(`Showing info of service %s in org %s / space %s as %s\.\.\.`, serviceInstanceName, orgName, spaceName, userName)) 327 Eventually(session).Should(Say("\n\n")) 328 Eventually(session).Should(Say(`name:\s+%s`, serviceInstanceName)) 329 Consistently(session).ShouldNot(Say("shared from:")) 330 Eventually(session).Should(Say(`service:\s+%s`, service)) 331 Eventually(session).Should(Say(`tags:\s+database, email`)) 332 Eventually(session).Should(Say(`plan:\s+%s`, servicePlan)) 333 Eventually(session).Should(Say(`description:\s+fake service`)) 334 Eventually(session).Should(Say(`documentation:\s+http://documentation\.url`)) 335 Eventually(session).Should(Say(`dashboard:\s+http://example\.com`)) 336 Eventually(session).Should(Say(`service broker:\s+%s`, broker.Name)) 337 Eventually(session).Should(Say("\n\n")) 338 Consistently(session).ShouldNot(Say("shared with spaces:")) 339 Eventually(session).Should(Say(`Showing status of last operation from service %s\.\.\.`, serviceInstanceName)) 340 Eventually(session).Should(Say("\n\n")) 341 Eventually(session).Should(Say(`status:\s+create succeeded`)) 342 Eventually(session).Should(Say("message:")) 343 Eventually(session).Should(Say(`started:\s+\d{4}-[01]\d-[0-3]\dT[0-2][0-9]:[0-5]\d:[0-5]\dZ`)) 344 Eventually(session).Should(Say(`updated:\s+\d{4}-[01]\d-[0-3]\dT[0-2][0-9]:[0-5]\d:[0-5]\dZ`)) 345 Eventually(session).Should(Say("\n\n")) 346 Eventually(session).Should(Say("bound apps:")) 347 Eventually(session).Should(Say(`name\s+binding name\s+status\s+message`)) 348 Eventually(session).Should(Say(appName1)) 349 Eventually(session).Should(Say(appName2)) 350 Eventually(session).Should(Exit(0)) 351 }) 352 }) 353 }) 354 355 When("the service bindings have binding names", func() { 356 var ( 357 bindingName1 string 358 bindingName2 string 359 ) 360 361 BeforeEach(func() { 362 bindingName1 = helpers.PrefixedRandomName("BINDING-NAME") 363 bindingName2 = helpers.PrefixedRandomName("BINDING-NAME") 364 Eventually(helpers.CF("bind-service", appName1, serviceInstanceName, "--binding-name", bindingName1)).Should(Exit(0)) 365 Eventually(helpers.CF("bind-service", appName2, serviceInstanceName, "--binding-name", bindingName2)).Should(Exit(0)) 366 }) 367 368 AfterEach(func() { 369 Eventually(helpers.CF("unbind-service", appName1, serviceInstanceName)).Should(Exit(0)) 370 Eventually(helpers.CF("unbind-service", appName2, serviceInstanceName)).Should(Exit(0)) 371 }) 372 373 It("displays service instance info", func() { 374 session := helpers.CF("service", serviceInstanceName) 375 Eventually(session).Should(Say(`Showing info of service %s in org %s / space %s as %s\.\.\.`, serviceInstanceName, orgName, spaceName, userName)) 376 Eventually(session).Should(Say("\n\n")) 377 Eventually(session).Should(Say(`name:\s+%s`, serviceInstanceName)) 378 Consistently(session).ShouldNot(Say("shared from:")) 379 Eventually(session).Should(Say(`service:\s+%s`, service)) 380 Eventually(session).Should(Say(`tags:\s+database, email`)) 381 Eventually(session).Should(Say(`plan:\s+%s`, servicePlan)) 382 Eventually(session).Should(Say(`description:\s+fake service`)) 383 Eventually(session).Should(Say(`documentation:\s+http://documentation\.url`)) 384 Eventually(session).Should(Say(`dashboard:\s+http://example\.com`)) 385 Eventually(session).Should(Say("\n\n")) 386 Consistently(session).ShouldNot(Say("shared with spaces:")) 387 Eventually(session).Should(Say(`Showing status of last operation from service %s\.\.\.`, serviceInstanceName)) 388 Eventually(session).Should(Say("\n\n")) 389 Eventually(session).Should(Say(`status:\s+create succeeded`)) 390 Eventually(session).Should(Say("message:")) 391 Eventually(session).Should(Say(`started:\s+\d{4}-[01]\d-[0-3]\dT[0-2][0-9]:[0-5]\d:[0-5]\dZ`)) 392 Eventually(session).Should(Say(`updated:\s+\d{4}-[01]\d-[0-3]\dT[0-2][0-9]:[0-5]\d:[0-5]\dZ`)) 393 Eventually(session).Should(Say("\n\n")) 394 Eventually(session).Should(Say("bound apps:")) 395 Eventually(session).Should(Say(`name\s+binding name\s+status\s+message`)) 396 Eventually(session).Should(Say(`%s\s+%s`, appName1, bindingName1)) 397 Eventually(session).Should(Say(`%s\s+%s`, appName2, bindingName2)) 398 399 Eventually(session).Should(Exit(0)) 400 }) 401 }) 402 403 When("the binding has a state", func() { 404 var ( 405 bindingName1 string 406 bindingName2 string 407 ) 408 409 BeforeEach(func() { 410 helpers.SkipIfVersionLessThan(ccversion.MinVersionAsyncBindingsV2) 411 bindingName1 = helpers.PrefixedRandomName("BINDING-NAME") 412 bindingName2 = helpers.PrefixedRandomName("BINDING-NAME") 413 Eventually(helpers.CF("bind-service", appName1, serviceInstanceName, "--binding-name", bindingName1)).Should(Exit(0)) 414 Eventually(helpers.CF("bind-service", appName2, serviceInstanceName, "--binding-name", bindingName2)).Should(Exit(0)) 415 }) 416 417 AfterEach(func() { 418 Eventually(helpers.CF("unbind-service", appName1, serviceInstanceName)).Should(Exit(0)) 419 Eventually(helpers.CF("unbind-service", appName2, serviceInstanceName)).Should(Exit(0)) 420 }) 421 422 It("displays it in the status field", func() { 423 session := helpers.CF("service", serviceInstanceName) 424 Eventually(session).Should(Say(`name:\s+%s`, serviceInstanceName)) 425 Eventually(session).Should(Say("bound apps:")) 426 Eventually(session).Should(Say(`name\s+binding name\s+status\s+message`)) 427 Eventually(session).Should(Say(`%s\s+%s\s+create succeeded`, appName1, bindingName1)) 428 Eventually(session).Should(Say(`%s\s+%s\s+create succeeded`, appName2, bindingName2)) 429 430 Eventually(session).Should(Exit(0)) 431 }) 432 }) 433 }) 434 }) 435 }) 436 }) 437 438 Context("service instance sharing when there are multiple spaces", func() { 439 var ( 440 orgName string 441 sourceSpaceName string 442 443 service string 444 servicePlan string 445 broker helpers.ServiceBroker 446 ) 447 448 BeforeEach(func() { 449 helpers.SkipIfVersionLessThan(ccversion.MinVersionShareServiceV3) 450 orgName = helpers.NewOrgName() 451 sourceSpaceName = helpers.NewSpaceName() 452 helpers.SetupCF(orgName, sourceSpaceName) 453 454 domain := helpers.DefaultSharedDomain() 455 service = helpers.PrefixedRandomName("SERVICE") 456 servicePlan = helpers.PrefixedRandomName("SERVICE-PLAN") 457 broker = helpers.CreateBroker(domain, service, servicePlan) 458 459 Eventually(helpers.CF("enable-service-access", service)).Should(Exit(0)) 460 Eventually(helpers.CF("create-service", service, servicePlan, serviceInstanceName)).Should(Exit(0)) 461 }) 462 463 AfterEach(func() { 464 // need to login as admin 465 helpers.LoginCF() 466 helpers.TargetOrgAndSpace(orgName, sourceSpaceName) 467 broker.Destroy() 468 helpers.QuickDeleteOrg(orgName) 469 }) 470 471 Context("service has no type of shares", func() { 472 When("the service is shareable", func() { 473 It("should not display shared from or shared with information, but DOES display not currently shared info", func() { 474 session := helpers.CF("service", serviceInstanceName) 475 Eventually(session).Should(Say("This service is not currently shared.")) 476 Eventually(session).Should(Exit(0)) 477 }) 478 }) 479 }) 480 481 Context("service is shared between two spaces", func() { 482 var ( 483 targetSpaceName string 484 ) 485 486 BeforeEach(func() { 487 targetSpaceName = helpers.NewSpaceName() 488 helpers.CreateOrgAndSpace(orgName, targetSpaceName) 489 helpers.TargetOrgAndSpace(orgName, sourceSpaceName) 490 Eventually(helpers.CF("share-service", serviceInstanceName, "-s", targetSpaceName)).Should(Exit(0)) 491 }) 492 493 When("the user is targeted to the source space", func() { 494 When("there are externally bound apps to the service", func() { 495 BeforeEach(func() { 496 helpers.TargetOrgAndSpace(orgName, targetSpaceName) 497 helpers.WithHelloWorldApp(func(appDir string) { 498 appName1 := helpers.NewAppName() 499 Eventually(helpers.CF("push", appName1, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0)) 500 Eventually(helpers.CF("bind-service", appName1, serviceInstanceName)).Should(Exit(0)) 501 502 appName2 := helpers.NewAppName() 503 Eventually(helpers.CF("push", appName2, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0)) 504 Eventually(helpers.CF("bind-service", appName2, serviceInstanceName)).Should(Exit(0)) 505 }) 506 helpers.TargetOrgAndSpace(orgName, sourceSpaceName) 507 }) 508 509 It("should display the number of bound apps next to the target space name", func() { 510 session := helpers.CF("service", serviceInstanceName) 511 Eventually(session).Should(Say("shared with spaces:")) 512 Eventually(session).Should(Say(`org\s+space\s+bindings`)) 513 Eventually(session).Should(Say(`%s\s+%s\s+2`, orgName, targetSpaceName)) 514 Eventually(session).Should(Exit(0)) 515 }) 516 }) 517 518 When("there are no externally bound apps to the service", func() { 519 It("should NOT display the number of bound apps next to the target space name", func() { 520 session := helpers.CF("service", serviceInstanceName) 521 Eventually(session).Should(Say("shared with spaces:")) 522 Eventually(session).Should(Say(`org\s+space\s+bindings`)) 523 Eventually(session).Should(Exit(0)) 524 }) 525 }) 526 527 When("the service is no longer shareable", func() { 528 Context("due to service broker settings", func() { 529 BeforeEach(func() { 530 broker.Configure(false) 531 broker.Update() 532 }) 533 534 It("should display that service instance sharing is disabled for this service", func() { 535 session := helpers.CF("service", serviceInstanceName) 536 Eventually(session).Should(Say("Service instance sharing is disabled for this service.")) 537 Eventually(session).Should(Exit(0)) 538 }) 539 }) 540 }) 541 }) 542 543 When("the user is targeted to the target space", func() { 544 var appName1, appName2 string 545 546 BeforeEach(func() { 547 // We test that the app names are listed in alphanumeric sort order 548 appName1 = helpers.PrefixedRandomName("2-INTEGRATION-APP") 549 appName2 = helpers.PrefixedRandomName("1-INTEGRATION-APP") 550 helpers.TargetOrgAndSpace(orgName, targetSpaceName) 551 helpers.WithHelloWorldApp(func(appDir string) { 552 Eventually(helpers.CF("push", appName1, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0)) 553 Eventually(helpers.CF("bind-service", appName1, serviceInstanceName)).Should(Exit(0)) 554 555 Eventually(helpers.CF("push", appName2, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0)) 556 Eventually(helpers.CF("bind-service", appName2, serviceInstanceName)).Should(Exit(0)) 557 }) 558 }) 559 560 When("there are bound apps to the service with no binding names", func() { 561 It("should display the bound apps in alphanumeric sort order", func() { 562 session := helpers.CF("service", serviceInstanceName) 563 Eventually(session).Should(Say(`shared from org/space:\s+%s / %s`, orgName, sourceSpaceName)) 564 Eventually(session).Should(Say("\n\n")) 565 Eventually(session).Should(Say("bound apps:")) 566 Eventually(session).Should(Say(`name\s+binding name\s+status\s+message`)) 567 Eventually(session).Should(Say(appName2)) 568 Eventually(session).Should(Say(appName1)) 569 Eventually(session).Should(Exit(0)) 570 }) 571 }) 572 }) 573 }) 574 }) 575 })