Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions api/handlers/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import (
)

const (
OrgsPath = "/v3/organizations"
OrgPath = "/v3/organizations/{guid}"
OrgDomainsPath = "/v3/organizations/{guid}/domains"
OrgDefaultDomainPath = "/v3/organizations/{guid}/domains/default"
OrgsPath = "/v3/organizations"
OrgPath = "/v3/organizations/{guid}"
OrgDomainsPath = "/v3/organizations/{guid}/domains"
OrgDefaultDomainPath = "/v3/organizations/{guid}/domains/default"
OrgIsolationSegmentsPath = "/v3/organizations/{guid}/relationships/default_isolation_segment"
)

//counterfeiter:generate -o fake -fake-name CFOrgRepository . CFOrgRepository
Expand Down Expand Up @@ -207,6 +208,10 @@ func (h *Org) UnauthenticatedRoutes() []routing.Route {
return nil
}

func (h *Org) getIsolationSegments(r *http.Request) (*routing.Response, error) {
return routing.NewResponse(http.StatusOK).WithBody(presenter.ForIsolationSegment(h.apiBaseURL)), nil
}

func (h *Org) AuthenticatedRoutes() []routing.Route {
return []routing.Route{
{Method: "GET", Pattern: OrgsPath, Handler: h.list},
Expand All @@ -216,6 +221,7 @@ func (h *Org) AuthenticatedRoutes() []routing.Route {
{Method: "GET", Pattern: OrgDomainsPath, Handler: h.listDomains},
{Method: "GET", Pattern: OrgDefaultDomainPath, Handler: h.defaultDomain},
{Method: "GET", Pattern: OrgPath, Handler: h.get},
{Method: "GET", Pattern: OrgIsolationSegmentsPath, Handler: h.getIsolationSegments},
}
}

Expand Down
12 changes: 9 additions & 3 deletions api/handlers/space.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import (
)

const (
SpacesPath = "/v3/spaces"
SpacePath = "/v3/spaces/{guid}"
RoutesForSpacePath = "/v3/spaces/{guid}/routes"
SpacesPath = "/v3/spaces"
SpacePath = "/v3/spaces/{guid}"
RoutesForSpacePath = "/v3/spaces/{guid}/routes"
IsolationSegmentsForSpacePath = "/v3/spaces/{guid}/relationships/isolation_segment"
)

//counterfeiter:generate -o fake -fake-name CFSpaceRepository . CFSpaceRepository
Expand Down Expand Up @@ -197,6 +198,10 @@ func (h *Space) deleteUnmappedRoutes(r *http.Request) (*routing.Response, error)
return routing.NewResponse(http.StatusAccepted).WithHeader("Location", presenter.JobURLForRedirects(spaceGUID, presenter.SpaceDeleteUnmappedRoutesOperation, h.apiBaseURL)), nil
}

func (h *Space) getIsolationSegments(r *http.Request) (*routing.Response, error) {
return routing.NewResponse(http.StatusOK).WithBody(presenter.ForIsolationSegment(h.apiBaseURL)), nil
}

func (h *Space) UnauthenticatedRoutes() []routing.Route {
return nil
}
Expand All @@ -209,5 +214,6 @@ func (h *Space) AuthenticatedRoutes() []routing.Route {
{Method: "DELETE", Pattern: SpacePath, Handler: h.delete},
{Method: "GET", Pattern: SpacePath, Handler: h.get},
{Method: "DELETE", Pattern: RoutesForSpacePath, Handler: h.deleteUnmappedRoutes},
{Method: "GET", Pattern: IsolationSegmentsForSpacePath, Handler: h.getIsolationSegments},
}
}
11 changes: 11 additions & 0 deletions api/presenter/isolation_segment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package presenter

import (
"net/url"
)

type IsolationSegmentResponse struct{}

func ForIsolationSegment(apiBaseURL url.URL) IsolationSegmentResponse {
return IsolationSegmentResponse{}
}
16 changes: 16 additions & 0 deletions tests/e2e/orgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,20 @@ var _ = Describe("Orgs", func() {
Expect(result.GUID).To(Equal(commonTestOrgGUID))
})
})

Describe("default isolation segment", func() {
var result resource

JustBeforeEach(func() {
var err error
resp, err = adminClient.R().
SetResult(&result).
Get("/v3/organizations/" + commonTestOrgGUID + "/relationships/default_isolation_segment")
Expect(err).NotTo(HaveOccurred())
})

It("returns StatusOK", func() {
Expect(resp).To(HaveRestyStatusCode(http.StatusOK))
})
})
})
23 changes: 23 additions & 0 deletions tests/e2e/spaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,4 +424,27 @@ var _ = Describe("Spaces", func() {
Expect(result.GUID).To(Equal(spaceGUID))
})
})

Describe("isolation_segment", func() {
var (
spaceGUID string
result resource
)

BeforeEach(func() {
spaceGUID = createSpace(generateGUID("space"), commonTestOrgGUID)
})

JustBeforeEach(func() {
var err error
resp, err = adminClient.R().
SetResult(&result).
Get("/v3/spaces/" + spaceGUID + "/relationships/isolation_segment")
Expect(err).NotTo(HaveOccurred())
})

It("returns StatusOK", func() {
Expect(resp).To(HaveRestyStatusCode(http.StatusOK))
})
})
})
Loading