Пример #1
0
			space.Guid = "the-old-space-guid"
			reqFactory.Space = space
		})

		It("renames a space", func() {
			originalSpaceName := configRepo.SpaceFields().Name
			callRenameSpace([]string{"the-old-space-name", "my-new-space"})

			testassert.SliceContains(ui.Outputs, testassert.Lines{
				{"Renaming space", "the-old-space-name", "my-new-space", "my-org", "my-user"},
				{"OK"},
			})

			Expect(spaceRepo.RenameSpaceGuid).To(Equal("the-old-space-guid"))
			Expect(spaceRepo.RenameNewName).To(Equal("my-new-space"))
			Expect(configRepo.SpaceFields().Name).To(Equal(originalSpaceName))
		})

		Describe("renaming the space the user has targeted", func() {
			BeforeEach(func() {
				configRepo.SetSpaceFields(reqFactory.Space.SpaceFields)
			})

			It("renames the targeted space", func() {
				callRenameSpace([]string{"the-old-space-name", "my-new-space-name"})
				Expect(configRepo.SpaceFields().Name).To(Equal("my-new-space-name"))
			})
		})
	})
})
Пример #2
0
						Name: "org-name",
						Guid: "org-guid",
					})
				})

				It("tells the user which org is targeted", func() {
					testassert.SliceContains(output, testassert.Lines{
						{"Org:", "org-name"},
					})
				})
			})

			Context("when a space is targeted", func() {
				BeforeEach(func() {
					config.SetSpaceFields(models.SpaceFields{
						Name: "my-space",
						Guid: "space-guid",
					})
				})

				It("tells the user which space is targeted", func() {
					testassert.SliceContains(output, testassert.Lines{
						{"Space:", "my-space"},
					})
				})
			})
		})

		It("prompts the user to target an org and space when no org or space is targeted", func() {
			output := captureOutput(func() {
				ui := NewUI(os.Stdin)
				ui.ShowConfiguration(config)
Пример #3
0
			space := models.Space{}
			space.Name = "my-space"
			space.Guid = "my-space-guid"

			spaceRepo.Spaces = []models.Space{space}
			spaceRepo.FindByNameSpace = space

			ui := callTarget([]string{"-s", "my-space"}, reqFactory, config, orgRepo, spaceRepo)

			Expect(spaceRepo.FindByNameName).To(Equal("my-space"))
			Expect(config.SpaceFields().Guid).To(Equal("my-space-guid"))
			Expect(ui.ShowConfigurationCalled).To(BeTrue())
		})

		It("TestTargetSpaceWhenUserDoesNotHaveAccess", func() {
			config.SetSpaceFields(models.SpaceFields{})
			spaceRepo.FindByNameErr = true

			ui := callTarget([]string{"-s", "my-space"}, reqFactory, config, orgRepo, spaceRepo)

			testassert.SliceContains(ui.Outputs, testassert.Lines{
				{"FAILED"},
				{"Unable to access space", "my-space"},
			})

			Expect(config.SpaceFields().Guid).To(Equal(""))
			Expect(ui.ShowConfigurationCalled).To(BeFalse())
		})

		It("TestTargetSpaceWhenSpaceNotFound", func() {
			spaceRepo.FindByNameNotFound = true
Пример #4
0
	})

	Describe("updating the endpoints", func() {
		It("stores the data from the /info api in the config", func() {
			testServerFn = validApiInfoEndpoint

			org := models.OrganizationFields{}
			org.Name = "my-org"
			org.Guid = "my-org-guid"

			space := models.SpaceFields{}
			space.Name = "my-space"
			space.Guid = "my-space-guid"

			config.SetOrganizationFields(org)
			config.SetSpaceFields(space)

			repo.UpdateEndpoint(testServer.URL)

			Expect(config.AccessToken()).To(Equal(""))
			Expect(config.AuthorizationEndpoint()).To(Equal("https://login.example.com"))
			Expect(config.LoggregatorEndpoint()).To(Equal("wss://loggregator.foo.example.org:4443"))
			Expect(config.ApiEndpoint()).To(Equal(testServer.URL))
			Expect(config.ApiVersion()).To(Equal("42.0.0"))
			Expect(config.HasOrganization()).To(BeFalse())
			Expect(config.HasSpace()).To(BeFalse())
		})

		It("TestUpdateEndpointWhenUrlIsAlreadyTargeted", func() {
			testServerFn = validApiInfoEndpoint
Пример #5
0
			reqFactory.ApiEndpointSuccess = false

			testcmd.RunCommand(cmd, testcmd.NewContext("marketplace", []string{}), reqFactory)
			Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
		})
	})

	Context("when the user is logged in", func() {
		BeforeEach(func() {
			config = testconfig.NewRepositoryWithDefaults()
		})

		Context("when the user has a space targeted", func() {
			BeforeEach(func() {
				config.SetSpaceFields(models.SpaceFields{
					Guid: "the-space-guid",
					Name: "the-space-name",
				})
			})

			It("lists all of the service offerings for the space", func() {
				serviceRepo := &testapi.FakeServiceRepo{}
				serviceRepo.GetServiceOfferingsForSpaceReturns.ServiceOfferings = fakeServiceOfferings
				cmd := NewMarketplaceServices(ui, config, serviceRepo)
				testcmd.RunCommand(cmd, testcmd.NewContext("marketplace", []string{}), reqFactory)

				Expect(serviceRepo.GetServiceOfferingsForSpaceArgs.SpaceGuid).To(Equal("the-space-guid"))

				testassert.SliceContains(ui.Outputs, testassert.Lines{
					{"Getting services from marketplace in org", "my-org", "the-space-name", "my-user"},
					{"OK"},
					{"service", "plans", "description"},
Пример #6
0
			space.Guid = "the-old-space-guid"
			requirementsFactory.Space = space
		})

		It("renames a space", func() {
			originalSpaceName := configRepo.SpaceFields().Name
			callRenameSpace([]string{"the-old-space-name", "my-new-space"})

			testassert.SliceContains(ui.Outputs, testassert.Lines{
				{"Renaming space", "the-old-space-name", "my-new-space", "my-org", "my-user"},
				{"OK"},
			})

			Expect(spaceRepo.RenameSpaceGuid).To(Equal("the-old-space-guid"))
			Expect(spaceRepo.RenameNewName).To(Equal("my-new-space"))
			Expect(configRepo.SpaceFields().Name).To(Equal(originalSpaceName))
		})

		Describe("renaming the space the user has targeted", func() {
			BeforeEach(func() {
				configRepo.SetSpaceFields(requirementsFactory.Space.SpaceFields)
			})

			It("renames the targeted space", func() {
				callRenameSpace([]string{"the-old-space-name", "my-new-space-name"})
				Expect(configRepo.SpaceFields().Name).To(Equal("my-new-space-name"))
			})
		})
	})
})
Пример #7
0
		testassert.SliceContains(ui.Prompts, testassert.Lines{
			{"Really delete the space space-to-delete"},
		})
		testassert.SliceContains(ui.Outputs, testassert.Lines{
			{"Deleting space", "space-to-delete", "my-org", "my-user"},
			{"OK"},
		})
		Expect(spaceRepo.DeletedSpaceGuid).To(Equal("space-to-delete-guid"))
		Expect(config.HasSpace()).To(Equal(true))
	})

	It("does not prompt when the -f flag is given", func() {
		runCommand("-f", "space-to-delete")

		Expect(ui.Prompts).To(BeEmpty())
		testassert.SliceContains(ui.Outputs, testassert.Lines{
			{"Deleting", "space-to-delete"},
			{"OK"},
		})
		Expect(spaceRepo.DeletedSpaceGuid).To(Equal("space-to-delete-guid"))
	})

	It("clears the space from the config, when deleting the space currently targeted", func() {
		config.SetSpaceFields(space.SpaceFields)
		runCommand("-f", "space-to-delete")

		Expect(config.HasSpace()).To(Equal(false))
	})
})
Пример #8
0
			Expect(Config.SpaceFields().Guid).To(Equal("my-space-guid"))
			Expect(Config.AccessToken()).To(Equal("my_access_token"))
			Expect(Config.RefreshToken()).To(Equal("my_refresh_token"))

			Expect(endpointRepo.UpdateEndpointReceived).To(Equal("http://api.example.com"))
			Expect(authRepo.AuthenticateArgs.Credentials).To(Equal(map[string]string{
				"username": "******",
				"password": "******",
			}))

			Expect(ui.ShowConfigurationCalled).To(BeTrue())
		})

		It("uses the org and space from the config file if they are present", func() {
			Config.SetOrganizationFields(org2.OrganizationFields)
			Config.SetSpaceFields(space2.SpaceFields)

			ui.Inputs = []string{"http://api.example.com", "*****@*****.**", "password"}

			orgRepo.FindByNameOrganization = models.Organization{}
			spaceRepo.FindByNameInOrgSpace = models.Space{}

			l := NewLogin(ui, Config, authRepo, endpointRepo, orgRepo, spaceRepo)
			testcmd.RunCommand(l, testcmd.NewContext("login", Flags), nil)

			Expect(Config.ApiEndpoint()).To(Equal("http://api.example.com"))
			Expect(Config.OrganizationFields().Guid).To(Equal("my-org-guid"))
			Expect(Config.SpaceFields().Guid).To(Equal("some-space-guid"))
			Expect(Config.AccessToken()).To(Equal("my_access_token"))
			Expect(Config.RefreshToken()).To(Equal("my_refresh_token"))