From 707414d77311d5a48d84650f1103c9f13ddaeb57 Mon Sep 17 00:00:00 2001 From: Jovan Kostovski Date: Mon, 13 Jan 2025 16:56:56 +0100 Subject: [PATCH] CAPI call migration from v2 to v3 The CAPI v2 is deprecated and will be deactivated in the cf-deployment. Therefore an update is needed to use the newer CAPI v3. --- src/rlp-gateway/internal/auth/capi_client.go | 6 +++--- src/rlp-gateway/internal/auth/capi_client_test.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/rlp-gateway/internal/auth/capi_client.go b/src/rlp-gateway/internal/auth/capi_client.go index af9f7546b..0eca8ee6f 100644 --- a/src/rlp-gateway/internal/auth/capi_client.go +++ b/src/rlp-gateway/internal/auth/capi_client.go @@ -83,7 +83,7 @@ func (c *CAPIClient) IsAuthorized(sourceID, token string) bool { return true } - uri = fmt.Sprintf("%s/v2/service_instances/%s", c.externalCapi, sourceID) + uri = fmt.Sprintf("%s/v3/service_instances/%s", c.externalCapi, sourceID) req, err = http.NewRequest(http.MethodGet, uri, nil) if err != nil { log.Printf("failed to build authorize service instance access request: %s", err) @@ -149,7 +149,7 @@ func (c *CAPIClient) AvailableSourceIDs(token string) []string { sourceIDs = append(sourceIDs, v.Guid) } - req, err = http.NewRequest(http.MethodGet, c.externalCapi+"/v2/service_instances", nil) + req, err = http.NewRequest(http.MethodGet, c.externalCapi+"/v3/service_instances", nil) if err != nil { log.Printf("failed to build authorize service instance access request: %s", err) return nil @@ -169,7 +169,7 @@ func (c *CAPIClient) AvailableSourceIDs(token string) []string { }(resp) if resp.StatusCode != http.StatusOK { - log.Printf("CAPI request failed (/v2/service_instances): %d", resp.StatusCode) + log.Printf("CAPI request failed (/v3/service_instances): %d", resp.StatusCode) return nil } diff --git a/src/rlp-gateway/internal/auth/capi_client_test.go b/src/rlp-gateway/internal/auth/capi_client_test.go index b2198b87a..0e23185d1 100644 --- a/src/rlp-gateway/internal/auth/capi_client_test.go +++ b/src/rlp-gateway/internal/auth/capi_client_test.go @@ -51,7 +51,7 @@ var _ = Describe("CAPIClient", func() { r = capiClient.requests[1] Expect(r.Method).To(Equal(http.MethodGet)) - Expect(r.URL.String()).To(Equal("http://external.capi.com/v2/service_instances/some-id")) + Expect(r.URL.String()).To(Equal("http://external.capi.com/v3/service_instances/some-id")) Expect(r.Header.Get("Authorization")).To(Equal("some-token")) }) @@ -121,7 +121,7 @@ var _ = Describe("CAPIClient", func() { servicesReq := capiClient.requests[1] Expect(servicesReq.Method).To(Equal(http.MethodGet)) - Expect(servicesReq.URL.String()).To(Equal("http://external.capi.com/v2/service_instances")) + Expect(servicesReq.URL.String()).To(Equal("http://external.capi.com/v3/service_instances")) Expect(servicesReq.Header.Get("Authorization")).To(Equal("some-token")) })