Skip to content

Commit 54991c7

Browse files
[api][handlers] Stub isolation_segment related endpoints (#4252)
* [api][handlers] Stub isolation_segment related endpoints * [api][handlers] Add e2e tests for stubbed isolation_segment related endpoints
1 parent 14b0a97 commit 54991c7

File tree

5 files changed

+69
-7
lines changed

5 files changed

+69
-7
lines changed

api/handlers/org.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ import (
2121
)
2222

2323
const (
24-
OrgsPath = "/v3/organizations"
25-
OrgPath = "/v3/organizations/{guid}"
26-
OrgDomainsPath = "/v3/organizations/{guid}/domains"
27-
OrgDefaultDomainPath = "/v3/organizations/{guid}/domains/default"
24+
OrgsPath = "/v3/organizations"
25+
OrgPath = "/v3/organizations/{guid}"
26+
OrgDomainsPath = "/v3/organizations/{guid}/domains"
27+
OrgDefaultDomainPath = "/v3/organizations/{guid}/domains/default"
28+
OrgIsolationSegmentsPath = "/v3/organizations/{guid}/relationships/default_isolation_segment"
2829
)
2930

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

211+
func (h *Org) getIsolationSegments(r *http.Request) (*routing.Response, error) {
212+
return routing.NewResponse(http.StatusOK).WithBody(presenter.ForIsolationSegment(h.apiBaseURL)), nil
213+
}
214+
210215
func (h *Org) AuthenticatedRoutes() []routing.Route {
211216
return []routing.Route{
212217
{Method: "GET", Pattern: OrgsPath, Handler: h.list},
@@ -216,6 +221,7 @@ func (h *Org) AuthenticatedRoutes() []routing.Route {
216221
{Method: "GET", Pattern: OrgDomainsPath, Handler: h.listDomains},
217222
{Method: "GET", Pattern: OrgDefaultDomainPath, Handler: h.defaultDomain},
218223
{Method: "GET", Pattern: OrgPath, Handler: h.get},
224+
{Method: "GET", Pattern: OrgIsolationSegmentsPath, Handler: h.getIsolationSegments},
219225
}
220226
}
221227

api/handlers/space.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ import (
1818
)
1919

2020
const (
21-
SpacesPath = "/v3/spaces"
22-
SpacePath = "/v3/spaces/{guid}"
23-
RoutesForSpacePath = "/v3/spaces/{guid}/routes"
21+
SpacesPath = "/v3/spaces"
22+
SpacePath = "/v3/spaces/{guid}"
23+
RoutesForSpacePath = "/v3/spaces/{guid}/routes"
24+
IsolationSegmentsForSpacePath = "/v3/spaces/{guid}/relationships/isolation_segment"
2425
)
2526

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

201+
func (h *Space) getIsolationSegments(r *http.Request) (*routing.Response, error) {
202+
return routing.NewResponse(http.StatusOK).WithBody(presenter.ForIsolationSegment(h.apiBaseURL)), nil
203+
}
204+
200205
func (h *Space) UnauthenticatedRoutes() []routing.Route {
201206
return nil
202207
}
@@ -209,5 +214,6 @@ func (h *Space) AuthenticatedRoutes() []routing.Route {
209214
{Method: "DELETE", Pattern: SpacePath, Handler: h.delete},
210215
{Method: "GET", Pattern: SpacePath, Handler: h.get},
211216
{Method: "DELETE", Pattern: RoutesForSpacePath, Handler: h.deleteUnmappedRoutes},
217+
{Method: "GET", Pattern: IsolationSegmentsForSpacePath, Handler: h.getIsolationSegments},
212218
}
213219
}

api/presenter/isolation_segment.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package presenter
2+
3+
import (
4+
"net/url"
5+
)
6+
7+
type IsolationSegmentResponse struct{}
8+
9+
func ForIsolationSegment(apiBaseURL url.URL) IsolationSegmentResponse {
10+
return IsolationSegmentResponse{}
11+
}

tests/e2e/orgs_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,20 @@ var _ = Describe("Orgs", func() {
266266
Expect(result.GUID).To(Equal(commonTestOrgGUID))
267267
})
268268
})
269+
270+
Describe("default isolation segment", func() {
271+
var result resource
272+
273+
JustBeforeEach(func() {
274+
var err error
275+
resp, err = adminClient.R().
276+
SetResult(&result).
277+
Get("/v3/organizations/" + commonTestOrgGUID + "/relationships/default_isolation_segment")
278+
Expect(err).NotTo(HaveOccurred())
279+
})
280+
281+
It("returns StatusOK", func() {
282+
Expect(resp).To(HaveRestyStatusCode(http.StatusOK))
283+
})
284+
})
269285
})

tests/e2e/spaces_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,4 +424,27 @@ var _ = Describe("Spaces", func() {
424424
Expect(result.GUID).To(Equal(spaceGUID))
425425
})
426426
})
427+
428+
Describe("isolation_segment", func() {
429+
var (
430+
spaceGUID string
431+
result resource
432+
)
433+
434+
BeforeEach(func() {
435+
spaceGUID = createSpace(generateGUID("space"), commonTestOrgGUID)
436+
})
437+
438+
JustBeforeEach(func() {
439+
var err error
440+
resp, err = adminClient.R().
441+
SetResult(&result).
442+
Get("/v3/spaces/" + spaceGUID + "/relationships/isolation_segment")
443+
Expect(err).NotTo(HaveOccurred())
444+
})
445+
446+
It("returns StatusOK", func() {
447+
Expect(resp).To(HaveRestyStatusCode(http.StatusOK))
448+
})
449+
})
427450
})

0 commit comments

Comments
 (0)