Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit 8b82f94

Browse files
Service Plan Visibilities V3 migration (#151)
1 parent 08aeec0 commit 8b82f94

File tree

10 files changed

+1193
-1506
lines changed

10 files changed

+1193
-1506
lines changed

cf/cache_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package cf_test
22

33
import (
44
"context"
5+
"github.com/Peripli/service-broker-proxy/pkg/platform"
56
"net/http"
67
"regexp"
78
"strings"
89

910
"github.com/Peripli/service-broker-proxy-cf/cf"
10-
"github.com/Peripli/service-broker-proxy/pkg/platform"
1111
"github.com/Peripli/service-manager/pkg/log"
1212
cfclient "github.com/cloudfoundry-community/go-cfclient"
1313
. "github.com/onsi/ginkgo"
@@ -32,6 +32,8 @@ var _ = Describe("Cache", func() {
3232
brokersRequest, servicesRequest, plansRequest, visibilitiesRequest *http.Request
3333

3434
broker1, broker2 brokerData
35+
36+
requestPlanIds []string
3537
)
3638

3739
recordRequest := func(r **http.Request) http.HandlerFunc {
@@ -75,6 +77,9 @@ var _ = Describe("Cache", func() {
7577
servicesResponse.Count = len(servicesResponse.Resources)
7678
plansResponse.Count = len(plansResponse.Resources)
7779

80+
visibilitiesRequestPath := regexp.MustCompile(`/v3/service_plans/(?P<guid>[A-Za-z0-9_-]+)/visibility`)
81+
planIdExtractor := strings.NewReplacer("/v3/service_plans/", "", "/visibility", "")
82+
7883
ccServer.RouteToHandler(http.MethodGet, "/v2/service_brokers",
7984
ghttp.CombineHandlers(
8085
recordRequest(&brokersRequest),
@@ -93,13 +98,16 @@ var _ = Describe("Cache", func() {
9398
ghttp.RespondWithJSONEncoded(http.StatusOK, plansResponse),
9499
),
95100
)
96-
ccServer.RouteToHandler(http.MethodGet, "/v2/service_plan_visibilities",
101+
ccServer.RouteToHandler(http.MethodGet, visibilitiesRequestPath,
97102
ghttp.CombineHandlers(
98103
recordRequest(&visibilitiesRequest),
99104
ghttp.RespondWithJSONEncoded(http.StatusOK, cfclient.ServicePlanVisibilitiesResponse{
100105
Count: 0,
101106
Pages: 0,
102107
}),
108+
func(writer http.ResponseWriter, request *http.Request) {
109+
requestPlanIds = append(requestPlanIds, planIdExtractor.Replace(request.RequestURI))
110+
},
103111
),
104112
)
105113
}
@@ -117,8 +125,9 @@ var _ = Describe("Cache", func() {
117125
}
118126

119127
getPlanGUIDS := func() []string {
128+
requestPlanIds = nil
120129
client.GetVisibilitiesByBrokers(ctx, []string{"broker1", "broker2"})
121-
return getRequestGUIDS(visibilitiesRequest, "service_plan_guid")
130+
return requestPlanIds
122131
}
123132

124133
clearRequests := func() {
@@ -203,7 +212,6 @@ var _ = Describe("Cache", func() {
203212
setupCCRoutes(broker1, broker2)
204213

205214
Expect(client.ResetCache(ctx)).To(Succeed())
206-
207215
Expect(getPlanGUIDS()).To(ConsistOf([]string{
208216
"broker1-service1-plan1-guid",
209217
"broker1-service2-plan1-guid",

0 commit comments

Comments
 (0)