Ejemplo n.º 1
0
			It("creates a public zone and ignores org", func() {
				runCommand("--public", "-o", "my-org", "my-zone", "50")
				Expect(ui.Outputs).To(ContainSubstrings(
					[]string{"Creating public zone", "my-zone"},
					[]string{"OK"},
				))
				Expect(*zoneRepo.CreateZoneParams.IsPublic).To(BeTrue())
				Expect(zoneRepo.CreateZoneParams.OrgGuid).To(BeNil())
			})
		})

		Context("when the --public flag is not provided", func() {
			It("fails without a targeting or given org", func() {
				org := maker.NewOrg(maker.Overrides{"name": "", "guid": ""})
				config.SetOrganizationFields(org.OrganizationFields)

				orgRepo.FindByNameReturns(models.Organization{}, errors.New("Error finding organization by name."))

				runCommand("my-zone", "50")
				Expect(ui.Outputs).To(ContainSubstrings(
					[]string{"FAILED"},
					[]string{"Error finding organization by name."},
				))
			})

			It("creates a private zone with the given org", func() {
				//org := maker.NewOrg(maker.Overrides{"name": "my-org", "guid": "my-org-guid"})
				//orgRepo.Organizations = []models.Organization{org}
				org := maker.NewOrg(maker.Overrides{"name": "my-org", "guid": "my-org-guid"})
				config.SetOrganizationFields(org.OrganizationFields)
Ejemplo n.º 2
0
	. "github.com/nttlabs/cli/cf/requirements"
	testassert "github.com/nttlabs/cli/testhelpers/assert"
	testconfig "github.com/nttlabs/cli/testhelpers/configuration"
	testterm "github.com/nttlabs/cli/testhelpers/terminal"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("DomainRequirement", func() {
	var config core_config.ReadWriter
	var ui *testterm.FakeUI

	BeforeEach(func() {
		ui = new(testterm.FakeUI)
		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 := &testapi.FakeDomainRepository{FindByNameInOrgDomain: domain}
		domainReq := NewDomainRequirement("example.com", ui, config, domainRepo)
		success := domainReq.Execute()

		Expect(success).To(BeTrue())
		Expect(domainRepo.FindByNameInOrgName).To(Equal("example.com"))
		Expect(domainRepo.FindByNameInOrgGuid).To(Equal("the-org-guid"))
		Expect(domainReq.GetDomain()).To(Equal(domain))
	})

	It("fails when the domain is not found", func() {
Ejemplo n.º 3
0
		})

		It("renames an organization", func() {
			targetedOrgName := configRepo.OrganizationFields().Name
			callRenameOrg([]string{"the-old-org-name", "the-new-org-name"})
			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Renaming org", "the-old-org-name", "the-new-org-name", "my-user"},
				[]string{"OK"},
			))

			guid, name := orgRepo.RenameArgsForCall(0)

			Expect(requirementsFactory.OrganizationName).To(Equal("the-old-org-name"))
			Expect(guid).To(Equal("the-old-org-guid"))
			Expect(name).To(Equal("the-new-org-name"))
			Expect(configRepo.OrganizationFields().Name).To(Equal(targetedOrgName))
		})

		Describe("when the organization is currently targeted", func() {
			It("updates the name of the org in the config", func() {
				configRepo.SetOrganizationFields(models.OrganizationFields{
					Guid: "the-old-org-guid",
					Name: "the-old-org-name",
				})
				callRenameOrg([]string{"the-old-org-name", "the-new-org-name"})
				Expect(configRepo.OrganizationFields().Name).To(Equal("the-new-org-name"))
			})
		})
	})
})
Ejemplo n.º 4
0
	)

	BeforeEach(func() {
		ui = new(testterm.FakeUI)
		config = testconfig.NewRepositoryWithDefaults()
	})

	Context("when the user has an org targeted", func() {
		It("succeeds", func() {
			req := NewTargetedOrgRequirement(ui, config)
			success := req.Execute()
			Expect(success).To(BeTrue())
		})
	})

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

			testassert.AssertPanic(testterm.QuietPanic, func() {
				NewTargetedOrgRequirement(ui, config).Execute()
			})

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"FAILED"},
				[]string{"No org targeted"},
			))
		})
	})
})
Ejemplo n.º 5
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",
					})
				})