Skip to content

Commit

Permalink
Forcing default domain to be the first shared domain.
Browse files Browse the repository at this point in the history
Closes cloudfoundry#209
[Finishes #75067850]
  • Loading branch information
Anand Gaitonde and Christopher Piraino authored and Anand Gaitonde and Christopher Piraino committed Jul 15, 2014
1 parent bf79f7f commit a739b71
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
4 changes: 2 additions & 2 deletions cf/api/domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ func NewCloudControllerDomainRepository(config configuration.Reader, gateway net
}

func (repo CloudControllerDomainRepository) ListDomainsForOrg(orgGuid string, cb func(models.DomainFields) bool) error {
err := repo.listDomains(repo.strategy.SharedDomainsURL(), cb)
err := repo.listDomains(repo.strategy.PrivateDomainsByOrgURL(orgGuid), cb)
if err != nil {
return err
}
err = repo.listDomains(repo.strategy.PrivateDomainsByOrgURL(orgGuid), cb)
err = repo.listDomains(repo.strategy.SharedDomainsURL(), cb)
return err
}

Expand Down
28 changes: 21 additions & 7 deletions cf/api/domains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var _ = Describe("DomainRepository", func() {
Describe("listing domains", func() {
BeforeEach(func() {
config.SetApiVersion("2.2.0")
setupTestServer(firstPageSharedDomainsRequest, secondPageSharedDomainsRequest, firstPagePrivateDomainsRequest, secondPagePrivateDomainsRequest)
setupTestServer(firstPagePrivateDomainsRequest, secondPagePrivateDomainsRequest, firstPageSharedDomainsRequest, secondPageSharedDomainsRequest)
})

It("uses the organization-scoped domains endpoints", func() {
Expand All @@ -62,16 +62,30 @@ var _ = Describe("DomainRepository", func() {

Expect(apiErr).NotTo(HaveOccurred())
Expect(len(receivedDomains)).To(Equal(6))
Expect(receivedDomains[0].Guid).To(Equal("shared-domain1-guid"))
Expect(receivedDomains[1].Guid).To(Equal("shared-domain2-guid"))
Expect(receivedDomains[2].Guid).To(Equal("shared-domain3-guid"))
Expect(receivedDomains[3].Guid).To(Equal("domain1-guid"))
Expect(receivedDomains[4].Guid).To(Equal("domain2-guid"))
Expect(receivedDomains[5].Guid).To(Equal("domain3-guid"))
Expect(receivedDomains[0].Guid).To(Equal("domain1-guid"))
Expect(receivedDomains[1].Guid).To(Equal("domain2-guid"))
Expect(receivedDomains[2].Guid).To(Equal("domain3-guid"))
Expect(receivedDomains[3].Guid).To(Equal("shared-domain1-guid"))
Expect(receivedDomains[4].Guid).To(Equal("shared-domain2-guid"))
Expect(receivedDomains[5].Guid).To(Equal("shared-domain3-guid"))
Expect(handler).To(HaveAllRequestsCalled())
})
})

Describe("getting default domain", func() {
BeforeEach(func() {
config.SetApiVersion("2.2.0")
setupTestServer(firstPagePrivateDomainsRequest, secondPagePrivateDomainsRequest, firstPageSharedDomainsRequest, secondPageSharedDomainsRequest)
})

It("should always return back the first shared domain", func() {
domain, apiErr := repo.FirstOrDefault("my-org-guid", nil)

Expect(apiErr).NotTo(HaveOccurred())
Expect(domain.Guid).To(Equal("shared-domain1-guid"))
})
})

It("finds a domain by name", func() {
setupTestServer(testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "GET",
Expand Down

0 comments on commit a739b71

Please sign in to comment.