Skip to content

Commit 46c1c2a

Browse files
4244 stub security group space endpoints (#4266)
fixes #4244
1 parent d21b5fc commit 46c1c2a

File tree

3 files changed

+75
-5
lines changed

3 files changed

+75
-5
lines changed

api/handlers/space.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ import (
1919
)
2020

2121
const (
22-
SpacesPath = "/v3/spaces"
23-
SpacePath = "/v3/spaces/{guid}"
24-
RoutesForSpacePath = "/v3/spaces/{guid}/routes"
25-
SpaceFeaturePath = "/v3/spaces/{guid}/features/{name}"
26-
IsolationSegmentForSpacePath = "/v3/spaces/{guid}/relationships/isolation_segment"
22+
SpacesPath = "/v3/spaces"
23+
SpacePath = "/v3/spaces/{guid}"
24+
RoutesForSpacePath = "/v3/spaces/{guid}/routes"
25+
SpaceFeaturePath = "/v3/spaces/{guid}/features/{name}"
26+
IsolationSegmentForSpacePath = "/v3/spaces/{guid}/relationships/isolation_segment"
27+
RunningSecurityGroupsForSpacePath = "/v3/spaces/{guid}/running_security_groups"
28+
StagingSecurityGroupsForSpacePath = "/v3/spaces/{guid}/staging_security_groups"
2729
)
2830

2931
//counterfeiter:generate -o fake -fake-name CFSpaceRepository . CFSpaceRepository
@@ -204,6 +206,14 @@ func (h *Space) getIsolationSegment(r *http.Request) (*routing.Response, error)
204206
return routing.NewResponse(http.StatusOK).WithBody(struct{}{}), nil
205207
}
206208

209+
func (h *Space) getRunningSecurityGroups(r *http.Request) (*routing.Response, error) {
210+
return routing.NewResponse(http.StatusOK).WithBody(presenter.ForList(presenter.Empty, repositories.ListResult[any]{}, h.apiBaseURL, *r.URL)), nil
211+
}
212+
213+
func (h *Space) getStagingSecurityGroups(r *http.Request) (*routing.Response, error) {
214+
return routing.NewResponse(http.StatusOK).WithBody(presenter.ForList(presenter.Empty, repositories.ListResult[any]{}, h.apiBaseURL, *r.URL)), nil
215+
}
216+
207217
func (h *Space) getSpaceFeature(r *http.Request) (*routing.Response, error) {
208218
logger := logr.FromContextOrDiscard(r.Context()).WithName("handlers.space.get-feature")
209219

@@ -232,6 +242,8 @@ func (h *Space) AuthenticatedRoutes() []routing.Route {
232242
{Method: "GET", Pattern: SpacePath, Handler: h.get},
233243
{Method: "DELETE", Pattern: RoutesForSpacePath, Handler: h.deleteUnmappedRoutes},
234244
{Method: "GET", Pattern: IsolationSegmentForSpacePath, Handler: h.getIsolationSegment},
245+
{Method: "GET", Pattern: RunningSecurityGroupsForSpacePath, Handler: h.getRunningSecurityGroups},
246+
{Method: "GET", Pattern: StagingSecurityGroupsForSpacePath, Handler: h.getStagingSecurityGroups},
235247
{Method: "GET", Pattern: SpaceFeaturePath, Handler: h.getSpaceFeature},
236248
}
237249
}

tests/e2e/spaces_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,4 +474,50 @@ var _ = Describe("Spaces", func() {
474474
Expect(respUnmarshalled).To(HaveKeyWithValue("enabled", BeFalse()))
475475
})
476476
})
477+
478+
Describe("running_security_groups", func() {
479+
var (
480+
spaceGUID string
481+
result resource
482+
)
483+
484+
BeforeEach(func() {
485+
spaceGUID = createSpace(generateGUID("space"), commonTestOrgGUID)
486+
})
487+
488+
JustBeforeEach(func() {
489+
var err error
490+
resp, err = adminClient.R().
491+
SetResult(&result).
492+
Get("/v3/spaces/" + spaceGUID + "/running_security_groups")
493+
Expect(err).NotTo(HaveOccurred())
494+
})
495+
496+
It("returns StatusOK", func() {
497+
Expect(resp).To(HaveRestyStatusCode(http.StatusOK))
498+
})
499+
})
500+
501+
Describe("staging_security_groups", func() {
502+
var (
503+
spaceGUID string
504+
result resource
505+
)
506+
507+
BeforeEach(func() {
508+
spaceGUID = createSpace(generateGUID("space"), commonTestOrgGUID)
509+
})
510+
511+
JustBeforeEach(func() {
512+
var err error
513+
resp, err = adminClient.R().
514+
SetResult(&result).
515+
Get("/v3/spaces/" + spaceGUID + "/staging_security_groups")
516+
Expect(err).NotTo(HaveOccurred())
517+
})
518+
519+
It("returns StatusOK", func() {
520+
Expect(resp).To(HaveRestyStatusCode(http.StatusOK))
521+
})
522+
})
477523
})

tests/smoke/spaces_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,16 @@ var _ = Describe("Spaces", func() {
3535
))
3636
})
3737
})
38+
39+
Describe("cf space", func() {
40+
It("returns successful", func() {
41+
session := helpers.Cf("space", spaceName)
42+
Expect(session).To(Exit(0))
43+
44+
lines := it.MustCollect(it.LinesString(session.Out))
45+
Expect(lines).To(ContainElement(
46+
matchSubstrings(spaceName),
47+
))
48+
})
49+
})
3850
})

0 commit comments

Comments
 (0)