From be47f646d92d7e7add6e0e064fea58ef9480dbad Mon Sep 17 00:00:00 2001 From: Matthew Long Date: Tue, 30 Sep 2025 13:19:58 +0100 Subject: [PATCH 1/7] fix: aligning data types with rediscloud API --- service/privatelink/model.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/service/privatelink/model.go b/service/privatelink/model.go index e99cec0..49d64c3 100644 --- a/service/privatelink/model.go +++ b/service/privatelink/model.go @@ -32,9 +32,9 @@ type PrivateLinkPrincipal struct { type PrivateLinkConnection struct { AssociationId *string `json:"associationId,omitempty"` - ConnectionId *int `json:"connectionId,omitempty"` + ConnectionId *string `json:"connectionId,omitempty"` Type *string `json:"type,omitempty"` - OwnerId *int `json:"ownerId,omitempty"` + OwnerId *string `json:"ownerId,omitempty"` AssociationDate *string `json:"associationDate,omitempty"` } From add87f9638180e7d07db0818eb7aa3043f716ea9 Mon Sep 17 00:00:00 2001 From: Matthew Long Date: Tue, 30 Sep 2025 13:23:20 +0100 Subject: [PATCH 2/7] docs: changelog.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dc669b..76d34e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/). +## 0.36.4 + +### Changed: +* Several fields in the PrivateLink connections datatype now have data types aligned with the API. + ## 0.36.3 ### Added: From 9b4259de298b4fce0bc6505a3cccbe11188486b3 Mon Sep 17 00:00:00 2001 From: Matthew Long Date: Tue, 30 Sep 2025 13:34:23 +0100 Subject: [PATCH 3/7] test: updating tests --- privatelink_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/privatelink_test.go b/privatelink_test.go index 424ecfc..64d3971 100644 --- a/privatelink_test.go +++ b/privatelink_test.go @@ -69,9 +69,9 @@ func TestGetPrivateLink(t *testing.T) { "connections": [ { "associationId": "received", - "connectionId": 144019, + "connectionId": "vpce-con-12345678", "type": "connection type", - "ownerId": 12312312, + "ownerId": "123456789012", "associationDate": "2024-07-16T09:26:40.929904847Z" } ], @@ -112,9 +112,9 @@ func TestGetPrivateLink(t *testing.T) { ShareName: redis.String("share name"), Connections: []*pl.PrivateLinkConnection{{ AssociationId: redis.String("received"), - ConnectionId: redis.Int(144019), + ConnectionId: redis.String("vpce-con-12345678"), Type: redis.String("connection type"), - OwnerId: redis.Int(12312312), + OwnerId: redis.String("123456789012"), AssociationDate: redis.String("2024-07-16T09:26:40.929904847Z"), }}, Databases: []*pl.PrivateLinkDatabase{{ @@ -272,9 +272,9 @@ func TestGetActiveActivePrivateLink(t *testing.T) { "connections": [ { "associationId": "received", - "connectionId": 144019, + "connectionId": "vpce-con-12345678", "type": "connection type", - "ownerId": 12312312, + "ownerId": "123456789012", "associationDate": "2024-07-16T09:26:40.929904847Z" } ], @@ -316,9 +316,9 @@ func TestGetActiveActivePrivateLink(t *testing.T) { ShareName: redis.String("share name"), Connections: []*pl.PrivateLinkConnection{{ AssociationId: redis.String("received"), - ConnectionId: redis.Int(144019), + ConnectionId: redis.String("vpce-con-12345678"), Type: redis.String("connection type"), - OwnerId: redis.Int(12312312), + OwnerId: redis.String("123456789012"), AssociationDate: redis.String("2024-07-16T09:26:40.929904847Z"), }}, Databases: []*pl.PrivateLinkDatabase{{ From 1c908d1eea1ac30e5d0e637364ce184f670f45fc Mon Sep 17 00:00:00 2001 From: Matthew Long Date: Tue, 30 Sep 2025 13:37:42 +0100 Subject: [PATCH 4/7] fix: endpoint script path incorrectly formed --- service/privatelink/service.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/service/privatelink/service.go b/service/privatelink/service.go index dcaeed5..c7af6f1 100644 --- a/service/privatelink/service.go +++ b/service/privatelink/service.go @@ -66,7 +66,7 @@ type PrivateLinkEndpointScript = string // GetPrivateLinkEndpointScript will get the script for an endpoint. func (a *API) GetPrivateLinkEndpointScript(ctx context.Context, subscriptionId int) (*PrivateLinkEndpointScript, error) { message := fmt.Sprintf("get private link for subscription %d", subscriptionId) - path := fmt.Sprintf("/subscriptions/%d/private-link/endpoint-script/?includeTerraformAwsScript=true", subscriptionId) + path := fmt.Sprintf("/subscriptions/%d/private-link/endpoint-script?includeTerraformAwsScript=true", subscriptionId) task, err := a.getScript(ctx, message, path) if err != nil { return nil, wrap404Error(subscriptionId, err) @@ -127,7 +127,7 @@ func (a *API) GetActiveActivePrivateLink(ctx context.Context, subscription int, // GetPrivateLinkEndpointScript will get the script for an endpoint. func (a *API) GetActiveActivePrivateLinkEndpointScript(ctx context.Context, subscription int, regionId int) (*PrivateLinkEndpointScript, error) { message := fmt.Sprintf("get private link for subscription %d", subscription) - path := fmt.Sprintf("/subscriptions/%d/regions/%d/private-link/endpoint-script/?includeTerraformAwsScript=true", subscription, regionId) + path := fmt.Sprintf("/subscriptions/%d/regions/%d/private-link/endpoint-script?includeTerraformAwsScript=true", subscription, regionId) task, err := a.getScript(ctx, message, path) if err != nil { return nil, wrap404Error(subscription, err) From b1e1401419b3ea50e24f5c5a5a5aab821a78f712 Mon Sep 17 00:00:00 2001 From: Matthew Long Date: Tue, 30 Sep 2025 14:01:21 +0100 Subject: [PATCH 5/7] test: adding placeholder endpoint script tests - subject to how the api responds --- privatelink_test.go | 84 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/privatelink_test.go b/privatelink_test.go index 64d3971..9f0d310 100644 --- a/privatelink_test.go +++ b/privatelink_test.go @@ -419,3 +419,87 @@ func TestGetActiveActivePrivateLink(t *testing.T) { }) } } + +func TestGetPrivateLinkScript(t *testing.T) { + + tc := []struct { + description string + mockedResponse []endpointRequest + expectedResult *pl.PrivateLinkEndpointScript + expectedError error + expectedErrorAs error + }{ + { + description: "should successfully return a privatelink script", + mockedResponse: []endpointRequest{ + getRequest( + t, + "/subscriptions/114019/private-link/endpoint-script?includeTerraformAwsScript=true", + `a pro privatelink aws terraform endpoint script`, + ), + }, + expectedResult: redis.String("a pro privatelink aws terraform endpoint script"), + }, + } + for _, testCase := range tc { + + t.Run(testCase.description, func(t *testing.T) { + server := httptest.NewServer( + testServer("key", "secret", testCase.mockedResponse...)) + + subject, err := clientFromTestServer(server, "key", "secret") + require.NoError(t, err) + + actual, err := subject.PrivateLink.GetPrivateLinkEndpointScript(context.TODO(), 114019) + if testCase.expectedError == nil { + assert.NoError(t, err) + assert.Equal(t, testCase.expectedResult, actual) + } else { + assert.IsType(t, err, testCase.expectedErrorAs) + assert.EqualError(t, err, testCase.expectedError.Error()) + } + }) + } +} + +func TestGetActiveActivePrivateLinkScript(t *testing.T) { + + tc := []struct { + description string + mockedResponse []endpointRequest + expectedResult *pl.PrivateLinkEndpointScript + expectedError error + expectedErrorAs error + }{ + { + description: "should successfully return an active active privatelink script", + mockedResponse: []endpointRequest{ + getRequest( + t, + "/subscriptions/114019/regions/1/private-link/endpoint-script?includeTerraformAwsScript=true", + `an active active aws terraform endpoint script`, + ), + }, + expectedResult: redis.String("an active active aws terraform endpoint script"), + }, + } + for _, testCase := range tc { + + t.Run(testCase.description, func(t *testing.T) { + server := httptest.NewServer( + testServer("key", "secret", testCase.mockedResponse...)) + + subject, err := clientFromTestServer(server, "key", "secret") + require.NoError(t, err) + + actual, err := subject.PrivateLink.GetActiveActivePrivateLinkEndpointScript(context.TODO(), 114019, 1) + if testCase.expectedError == nil { + assert.NoError(t, err) + assert.Equal(t, testCase.expectedResult, actual) + } else { + assert.IsType(t, err, testCase.expectedErrorAs) + assert.EqualError(t, err, testCase.expectedError.Error()) + } + }) + } +} From 2fc3a1464d633d2f0f531109a04095cbc5cfa8da Mon Sep 17 00:00:00 2001 From: Matthew Long Date: Tue, 30 Sep 2025 15:13:10 +0100 Subject: [PATCH 6/7] docs: changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76d34e1..b70de68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/). ### Changed: * Several fields in the PrivateLink connections datatype now have data types aligned with the API. +* Fixed an issue with a malformed URL for the PrivateLink endpoint scripts and added tests ## 0.36.3 From 1f627939c22fcd2092f978ac9ae647fb5518f2fc Mon Sep 17 00:00:00 2001 From: Matthew Long Date: Tue, 30 Sep 2025 17:48:56 +0100 Subject: [PATCH 7/7] test: adding skip to tests until api works --- privatelink_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/privatelink_test.go b/privatelink_test.go index 9f0d310..93c2160 100644 --- a/privatelink_test.go +++ b/privatelink_test.go @@ -421,6 +421,7 @@ func TestGetActiveActivePrivateLink(t *testing.T) { } func TestGetPrivateLinkScript(t *testing.T) { + t.Skipf("skipping test until privatelink script is available") tc := []struct { description string @@ -463,6 +464,7 @@ func TestGetPrivateLinkScript(t *testing.T) { } func TestGetActiveActivePrivateLinkScript(t *testing.T) { + t.Skipf("skipping test until privatelink script is available") tc := []struct { description string