github.com/cloudfoundry-community/cloudfoundry-cli@v6.44.1-0.20240130060226-cda5ed8e89a5+incompatible/integration/shared/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  
    14  	var (
    15  		serviceInstanceName string
    16  		orgName             string
    17  		sourceSpaceName     string
    18  
    19  		service     string
    20  		servicePlan string
    21  		broker      helpers.ServiceBroker
    22  	)
    23  
    24  	BeforeEach(func() {
    25  		helpers.SkipIfVersionLessThan(ccversion.MinVersionShareServiceV3)
    26  
    27  		serviceInstanceName = helpers.PrefixedRandomName("SI")
    28  		orgName = helpers.NewOrgName()
    29  		sourceSpaceName = helpers.NewSpaceName()
    30  		helpers.SetupCF(orgName, sourceSpaceName)
    31  
    32  		domain := helpers.DefaultSharedDomain()
    33  		service = helpers.PrefixedRandomName("SERVICE")
    34  		servicePlan = helpers.PrefixedRandomName("SERVICE-PLAN")
    35  		broker = helpers.CreateBroker(domain, service, servicePlan)
    36  
    37  		Eventually(helpers.CF("enable-service-access", service)).Should(Exit(0))
    38  		Eventually(helpers.CF("create-service", service, servicePlan, serviceInstanceName)).Should(Exit(0))
    39  	})
    40  
    41  	AfterEach(func() {
    42  		// need to login as admin
    43  		helpers.LoginCF()
    44  		helpers.TargetOrgAndSpace(orgName, sourceSpaceName)
    45  		broker.Destroy()
    46  		helpers.QuickDeleteOrg(orgName)
    47  	})
    48  
    49  	Context("service is shared between two spaces", func() {
    50  		var (
    51  			targetSpaceName string
    52  		)
    53  
    54  		BeforeEach(func() {
    55  			targetSpaceName = helpers.NewSpaceName()
    56  			helpers.CreateOrgAndSpace(orgName, targetSpaceName)
    57  			helpers.TargetOrgAndSpace(orgName, sourceSpaceName)
    58  			Eventually(helpers.CF("share-service", serviceInstanceName, "-s", targetSpaceName)).Should(Exit(0))
    59  		})
    60  
    61  		Context("due to global settings of service sharing disabled", func() {
    62  			BeforeEach(func() {
    63  				helpers.DisableFeatureFlag("service_instance_sharing")
    64  			})
    65  
    66  			AfterEach(func() {
    67  				helpers.EnableFeatureFlag("service_instance_sharing")
    68  			})
    69  
    70  			It("should display that the service instance feature flag is disabled", func() {
    71  				session := helpers.CF("service", serviceInstanceName)
    72  				Eventually(session).Should(Say(`The "service_instance_sharing" feature flag is disabled for this Cloud Foundry platform.`))
    73  				Eventually(session).Should(Exit(0))
    74  			})
    75  
    76  			Context("AND service broker does not allow service instance sharing", func() {
    77  				BeforeEach(func() {
    78  					broker.Configure(false)
    79  					broker.Update()
    80  				})
    81  
    82  				It("should display that service instance sharing is disabled for this service (global message)", func() {
    83  					session := helpers.CF("service", serviceInstanceName)
    84  					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.`))
    85  					Eventually(session).Should(Exit(0))
    86  				})
    87  			})
    88  		})
    89  	})
    90  })