github.com/jghiloni/cli@v6.28.1-0.20170628223758-0ce05fe032a2+incompatible/actor/v2action/space_summary_test.go (about) 1 package v2action_test 2 3 import ( 4 "errors" 5 6 . "code.cloudfoundry.org/cli/actor/v2action" 7 "code.cloudfoundry.org/cli/actor/v2action/v2actionfakes" 8 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv2" 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 ) 12 13 var _ = Describe("Space Summary Actions", func() { 14 Describe("GetSpaceSummaryByOrganizationAndName", func() { 15 var ( 16 actor *Actor 17 fakeCloudControllerClient *v2actionfakes.FakeCloudControllerClient 18 spaceSummary SpaceSummary 19 warnings Warnings 20 err error 21 ) 22 23 BeforeEach(func() { 24 fakeCloudControllerClient = new(v2actionfakes.FakeCloudControllerClient) 25 actor = NewActor(fakeCloudControllerClient, nil) 26 }) 27 28 Context("when space staging security groups are requested", func() { 29 JustBeforeEach(func() { 30 spaceSummary, warnings, err = actor.GetSpaceSummaryByOrganizationAndName("some-org-guid", "some-space", true) 31 }) 32 33 Context("when no errors are encountered", func() { 34 BeforeEach(func() { 35 fakeCloudControllerClient.GetOrganizationReturns( 36 ccv2.Organization{ 37 GUID: "some-org-guid", 38 Name: "some-org", 39 }, 40 ccv2.Warnings{"warning-1", "warning-2"}, 41 nil) 42 43 fakeCloudControllerClient.GetSpacesReturns( 44 []ccv2.Space{ 45 { 46 GUID: "some-space-guid", 47 Name: "some-space", 48 SpaceQuotaDefinitionGUID: "some-space-quota-guid", 49 }, 50 }, 51 ccv2.Warnings{"warning-3", "warning-4"}, 52 nil) 53 54 fakeCloudControllerClient.GetApplicationsReturns( 55 []ccv2.Application{ 56 { 57 Name: "some-app-2", 58 }, 59 { 60 Name: "some-app-1", 61 }, 62 }, 63 ccv2.Warnings{"warning-5", "warning-6"}, 64 nil) 65 66 fakeCloudControllerClient.GetSpaceServiceInstancesReturns( 67 []ccv2.ServiceInstance{ 68 { 69 GUID: "some-service-instance-guid-2", 70 Name: "some-service-instance-2", 71 }, 72 { 73 GUID: "some-service-instance-guid-1", 74 Name: "some-service-instance-1", 75 }, 76 }, 77 ccv2.Warnings{"warning-7", "warning-8"}, 78 nil) 79 80 fakeCloudControllerClient.GetSpaceQuotaReturns( 81 ccv2.SpaceQuota{ 82 GUID: "some-space-quota-guid", 83 Name: "some-space-quota", 84 }, 85 ccv2.Warnings{"warning-9", "warning-10"}, 86 nil) 87 88 fakeCloudControllerClient.GetSpaceRunningSecurityGroupsBySpaceReturns( 89 []ccv2.SecurityGroup{ 90 { 91 Name: "some-shared-security-group", 92 Rules: []ccv2.SecurityGroupRule{ 93 { 94 Description: "Some shared walking group", 95 Destination: "0.0.0.0-5.6.7.8", 96 Ports: "80,443", 97 Protocol: "tcp", 98 }, 99 { 100 Description: "Some shared walking group too", 101 Destination: "127.10.10.10-127.10.10.255", 102 Ports: "80,4443", 103 Protocol: "udp", 104 }, 105 }, 106 }, 107 { 108 Name: "some-running-security-group", 109 Rules: []ccv2.SecurityGroupRule{ 110 { 111 Description: "Some running walking group", 112 Destination: "127.0.0.1-127.0.0.255", 113 Ports: "8080,443", 114 Protocol: "tcp", 115 }, 116 { 117 Description: "Some running walking group too", 118 Destination: "127.20.20.20-127.20.20.25", 119 Ports: "80,4443", 120 Protocol: "udp", 121 }, 122 }, 123 }, 124 }, 125 ccv2.Warnings{"warning-11", "warning-12"}, 126 nil) 127 128 fakeCloudControllerClient.GetSpaceStagingSecurityGroupsBySpaceReturns( 129 []ccv2.SecurityGroup{ 130 { 131 Name: "some-staging-security-group", 132 Rules: []ccv2.SecurityGroupRule{ 133 { 134 Description: "Some staging cinematic group", 135 Destination: "127.5.5.1-127.6.6.255", 136 Ports: "32767,443", 137 Protocol: "tcp", 138 }, 139 { 140 Description: "Some staging cinematic group too", 141 Destination: "127.25.20.20-127.25.20.25", 142 Ports: "80,9999", 143 Protocol: "udp", 144 }, 145 }, 146 }, 147 { 148 Name: "some-shared-security-group", 149 Rules: []ccv2.SecurityGroupRule{ 150 { 151 Description: "Some shared cinematic group", 152 Destination: "0.0.0.0-5.6.7.8", 153 Ports: "80,443", 154 Protocol: "tcp", 155 }, 156 { 157 Description: "Some shared cinematic group too", 158 Destination: "127.10.10.10-127.10.10.255", 159 Ports: "80,4443", 160 Protocol: "udp", 161 }, 162 }, 163 }, 164 }, 165 ccv2.Warnings{"warning-13", "warning-14"}, 166 nil) 167 }) 168 169 It("returns the space summary and all warnings", func() { 170 Expect(err).NotTo(HaveOccurred()) 171 172 Expect(warnings).To(ConsistOf([]string{ 173 "warning-1", 174 "warning-2", 175 "warning-3", 176 "warning-4", 177 "warning-5", 178 "warning-6", 179 "warning-7", 180 "warning-8", 181 "warning-9", 182 "warning-10", 183 "warning-11", 184 "warning-12", 185 "warning-13", 186 "warning-14", 187 })) 188 189 Expect(spaceSummary).To(Equal(SpaceSummary{ 190 Space: Space{ 191 Name: "some-space", 192 GUID: "some-space-guid", 193 SpaceQuotaDefinitionGUID: "some-space-quota-guid", 194 }, 195 OrgName: "some-org", 196 AppNames: []string{"some-app-1", "some-app-2"}, 197 ServiceInstanceNames: []string{"some-service-instance-1", "some-service-instance-2"}, 198 SpaceQuotaName: "some-space-quota", 199 RunningSecurityGroupNames: []string{"some-running-security-group", "some-shared-security-group"}, 200 StagingSecurityGroupNames: []string{"some-shared-security-group", "some-staging-security-group"}, 201 SecurityGroupRules: []SecurityGroupRule{ 202 { 203 Name: "some-running-security-group", 204 Description: "Some running walking group", 205 Destination: "127.0.0.1-127.0.0.255", 206 Lifecycle: "running", 207 Ports: "8080,443", 208 Protocol: "tcp", 209 }, 210 { 211 Name: "some-running-security-group", 212 Description: "Some running walking group too", 213 Destination: "127.20.20.20-127.20.20.25", 214 Lifecycle: "running", 215 Ports: "80,4443", 216 Protocol: "udp", 217 }, 218 { 219 Name: "some-shared-security-group", 220 Description: "Some shared walking group", 221 Destination: "0.0.0.0-5.6.7.8", 222 Lifecycle: "running", 223 Ports: "80,443", 224 Protocol: "tcp", 225 }, 226 { 227 Name: "some-shared-security-group", 228 Description: "Some shared cinematic group", 229 Destination: "0.0.0.0-5.6.7.8", 230 Lifecycle: "staging", 231 Ports: "80,443", 232 Protocol: "tcp", 233 }, 234 { 235 Name: "some-shared-security-group", 236 Description: "Some shared walking group too", 237 Destination: "127.10.10.10-127.10.10.255", 238 Lifecycle: "running", 239 Ports: "80,4443", 240 Protocol: "udp", 241 }, 242 { 243 Name: "some-shared-security-group", 244 Description: "Some shared cinematic group too", 245 Destination: "127.10.10.10-127.10.10.255", 246 Lifecycle: "staging", 247 Ports: "80,4443", 248 Protocol: "udp", 249 }, 250 { 251 Name: "some-staging-security-group", 252 Description: "Some staging cinematic group too", 253 Destination: "127.25.20.20-127.25.20.25", 254 Lifecycle: "staging", 255 Ports: "80,9999", 256 Protocol: "udp", 257 }, 258 { 259 Name: "some-staging-security-group", 260 Description: "Some staging cinematic group", 261 Destination: "127.5.5.1-127.6.6.255", 262 Lifecycle: "staging", 263 Ports: "32767,443", 264 Protocol: "tcp", 265 }, 266 }, 267 })) 268 269 Expect(fakeCloudControllerClient.GetOrganizationCallCount()).To(Equal(1)) 270 Expect(fakeCloudControllerClient.GetOrganizationArgsForCall(0)).To(Equal("some-org-guid")) 271 272 Expect(fakeCloudControllerClient.GetSpacesCallCount()).To(Equal(1)) 273 query := fakeCloudControllerClient.GetSpacesArgsForCall(0) 274 Expect(query).To(ConsistOf( 275 ccv2.Query{ 276 Filter: ccv2.NameFilter, 277 Operator: ccv2.EqualOperator, 278 Value: "some-space", 279 }, 280 ccv2.Query{ 281 Filter: ccv2.OrganizationGUIDFilter, 282 Operator: ccv2.EqualOperator, 283 Value: "some-org-guid", 284 }, 285 )) 286 287 Expect(fakeCloudControllerClient.GetApplicationsCallCount()).To(Equal(1)) 288 query = fakeCloudControllerClient.GetApplicationsArgsForCall(0) 289 Expect(query).To(ConsistOf( 290 ccv2.Query{ 291 Filter: ccv2.SpaceGUIDFilter, 292 Operator: ccv2.EqualOperator, 293 Value: "some-space-guid", 294 }, 295 )) 296 297 Expect(fakeCloudControllerClient.GetSpaceServiceInstancesCallCount()).To(Equal(1)) 298 spaceGUID, includeUserProvidedServices, query := fakeCloudControllerClient.GetSpaceServiceInstancesArgsForCall(0) 299 Expect(spaceGUID).To(Equal("some-space-guid")) 300 Expect(includeUserProvidedServices).To(BeTrue()) 301 Expect(query).To(BeNil()) 302 303 Expect(fakeCloudControllerClient.GetSpaceQuotaCallCount()).To(Equal(1)) 304 spaceQuotaGUID := fakeCloudControllerClient.GetSpaceQuotaArgsForCall(0) 305 Expect(spaceQuotaGUID).To(Equal("some-space-quota-guid")) 306 307 Expect(fakeCloudControllerClient.GetSpaceRunningSecurityGroupsBySpaceCallCount()).To(Equal(1)) 308 spaceGUIDRunning, queriesRunning := fakeCloudControllerClient.GetSpaceRunningSecurityGroupsBySpaceArgsForCall(0) 309 Expect(spaceGUIDRunning).To(Equal("some-space-guid")) 310 Expect(queriesRunning).To(BeNil()) 311 312 Expect(fakeCloudControllerClient.GetSpaceStagingSecurityGroupsBySpaceCallCount()).To(Equal(1)) 313 spaceGUIDStaging, queriesStaging := fakeCloudControllerClient.GetSpaceStagingSecurityGroupsBySpaceArgsForCall(0) 314 Expect(spaceGUIDStaging).To(Equal("some-space-guid")) 315 Expect(queriesStaging).To(BeNil()) 316 }) 317 318 Context("when no space quota is assigned", func() { 319 BeforeEach(func() { 320 fakeCloudControllerClient.GetSpacesReturns( 321 []ccv2.Space{ 322 { 323 GUID: "some-space-guid", 324 Name: "some-space", 325 }, 326 }, 327 ccv2.Warnings{"warning-3", "warning-4"}, 328 nil) 329 }) 330 331 It("does not request space quota information or return a space quota name", func() { 332 Expect(fakeCloudControllerClient.GetSpaceQuotaCallCount()).To(Equal(0)) 333 Expect(spaceSummary.SpaceQuotaName).To(Equal("")) 334 }) 335 }) 336 }) 337 338 Context("when an error is encountered getting the organization", func() { 339 var expectedErr error 340 341 BeforeEach(func() { 342 expectedErr = errors.New("get-org-error") 343 fakeCloudControllerClient.GetOrganizationReturns( 344 ccv2.Organization{}, 345 ccv2.Warnings{ 346 "warning-1", 347 "warning-2", 348 }, 349 expectedErr) 350 }) 351 352 It("returns the error and all warnings", func() { 353 Expect(err).To(MatchError(expectedErr)) 354 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 355 }) 356 }) 357 358 Context("when an error is encountered getting the space", func() { 359 var expectedErr error 360 361 BeforeEach(func() { 362 expectedErr = errors.New("get-space-error") 363 364 fakeCloudControllerClient.GetOrganizationReturns( 365 ccv2.Organization{ 366 GUID: "some-org-guid", 367 Name: "some-org", 368 }, 369 nil, 370 nil) 371 372 fakeCloudControllerClient.GetSpacesReturns( 373 []ccv2.Space{}, 374 ccv2.Warnings{"warning-1", "warning-2"}, 375 expectedErr) 376 }) 377 378 It("returns the error and all warnings", func() { 379 Expect(err).To(MatchError(expectedErr)) 380 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 381 }) 382 }) 383 384 Context("when an error is encountered getting the application", func() { 385 var expectedErr error 386 387 BeforeEach(func() { 388 expectedErr = errors.New("get-applications-error") 389 390 fakeCloudControllerClient.GetOrganizationReturns( 391 ccv2.Organization{ 392 GUID: "some-org-guid", 393 Name: "some-org", 394 }, 395 nil, 396 nil) 397 398 fakeCloudControllerClient.GetSpacesReturns( 399 []ccv2.Space{ 400 { 401 GUID: "some-space-guid", 402 Name: "some-space", 403 SpaceQuotaDefinitionGUID: "some-space-quota-guid", 404 }, 405 }, 406 nil, 407 nil) 408 409 fakeCloudControllerClient.GetApplicationsReturns( 410 []ccv2.Application{}, 411 ccv2.Warnings{"warning-1", "warning-2"}, 412 expectedErr) 413 }) 414 415 It("returns the error and all warnings", func() { 416 Expect(err).To(MatchError(expectedErr)) 417 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 418 }) 419 }) 420 421 Context("when an error is encountered getting the service instances", func() { 422 var expectedErr error 423 424 BeforeEach(func() { 425 expectedErr = errors.New("get-service-instances-error") 426 427 fakeCloudControllerClient.GetOrganizationReturns( 428 ccv2.Organization{ 429 GUID: "some-org-guid", 430 Name: "some-org", 431 }, 432 nil, 433 nil) 434 435 fakeCloudControllerClient.GetSpacesReturns( 436 []ccv2.Space{ 437 { 438 GUID: "some-space-guid", 439 Name: "some-space", 440 SpaceQuotaDefinitionGUID: "some-space-quota-guid", 441 }, 442 }, 443 nil, 444 nil) 445 446 fakeCloudControllerClient.GetApplicationsReturns( 447 []ccv2.Application{ 448 { 449 Name: "some-app-2", 450 }, 451 { 452 Name: "some-app-1", 453 }, 454 }, 455 nil, 456 nil) 457 458 fakeCloudControllerClient.GetSpaceServiceInstancesReturns( 459 []ccv2.ServiceInstance{}, 460 ccv2.Warnings{"warning-1", "warning-2"}, 461 expectedErr) 462 }) 463 464 It("returns the error and all warnings", func() { 465 Expect(err).To(MatchError(expectedErr)) 466 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 467 }) 468 }) 469 470 Context("when an error is encountered getting the space quota", func() { 471 var expectedErr error 472 473 BeforeEach(func() { 474 expectedErr = errors.New("get-space-quota-error") 475 476 fakeCloudControllerClient.GetOrganizationReturns( 477 ccv2.Organization{ 478 GUID: "some-org-guid", 479 Name: "some-org", 480 }, 481 nil, 482 nil) 483 484 fakeCloudControllerClient.GetSpacesReturns( 485 []ccv2.Space{ 486 { 487 GUID: "some-space-guid", 488 Name: "some-space", 489 SpaceQuotaDefinitionGUID: "some-space-quota-guid", 490 }, 491 }, 492 nil, 493 nil) 494 495 fakeCloudControllerClient.GetApplicationsReturns( 496 []ccv2.Application{ 497 { 498 Name: "some-app-2", 499 }, 500 { 501 Name: "some-app-1", 502 }, 503 }, 504 nil, 505 nil) 506 507 fakeCloudControllerClient.GetSpaceServiceInstancesReturns( 508 []ccv2.ServiceInstance{ 509 { 510 GUID: "some-service-instance-guid-2", 511 Name: "some-service-instance-2", 512 }, 513 { 514 GUID: "some-service-instance-guid-1", 515 Name: "some-service-instance-1", 516 }, 517 }, 518 nil, 519 nil) 520 521 fakeCloudControllerClient.GetSpaceQuotaReturns( 522 ccv2.SpaceQuota{}, 523 ccv2.Warnings{"warning-1", "warning-2"}, 524 expectedErr) 525 }) 526 527 It("returns the error and all warnings", func() { 528 Expect(err).To(MatchError(expectedErr)) 529 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 530 }) 531 }) 532 533 Context("when an error is encountered getting the running security groups", func() { 534 var expectedErr error 535 536 BeforeEach(func() { 537 expectedErr = errors.New("get-running-security-groups-error") 538 539 fakeCloudControllerClient.GetOrganizationReturns( 540 ccv2.Organization{ 541 GUID: "some-org-guid", 542 Name: "some-org", 543 }, 544 nil, 545 nil) 546 547 fakeCloudControllerClient.GetSpacesReturns( 548 []ccv2.Space{ 549 { 550 GUID: "some-space-guid", 551 Name: "some-space", 552 SpaceQuotaDefinitionGUID: "some-space-quota-guid", 553 }, 554 }, 555 nil, 556 nil) 557 558 fakeCloudControllerClient.GetApplicationsReturns( 559 []ccv2.Application{ 560 { 561 Name: "some-app-2", 562 }, 563 { 564 Name: "some-app-1", 565 }, 566 }, 567 nil, 568 nil) 569 570 fakeCloudControllerClient.GetSpaceServiceInstancesReturns( 571 []ccv2.ServiceInstance{ 572 { 573 GUID: "some-service-instance-guid-2", 574 Name: "some-service-instance-2", 575 }, 576 { 577 GUID: "some-service-instance-guid-1", 578 Name: "some-service-instance-1", 579 }, 580 }, 581 nil, 582 nil) 583 584 fakeCloudControllerClient.GetSpaceQuotaReturns( 585 ccv2.SpaceQuota{ 586 GUID: "some-space-quota-guid", 587 Name: "some-space-quota", 588 }, 589 nil, 590 nil) 591 592 fakeCloudControllerClient.GetSpaceRunningSecurityGroupsBySpaceReturns( 593 []ccv2.SecurityGroup{}, 594 ccv2.Warnings{"warning-1", "warning-2"}, 595 expectedErr) 596 }) 597 598 It("returns the error and all warnings", func() { 599 Expect(err).To(MatchError(expectedErr)) 600 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 601 }) 602 }) 603 604 Context("when an error is encountered getting the staging security groups", func() { 605 var expectedErr error 606 607 BeforeEach(func() { 608 expectedErr = errors.New("get-staging-security-groups-error") 609 610 fakeCloudControllerClient.GetOrganizationReturns( 611 ccv2.Organization{ 612 GUID: "some-org-guid", 613 Name: "some-org", 614 }, 615 nil, 616 nil) 617 618 fakeCloudControllerClient.GetSpacesReturns( 619 []ccv2.Space{ 620 { 621 GUID: "some-space-guid", 622 Name: "some-space", 623 SpaceQuotaDefinitionGUID: "some-space-quota-guid", 624 }, 625 }, 626 nil, 627 nil) 628 629 fakeCloudControllerClient.GetApplicationsReturns( 630 []ccv2.Application{ 631 { 632 Name: "some-app-2", 633 }, 634 { 635 Name: "some-app-1", 636 }, 637 }, 638 nil, 639 nil) 640 641 fakeCloudControllerClient.GetSpaceServiceInstancesReturns( 642 []ccv2.ServiceInstance{ 643 { 644 GUID: "some-service-instance-guid-2", 645 Name: "some-service-instance-2", 646 }, 647 { 648 GUID: "some-service-instance-guid-1", 649 Name: "some-service-instance-1", 650 }, 651 }, 652 nil, 653 nil) 654 655 fakeCloudControllerClient.GetSpaceQuotaReturns( 656 ccv2.SpaceQuota{ 657 GUID: "some-space-quota-guid", 658 Name: "some-space-quota", 659 }, 660 nil, 661 nil) 662 663 fakeCloudControllerClient.GetSpaceRunningSecurityGroupsBySpaceReturns( 664 []ccv2.SecurityGroup{}, 665 nil, 666 nil) 667 668 fakeCloudControllerClient.GetSpaceStagingSecurityGroupsBySpaceReturns( 669 []ccv2.SecurityGroup{}, 670 ccv2.Warnings{"warning-1", "warning-2"}, 671 expectedErr) 672 }) 673 674 It("returns the error and all warnings", func() { 675 Expect(err).To(MatchError(expectedErr)) 676 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 677 }) 678 }) 679 }) 680 681 Context("when space staging security groups are not requested", func() { 682 JustBeforeEach(func() { 683 spaceSummary, warnings, err = actor.GetSpaceSummaryByOrganizationAndName("some-org-guid", "some-space", false) 684 }) 685 686 Context("when no errors are encountered", func() { 687 BeforeEach(func() { 688 fakeCloudControllerClient.GetOrganizationReturns( 689 ccv2.Organization{ 690 GUID: "some-org-guid", 691 Name: "some-org", 692 DefaultIsolationSegmentGUID: "some-org-default-isolation-segment-guid", 693 }, 694 ccv2.Warnings{"warning-1", "warning-2"}, 695 nil) 696 697 fakeCloudControllerClient.GetSpacesReturns( 698 []ccv2.Space{ 699 { 700 GUID: "some-space-guid", 701 Name: "some-space", 702 SpaceQuotaDefinitionGUID: "some-space-quota-guid", 703 }, 704 }, 705 ccv2.Warnings{"warning-3", "warning-4"}, 706 nil) 707 708 fakeCloudControllerClient.GetApplicationsReturns( 709 []ccv2.Application{ 710 { 711 Name: "some-app-2", 712 }, 713 { 714 Name: "some-app-1", 715 }, 716 }, 717 ccv2.Warnings{"warning-5", "warning-6"}, 718 nil) 719 720 fakeCloudControllerClient.GetSpaceServiceInstancesReturns( 721 []ccv2.ServiceInstance{ 722 { 723 GUID: "some-service-instance-guid-2", 724 Name: "some-service-instance-2", 725 }, 726 { 727 GUID: "some-service-instance-guid-1", 728 Name: "some-service-instance-1", 729 }, 730 }, 731 ccv2.Warnings{"warning-7", "warning-8"}, 732 nil) 733 734 fakeCloudControllerClient.GetSpaceQuotaReturns( 735 ccv2.SpaceQuota{ 736 GUID: "some-space-quota-guid", 737 Name: "some-space-quota", 738 }, 739 ccv2.Warnings{"warning-9", "warning-10"}, 740 nil) 741 742 fakeCloudControllerClient.GetSpaceRunningSecurityGroupsBySpaceReturns( 743 []ccv2.SecurityGroup{ 744 { 745 Name: "some-shared-security-group", 746 Rules: []ccv2.SecurityGroupRule{ 747 { 748 Description: "Some shared walking group", 749 Destination: "0.0.0.0-5.6.7.8", 750 Ports: "80,443", 751 Protocol: "tcp", 752 }, 753 { 754 Description: "Some shared walking group too", 755 Destination: "127.10.10.10-127.10.10.255", 756 Ports: "80,4443", 757 Protocol: "udp", 758 }, 759 }, 760 }, 761 { 762 Name: "some-running-security-group", 763 Rules: []ccv2.SecurityGroupRule{ 764 { 765 Description: "Some running walking group", 766 Destination: "127.0.0.1-127.0.0.255", 767 Ports: "8080,443", 768 Protocol: "tcp", 769 }, 770 { 771 Description: "Some running walking group too", 772 Destination: "127.20.20.20-127.20.20.25", 773 Ports: "80,4443", 774 Protocol: "udp", 775 }, 776 }, 777 }, 778 }, 779 ccv2.Warnings{"warning-11", "warning-12"}, 780 nil) 781 }) 782 783 It("returns the space summary (without staging security group rules) and all warnings", func() { 784 Expect(err).NotTo(HaveOccurred()) 785 786 Expect(warnings).To(ConsistOf([]string{ 787 "warning-1", 788 "warning-2", 789 "warning-3", 790 "warning-4", 791 "warning-5", 792 "warning-6", 793 "warning-7", 794 "warning-8", 795 "warning-9", 796 "warning-10", 797 "warning-11", 798 "warning-12", 799 })) 800 801 Expect(spaceSummary).To(Equal(SpaceSummary{ 802 Space: Space{ 803 Name: "some-space", 804 GUID: "some-space-guid", 805 SpaceQuotaDefinitionGUID: "some-space-quota-guid", 806 }, 807 OrgName: "some-org", 808 OrgDefaultIsolationSegmentGUID: "some-org-default-isolation-segment-guid", 809 AppNames: []string{"some-app-1", "some-app-2"}, 810 ServiceInstanceNames: []string{"some-service-instance-1", "some-service-instance-2"}, 811 SpaceQuotaName: "some-space-quota", 812 RunningSecurityGroupNames: []string{"some-running-security-group", "some-shared-security-group"}, 813 StagingSecurityGroupNames: nil, 814 SecurityGroupRules: []SecurityGroupRule{ 815 { 816 Name: "some-running-security-group", 817 Description: "Some running walking group", 818 Destination: "127.0.0.1-127.0.0.255", 819 Lifecycle: "running", 820 Ports: "8080,443", 821 Protocol: "tcp", 822 }, 823 { 824 Name: "some-running-security-group", 825 Description: "Some running walking group too", 826 Destination: "127.20.20.20-127.20.20.25", 827 Lifecycle: "running", 828 Ports: "80,4443", 829 Protocol: "udp", 830 }, 831 { 832 Name: "some-shared-security-group", 833 Description: "Some shared walking group", 834 Destination: "0.0.0.0-5.6.7.8", 835 Lifecycle: "running", 836 Ports: "80,443", 837 Protocol: "tcp", 838 }, 839 { 840 Name: "some-shared-security-group", 841 Description: "Some shared walking group too", 842 Destination: "127.10.10.10-127.10.10.255", 843 Lifecycle: "running", 844 Ports: "80,4443", 845 Protocol: "udp", 846 }, 847 }, 848 })) 849 850 Expect(fakeCloudControllerClient.GetOrganizationCallCount()).To(Equal(1)) 851 Expect(fakeCloudControllerClient.GetOrganizationArgsForCall(0)).To(Equal("some-org-guid")) 852 853 Expect(fakeCloudControllerClient.GetSpacesCallCount()).To(Equal(1)) 854 query := fakeCloudControllerClient.GetSpacesArgsForCall(0) 855 Expect(query).To(ConsistOf( 856 ccv2.Query{ 857 Filter: ccv2.NameFilter, 858 Operator: ccv2.EqualOperator, 859 Value: "some-space", 860 }, 861 ccv2.Query{ 862 Filter: ccv2.OrganizationGUIDFilter, 863 Operator: ccv2.EqualOperator, 864 Value: "some-org-guid", 865 }, 866 )) 867 868 Expect(fakeCloudControllerClient.GetApplicationsCallCount()).To(Equal(1)) 869 query = fakeCloudControllerClient.GetApplicationsArgsForCall(0) 870 Expect(query).To(ConsistOf( 871 ccv2.Query{ 872 Filter: ccv2.SpaceGUIDFilter, 873 Operator: ccv2.EqualOperator, 874 Value: "some-space-guid", 875 }, 876 )) 877 878 Expect(fakeCloudControllerClient.GetSpaceServiceInstancesCallCount()).To(Equal(1)) 879 spaceGUID, includeUserProvidedServices, query := fakeCloudControllerClient.GetSpaceServiceInstancesArgsForCall(0) 880 Expect(spaceGUID).To(Equal("some-space-guid")) 881 Expect(includeUserProvidedServices).To(BeTrue()) 882 Expect(query).To(BeNil()) 883 884 Expect(fakeCloudControllerClient.GetSpaceQuotaCallCount()).To(Equal(1)) 885 spaceQuotaGUID := fakeCloudControllerClient.GetSpaceQuotaArgsForCall(0) 886 Expect(spaceQuotaGUID).To(Equal("some-space-quota-guid")) 887 888 Expect(fakeCloudControllerClient.GetSpaceRunningSecurityGroupsBySpaceCallCount()).To(Equal(1)) 889 spaceGUID, queries := fakeCloudControllerClient.GetSpaceRunningSecurityGroupsBySpaceArgsForCall(0) 890 Expect(spaceGUID).To(Equal("some-space-guid")) 891 Expect(queries).To(BeNil()) 892 893 Expect(fakeCloudControllerClient.GetSpaceStagingSecurityGroupsBySpaceCallCount()).To(Equal(0)) 894 }) 895 }) 896 }) 897 }) 898 })