github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+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  	"code.cloudfoundry.org/cli/integration/helpers/fakeservicebroker"
     7  	. "github.com/onsi/ginkgo"
     8  	. "github.com/onsi/gomega"
     9  	. "github.com/onsi/gomega/gbytes"
    10  	. "github.com/onsi/gomega/gexec"
    11  )
    12  
    13  var _ = Describe("service command", func() {
    14  
    15  	var (
    16  		serviceInstanceName string
    17  		orgName             string
    18  		sourceSpaceName     string
    19  
    20  		service     string
    21  		servicePlan string
    22  		broker      *fakeservicebroker.FakeServiceBroker
    23  	)
    24  
    25  	BeforeEach(func() {
    26  		helpers.SkipIfVersionLessThan(ccversion.MinVersionShareServiceV3)
    27  
    28  		serviceInstanceName = helpers.PrefixedRandomName("SI")
    29  		orgName = helpers.NewOrgName()
    30  		sourceSpaceName = helpers.NewSpaceName()
    31  		helpers.SetupCF(orgName, sourceSpaceName)
    32  
    33  		broker = fakeservicebroker.New().EnsureBrokerIsAvailable()
    34  		service = broker.ServiceName()
    35  		servicePlan = broker.ServicePlanName()
    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.Services[0].Metadata.Shareable = 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  })