Ejemplo n.º 1
0
	})

	Describe("updating the endpoints", func() {
		Context("when the API request is successful", func() {
			var (
				org   models.OrganizationFields
				space models.SpaceFields
			)
			BeforeEach(func() {
				org.Name = "my-org"
				org.GUID = "my-org-guid"

				space.Name = "my-space"
				space.GUID = "my-space-guid"

				coreConfig.SetOrganizationFields(org)
				coreConfig.SetSpaceFields(space)
				testServerFn = validAPIInfoEndpoint
			})

			It("returns the configuration info from /info", func() {
				config, endpoint, err := repo.GetCCInfo(testServer.URL)

				Expect(err).NotTo(HaveOccurred())
				Expect(config.AuthorizationEndpoint).To(Equal("https://login.example.com"))
				Expect(config.LoggregatorEndpoint).To(Equal("wss://loggregator.foo.example.org:4443"))
				Expect(endpoint).To(Equal(testServer.URL))
				Expect(config.SSHOAuthClient).To(Equal("ssh-client-id"))
				Expect(config.APIVersion).To(Equal("42.0.0"))
				Expect(config.MinCLIVersion).To(Equal("6.5.0"))
				Expect(config.MinRecommendedCLIVersion).To(Equal("6.7.0"))
Ejemplo n.º 2
0
			It("tells the user which api endpoint is set", func() {
				Expect(output).To(ContainSubstrings([]string{"API endpoint:", "https://test.example.org"}))
			})

			It("tells the user the api version", func() {
				Expect(output).To(ContainSubstrings([]string{"API version:", "☃☃☃"}))
			})

			It("tells the user which user is logged in", func() {
				Expect(output).To(ContainSubstrings([]string{"User:"******"my-user-email"}))
			})

			Context("when an org is targeted", func() {
				BeforeEach(func() {
					config.SetOrganizationFields(models.OrganizationFields{
						Name: "org-name",
						GUID: "org-guid",
					})
				})

				It("tells the user which org is targeted", func() {
					Expect(output).To(ContainSubstrings([]string{"Org:", "org-name"}))
				})
			})

			Context("when a space is targeted", func() {
				BeforeEach(func() {
					config.SetSpaceFields(models.SpaceFields{
						Name: "my-space",
						GUID: "space-guid",
					})
				})
Ejemplo n.º 3
0
	"code.cloudfoundry.org/cli/cf/api/apifakes"
	"code.cloudfoundry.org/cli/cf/configuration/coreconfig"
	"code.cloudfoundry.org/cli/cf/errors"
	"code.cloudfoundry.org/cli/cf/models"
	. "code.cloudfoundry.org/cli/cf/requirements"
	testconfig "code.cloudfoundry.org/cli/testhelpers/configuration"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("DomainRequirement", func() {
	var config coreconfig.ReadWriter

	BeforeEach(func() {
		config = testconfig.NewRepository()
		config.SetOrganizationFields(models.OrganizationFields{GUID: "the-org-guid"})
	})

	It("succeeds when the domain is found", func() {
		domain := models.DomainFields{Name: "example.com", GUID: "domain-guid"}
		domainRepo := new(apifakes.FakeDomainRepository)
		domainRepo.FindByNameInOrgReturns(domain, nil)
		domainReq := NewDomainRequirement("example.com", config, domainRepo)
		err := domainReq.Execute()

		Expect(err).NotTo(HaveOccurred())
		orgName, orgGUID := domainRepo.FindByNameInOrgArgsForCall(0)
		Expect(orgName).To(Equal("example.com"))
		Expect(orgGUID).To(Equal("the-org-guid"))
		Expect(domainReq.GetDomain()).To(Equal(domain))
	})
Ejemplo n.º 4
0
)

var _ = Describe("TargetedOrganizationRequirement", func() {
	var (
		config coreconfig.ReadWriter
	)

	BeforeEach(func() {
		config = testconfig.NewRepositoryWithDefaults()
	})

	Context("when the user has an org targeted", func() {
		It("succeeds", func() {
			req := NewTargetedOrgRequirement(config)
			err := req.Execute()
			Expect(err).NotTo(HaveOccurred())
		})
	})

	Context("when the user does not have an org targeted", func() {
		It("errors", func() {
			config.SetOrganizationFields(models.OrganizationFields{})

			err := NewTargetedOrgRequirement(config).Execute()

			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(ContainSubstring("No org targeted"))
		})
	})
})