github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/integration/shared/isolated/rename_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  	"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("rename-service command", func() {
    14  	When("there is a service instance created", func() {
    15  		var (
    16  			instanceName string
    17  			serviceName  string
    18  			orgName      string
    19  			spaceName    string
    20  			broker       *fakeservicebroker.FakeServiceBroker
    21  		)
    22  
    23  		BeforeEach(func() {
    24  			instanceName = helpers.PrefixedRandomName("INSTANCE")
    25  			orgName = helpers.NewOrgName()
    26  			spaceName = helpers.NewSpaceName()
    27  			helpers.SetupCF(orgName, spaceName)
    28  
    29  			broker = fakeservicebroker.New().EnsureBrokerIsAvailable()
    30  			serviceName = broker.ServiceName()
    31  
    32  			Eventually(helpers.CF("enable-service-access", serviceName)).Should(Exit(0))
    33  			Eventually(helpers.CF("create-service", serviceName, broker.ServicePlanName(), instanceName)).Should(Exit(0))
    34  		})
    35  
    36  		AfterEach(func() {
    37  			Eventually(helpers.CF("delete-service", "my-new-instance-name", "-f")).Should(Exit(0))
    38  			broker.Destroy()
    39  			helpers.QuickDeleteOrg(orgName)
    40  		})
    41  
    42  		When("and that service access is revoked for a non-admin user", func() {
    43  			var unprivilegedUsername string
    44  
    45  			BeforeEach(func() {
    46  				Eventually(helpers.CF("disable-service-access", serviceName)).Should(Exit(0))
    47  
    48  				var password string
    49  				unprivilegedUsername, password = helpers.CreateUserInSpaceRole(orgName, spaceName, "SpaceDeveloper")
    50  				helpers.LogoutCF()
    51  				helpers.LoginAs(unprivilegedUsername, password)
    52  				helpers.TargetOrgAndSpace(orgName, spaceName)
    53  			})
    54  
    55  			AfterEach(func() {
    56  				helpers.LoginCF()
    57  				helpers.TargetOrgAndSpace(orgName, spaceName)
    58  				helpers.DeleteUser(unprivilegedUsername)
    59  			})
    60  
    61  			When("CC API allows updating a service when plan is not visible", func() {
    62  				BeforeEach(func() {
    63  					helpers.SkipIfVersionLessThan(ccversion.MinVersionUpdateServiceNameWhenPlanNotVisibleV2)
    64  				})
    65  
    66  				It("can still rename the service", func() {
    67  					session := helpers.CF("rename-service", instanceName, "my-new-instance-name")
    68  					Eventually(session).Should(Exit(0))
    69  
    70  					session = helpers.CF("services")
    71  					Eventually(session).Should(Exit(0))
    72  					Eventually(session).Should(Say("my-new-instance-name"))
    73  				})
    74  			})
    75  		})
    76  	})
    77  })