diff --git a/docs/command/atlas-streams-privateLinks-create.txt b/docs/command/atlas-streams-privateLinks-create.txt new file mode 100644 index 0000000000..09c8b78f82 --- /dev/null +++ b/docs/command/atlas-streams-privateLinks-create.txt @@ -0,0 +1,91 @@ +.. _atlas-streams-privateLinks-create: + +================================= +atlas streams privateLinks create +================================= + +.. default-domain:: mongodb + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +Creates a PrivateLink endpoint that can be used as an Atlas Stream Processor connection. + +To use this command, you must authenticate with a user account or an API key with any of the following roles: Project Owner, Project Stream Processing Owner. + +Syntax +------ + +.. code-block:: + :caption: Command Syntax + + atlas streams privateLinks create [options] + +.. Code end marker, please don't delete this comment + +Options +------- + +.. list-table:: + :header-rows: 1 + :widths: 20 10 10 60 + + * - Name + - Type + - Required + - Description + * - -f, --file + - string + - true + - Path to a JSON configuration file that defines an Atlas Stream Processing PrivateLink endpoint. + * - -h, --help + - + - false + - help for create + * - -o, --output + - string + - false + - Output format. Valid values are json, json-path, go-template, or go-template-file. To see the full output, use the -o json option. + * - --projectId + - string + - false + - Hexadecimal string that identifies the project to use. This option overrides the settings in the configuration file or environment variable. + +Inherited Options +----------------- + +.. list-table:: + :header-rows: 1 + :widths: 20 10 10 60 + + * - Name + - Type + - Required + - Description + * - -P, --profile + - string + - false + - Name of the profile to use from your configuration file. To learn about profiles for the Atlas CLI, see https://dochub.mongodb.org/core/atlas-cli-save-connection-settings. + +Output +------ + +If the command succeeds, the CLI returns output similar to the following sample. Values in brackets represent your values. + +.. code-block:: + + Atlas Stream Processing PrivateLink endpoint created. + + +Examples +-------- + +.. code-block:: + :copyable: false + + # create a new PrivateLink endpoint for Atlas Stream Processing: + atlas streams privateLink create -f endpointConfig.json + diff --git a/docs/command/atlas-streams-privateLinks.txt b/docs/command/atlas-streams-privateLinks.txt new file mode 100644 index 0000000000..abe26f6e26 --- /dev/null +++ b/docs/command/atlas-streams-privateLinks.txt @@ -0,0 +1,61 @@ +.. _atlas-streams-privateLinks: + +========================== +atlas streams privateLinks +========================== + +.. default-domain:: mongodb + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +Manage Atlas Stream Processing PrivateLink endpoints. + +Create your Atlas Stream Processing PrivateLink endpoints + +Options +------- + +.. list-table:: + :header-rows: 1 + :widths: 20 10 10 60 + + * - Name + - Type + - Required + - Description + * - -h, --help + - + - false + - help for privateLinks + +Inherited Options +----------------- + +.. list-table:: + :header-rows: 1 + :widths: 20 10 10 60 + + * - Name + - Type + - Required + - Description + * - -P, --profile + - string + - false + - Name of the profile to use from your configuration file. To learn about profiles for the Atlas CLI, see https://dochub.mongodb.org/core/atlas-cli-save-connection-settings. + +Related Commands +---------------- + +* :ref:`atlas-streams-privateLinks-create` - Creates a PrivateLink endpoint that can be used as an Atlas Stream Processor connection. + + +.. toctree:: + :titlesonly: + + create + diff --git a/docs/command/atlas-streams.txt b/docs/command/atlas-streams.txt index 7c5ce40184..d0a648bac8 100644 --- a/docs/command/atlas-streams.txt +++ b/docs/command/atlas-streams.txt @@ -53,6 +53,7 @@ Related Commands * :ref:`atlas-streams-connections` - Manage Atlas Stream Processing connections. * :ref:`atlas-streams-instances` - Manage Atlas Stream Processing instances. +* :ref:`atlas-streams-privateLinks` - Manage Atlas Stream Processing PrivateLink endpoints. .. toctree:: @@ -60,4 +61,5 @@ Related Commands connections instances + privateLinks diff --git a/internal/cli/streams/privatelink/create.go b/internal/cli/streams/privatelink/create.go new file mode 100644 index 0000000000..1dc3598bd8 --- /dev/null +++ b/internal/cli/streams/privatelink/create.go @@ -0,0 +1,110 @@ +// Copyright 2025 MongoDB Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package privatelink + +import ( + "context" + "errors" + "fmt" + + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli" + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/require" + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/config" + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/file" + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/flag" + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/store" + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/usage" + "github.com/spf13/afero" + "github.com/spf13/cobra" + atlasv2 "go.mongodb.org/atlas-sdk/v20241113004/admin" +) + +var createTemplate = "Atlas Stream Processing PrivateLink endpoint {{.InterfaceEndpointId}} created.\n" + +type CreateOpts struct { + cli.ProjectOpts + cli.OutputOpts + store store.PrivateLinkCreator + filename string + fs afero.Fs +} + +func (opts *CreateOpts) Run() error { + privateLinkEndpoint := atlasv2.NewStreamsPrivateLinkConnection() + if err := file.Load(opts.fs, opts.filename, privateLinkEndpoint); err != nil { + return err + } + + // Remaining validation will be done by the API + if privateLinkEndpoint.GetProvider() == "" { + return errors.New("provider missing") + } + + result, err := opts.store.CreatePrivateLinkEndpoint(opts.ConfigProjectID(), privateLinkEndpoint) + if err != nil { + return err + } + + return opts.Print(result) +} + +func (opts *CreateOpts) initStore(ctx context.Context) func() error { + return func() error { + var err error + opts.store, err = store.New(store.AuthenticatedPreset(config.Default()), store.WithContext(ctx)) + return err + } +} + +// atlas streams privateLink create +// -f filename: file containing the private link endpoint configuration. +// Create a PrivateLink endpoint that can be used as an Atlas Stream Processor connection. +func CreateBuilder() *cobra.Command { + opts := &CreateOpts{ + fs: afero.NewOsFs(), + } + cmd := &cobra.Command{ + Use: "create", + Short: "Creates a PrivateLink endpoint that can be used as an Atlas Stream Processor connection.", + Long: fmt.Sprintf(usage.RequiredOneOfRoles, commandRoles), + Args: require.NoArgs, + Annotations: map[string]string{ + "output": createTemplate, + }, + Example: `# create a new PrivateLink endpoint for Atlas Stream Processing: + atlas streams privateLink create -f endpointConfig.json +`, + PreRunE: func(cmd *cobra.Command, _ []string) error { + return opts.PreRunE( + opts.ValidateProjectID, + opts.initStore(cmd.Context()), + opts.InitOutput(cmd.OutOrStdout(), createTemplate), + ) + }, + RunE: func(_ *cobra.Command, _ []string) error { + return opts.Run() + }, + } + + cmd.Flags().StringVarP(&opts.filename, flag.File, flag.FileShort, "", usage.StreamsPrivateLinkFilename) + + opts.AddProjectOptsFlags(cmd) + opts.AddOutputOptFlags(cmd) + + _ = cmd.MarkFlagFilename(flag.File) + _ = cmd.MarkFlagRequired(flag.File) + + return cmd +} diff --git a/internal/cli/streams/privatelink/create_test.go b/internal/cli/streams/privatelink/create_test.go new file mode 100644 index 0000000000..1248266eb2 --- /dev/null +++ b/internal/cli/streams/privatelink/create_test.go @@ -0,0 +1,145 @@ +// Copyright 2025 MongoDB Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package privatelink + +import ( + "bytes" + "testing" + + "github.com/golang/mock/gomock" + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli" + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/mocks" + "github.com/spf13/afero" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + atlasv2 "go.mongodb.org/atlas-sdk/v20241113004/admin" +) + +const fileName = "test-privateLink.json" + +func TestCreateOpts_Run(t *testing.T) { + testCases := []struct { + name string + fileContents string + wantErr require.ErrorAssertionFunc + }{ + { + name: "no file passed in", + fileContents: "", + wantErr: require.Error, + }, + { + name: "file does not contain a provider", + fileContents: ` + { + "region": "US_EAST_2", + "serviceEndpointId": "/subscriptions/fd01adff-b37e-4693-8497-83ecf183a145/resourceGroups/test-rg/providers/Microsoft.EventHub/namespaces/test-namespace", + "dnsDomain": "test-namespace.servicebus.windows.net" + } + `, + wantErr: func(tt require.TestingT, err error, _ ...any) { + require.ErrorContains(tt, err, "provider missing") + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + fs := afero.NewMemMapFs() + + if tc.fileContents != "" { + require.NoError(t, afero.WriteFile(fs, fileName, []byte(tc.fileContents), 0600)) + } + + createOpts := &CreateOpts{ + fs: fs, + filename: fileName, + } + + tc.wantErr(t, createOpts.Run()) + }) + } + + validPrivateLinkConfigFileContents := ` + { + "provider": "Azure", + "region": "US_EAST_2", + "serviceEndpointId": "/subscriptions/fd01adff-b37e-4693-8497-83ecf183a145/resourceGroups/test-rg/providers/Microsoft.EventHub/namespaces/test-namespace", + "dnsDomain": "test-namespace.servicebus.windows.net" + } + ` + + t.Run("should call the store create privateLink method with the correct parameters", func(t *testing.T) { + fs := afero.NewMemMapFs() + require.NoError(t, afero.WriteFile(fs, fileName, []byte(validPrivateLinkConfigFileContents), 0600)) + + ctrl := gomock.NewController(t) + mockStore := mocks.NewMockPrivateLinkCreator(ctrl) + + createOpts := &CreateOpts{ + store: mockStore, + fs: fs, + filename: fileName, + } + + expected := atlasv2.NewStreamsPrivateLinkConnection() + expected.SetProvider("Azure") + expected.SetRegion("US_EAST_2") + expected.SetServiceEndpointId("/subscriptions/fd01adff-b37e-4693-8497-83ecf183a145/resourceGroups/test-rg/providers/Microsoft.EventHub/namespaces/test-namespace") + expected.SetDnsDomain("test-namespace.servicebus.windows.net") + + mockStore. + EXPECT(). + CreatePrivateLinkEndpoint(gomock.Eq(createOpts.ConfigProjectID()), gomock.Eq(expected)). + Times(1) + + require.NoError(t, createOpts.Run()) + }) + + t.Run("should print the result", func(t *testing.T) { + fs := afero.NewMemMapFs() + require.NoError(t, afero.WriteFile(fs, fileName, []byte(validPrivateLinkConfigFileContents), 0600)) + + ctrl := gomock.NewController(t) + mockStore := mocks.NewMockPrivateLinkCreator(ctrl) + + buf := new(bytes.Buffer) + createOpts := &CreateOpts{ + store: mockStore, + fs: fs, + filename: fileName, + OutputOpts: cli.OutputOpts{ + Template: createTemplate, + OutWriter: buf, + }, + } + + expectedInterfaceEndpointID := "vpc-1234567890abcdef0" + + expected := atlasv2.NewStreamsPrivateLinkConnection() + expected.InterfaceEndpointId = &expectedInterfaceEndpointID + + mockStore. + EXPECT(). + // This test does not assert the parameters passed to the store method + CreatePrivateLinkEndpoint(gomock.Any(), gomock.Any()). + Return(expected, nil). + Times(1) + + require.NoError(t, createOpts.Run()) + assert.Equal(t, "Atlas Stream Processing PrivateLink endpoint "+expectedInterfaceEndpointID+" created.\n", buf.String()) + }) +} diff --git a/internal/cli/streams/privatelink/privatelink.go b/internal/cli/streams/privatelink/privatelink.go new file mode 100644 index 0000000000..0d69673381 --- /dev/null +++ b/internal/cli/streams/privatelink/privatelink.go @@ -0,0 +1,40 @@ +// Copyright 2025 MongoDB Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package privatelink + +import ( + "strings" + + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli" + "github.com/spf13/cobra" +) + +var commandRoles = strings.Join([]string{"Project Owner", "Project Stream Processing Owner"}, ", ") + +func Builder() *cobra.Command { + const use = "privateLinks" + cmd := &cobra.Command{ + Use: use, + Aliases: cli.GenerateAliases(use), + Short: "Manage Atlas Stream Processing PrivateLink endpoints.", + Long: `Create your Atlas Stream Processing PrivateLink endpoints`, + } + + cmd.AddCommand( + CreateBuilder(), + ) + + return cmd +} diff --git a/internal/cli/streams/streams.go b/internal/cli/streams/streams.go index e33e5093ae..d70588a985 100644 --- a/internal/cli/streams/streams.go +++ b/internal/cli/streams/streams.go @@ -18,6 +18,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/streams/connection" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/streams/instance" + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/streams/privatelink" "github.com/spf13/cobra" ) @@ -32,6 +33,7 @@ func Builder() *cobra.Command { cmd.AddCommand( instance.Builder(), connection.Builder(), + privatelink.Builder(), ) return cmd diff --git a/internal/mocks/mock_streams.go b/internal/mocks/mock_streams.go index 6812815a27..8d0554b568 100644 --- a/internal/mocks/mock_streams.go +++ b/internal/mocks/mock_streams.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/mongodb/mongodb-atlas-cli/atlascli/internal/store (interfaces: StreamsLister,StreamsDescriber,StreamsCreator,StreamsDeleter,StreamsUpdater,StreamsDownloader,ConnectionCreator,ConnectionDeleter,ConnectionUpdater,StreamsConnectionDescriber,StreamsConnectionLister) +// Source: github.com/mongodb/mongodb-atlas-cli/atlascli/internal/store (interfaces: StreamsLister,StreamsDescriber,StreamsCreator,StreamsDeleter,StreamsUpdater,StreamsDownloader,ConnectionCreator,ConnectionDeleter,ConnectionUpdater,StreamsConnectionDescriber,StreamsConnectionLister,PrivateLinkCreator) // Package mocks is a generated GoMock package. package mocks @@ -427,3 +427,41 @@ func (mr *MockStreamsConnectionListerMockRecorder) StreamsConnections(arg0, arg1 mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StreamsConnections", reflect.TypeOf((*MockStreamsConnectionLister)(nil).StreamsConnections), arg0, arg1) } + +// MockPrivateLinkCreator is a mock of PrivateLinkCreator interface. +type MockPrivateLinkCreator struct { + ctrl *gomock.Controller + recorder *MockPrivateLinkCreatorMockRecorder +} + +// MockPrivateLinkCreatorMockRecorder is the mock recorder for MockPrivateLinkCreator. +type MockPrivateLinkCreatorMockRecorder struct { + mock *MockPrivateLinkCreator +} + +// NewMockPrivateLinkCreator creates a new mock instance. +func NewMockPrivateLinkCreator(ctrl *gomock.Controller) *MockPrivateLinkCreator { + mock := &MockPrivateLinkCreator{ctrl: ctrl} + mock.recorder = &MockPrivateLinkCreatorMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockPrivateLinkCreator) EXPECT() *MockPrivateLinkCreatorMockRecorder { + return m.recorder +} + +// CreatePrivateLinkEndpoint mocks base method. +func (m *MockPrivateLinkCreator) CreatePrivateLinkEndpoint(arg0 string, arg1 *admin.StreamsPrivateLinkConnection) (*admin.StreamsPrivateLinkConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreatePrivateLinkEndpoint", arg0, arg1) + ret0, _ := ret[0].(*admin.StreamsPrivateLinkConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreatePrivateLinkEndpoint indicates an expected call of CreatePrivateLinkEndpoint. +func (mr *MockPrivateLinkCreatorMockRecorder) CreatePrivateLinkEndpoint(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreatePrivateLinkEndpoint", reflect.TypeOf((*MockPrivateLinkCreator)(nil).CreatePrivateLinkEndpoint), arg0, arg1) +} diff --git a/internal/store/streams.go b/internal/store/streams.go index c4359d815f..09a8b94977 100644 --- a/internal/store/streams.go +++ b/internal/store/streams.go @@ -21,7 +21,7 @@ import ( atlasv2 "go.mongodb.org/atlas-sdk/v20241113004/admin" ) -//go:generate mockgen -destination=../mocks/mock_streams.go -package=mocks github.com/mongodb/mongodb-atlas-cli/atlascli/internal/store StreamsLister,StreamsDescriber,StreamsCreator,StreamsDeleter,StreamsUpdater,StreamsDownloader,ConnectionCreator,ConnectionDeleter,ConnectionUpdater,StreamsConnectionDescriber,StreamsConnectionLister +//go:generate mockgen -destination=../mocks/mock_streams.go -package=mocks github.com/mongodb/mongodb-atlas-cli/atlascli/internal/store StreamsLister,StreamsDescriber,StreamsCreator,StreamsDeleter,StreamsUpdater,StreamsDownloader,ConnectionCreator,ConnectionDeleter,ConnectionUpdater,StreamsConnectionDescriber,StreamsConnectionLister,PrivateLinkCreator type StreamsLister interface { ProjectStreams(*atlasv2.ListStreamInstancesApiParams) (*atlasv2.PaginatedApiStreamsTenant, error) @@ -67,6 +67,10 @@ type ConnectionUpdater interface { UpdateConnection(string, string, string, *atlasv2.StreamsConnection) (*atlasv2.StreamsConnection, error) } +type PrivateLinkCreator interface { + CreatePrivateLinkEndpoint(projectID string, connection *atlasv2.StreamsPrivateLinkConnection) (*atlasv2.StreamsPrivateLinkConnection, error) +} + func (s *Store) ProjectStreams(opts *atlasv2.ListStreamInstancesApiParams) (*atlasv2.PaginatedApiStreamsTenant, error) { result, _, err := s.clientv2.StreamsApi.ListStreamInstancesWithParams(s.ctx, opts).Execute() return result, err @@ -132,3 +136,8 @@ func (s *Store) DeleteConnection(projectID, tenantName, connectionName string) e _, _, err := s.clientv2.StreamsApi.DeleteStreamConnection(s.ctx, projectID, tenantName, connectionName).Execute() return err } + +func (s *Store) CreatePrivateLinkEndpoint(projectID string, connection *atlasv2.StreamsPrivateLinkConnection) (*atlasv2.StreamsPrivateLinkConnection, error) { + result, _, err := s.clientv2.StreamsApi.CreatePrivateLinkConnection(s.ctx, projectID, connection).Execute() + return result, err +} diff --git a/internal/usage/usage.go b/internal/usage/usage.go index bc058e9eff..ac07fed76b 100644 --- a/internal/usage/usage.go +++ b/internal/usage/usage.go @@ -239,6 +239,7 @@ dbName and collection are required only for built-in roles.` StreamsProvider = "Cloud service provider that applies to the provisioned Atlas Stream Processing instance." StreamsInstance = "Name of your Atlas Stream Processing instance." StreamsConnectionFilename = "Path to a JSON configuration file that defines an Atlas Stream Processing connection." + StreamsPrivateLinkFilename = "Path to a JSON configuration file that defines an Atlas Stream Processing PrivateLink endpoint." StreamsInstanceTier = "Tier for your Stream Instance." WithoutDefaultAlertSettings = "Flag that creates the new project without the default alert settings enabled. This flag defaults to false. This option is useful if you create projects programmatically and want to create your own alerts instead of using the default alert settings." FormatOut = "Output format. Valid values are json, json-path, go-template, or go-template-file. To see the full output, use the -o json option." @@ -335,6 +336,7 @@ dbName and collection are required only for built-in roles.` OperatorSubResourceDeletionProtection = "Toggle atlas operator deletion protection for subresources like Alerts, Integrations, etc. Read more: https://dochub.mongodb.org/core/ako-deletion-protection" ExportID = "Unique string that identifies the AWS S3 bucket to which you export your snapshots." RequiredRole = "To use this command, you must authenticate with a user account or an API key with the %s role." + RequiredOneOfRoles = "To use this command, you must authenticate with a user account or an API key with any of the following roles: %s." RestoreJobID = "Unique identifier that identifies the Restore Job." DeliveryType = "Type of restore job to create. Valid values include: automated, download, pointInTime. To learn more about types of restore jobs, see https://dochub.mongodb.org/core/backup-restore-cluster-atlas." EnableServerlessContinuousBackup = "Flag that enables Serverless Continuous Backup for your serverless instance. If enabled, the serverless instance does not use Basic Backup." diff --git a/test/README.md b/test/README.md index 01d562b968..666d0d83c8 100644 --- a/test/README.md +++ b/test/README.md @@ -193,6 +193,8 @@ | `streams instance list` | Y | Y | | `streams instance update` | Y | Y | | `streams instance log` | Y | Y | +| `streams privateLink` | | | +| `streams privateLink create` | Y | Y | | `config` | | | | `completion` | Y | Y | | `config delete` | Y | Y | diff --git a/test/e2e/atlas/data/create_streams_privateLink_test.json b/test/e2e/atlas/data/create_streams_privateLink_test.json new file mode 100644 index 0000000000..42e60d9e9c --- /dev/null +++ b/test/e2e/atlas/data/create_streams_privateLink_test.json @@ -0,0 +1,6 @@ +{ + "provider": "Azure", + "region": "US_EAST_2", + "serviceEndpointId": "/subscriptions/fd01adff-b37e-4693-8497-83ecf183a145/resourceGroups/test-rg/providers/Microsoft.EventHub/namespaces/test-namespace", + "dnsDomain": "test-namespace.servicebus.windows.net" +} diff --git a/test/e2e/atlas/streams_test.go b/test/e2e/atlas/streams_test.go index bb36ad195c..c9c2a99b42 100644 --- a/test/e2e/atlas/streams_test.go +++ b/test/e2e/atlas/streams_test.go @@ -195,6 +195,33 @@ func TestStreams(t *testing.T) { a.Equal("VIRGINIA_USA", instance.DataProcessRegion.Region) }) + // Endpoints + t.Run("Creating a streams privateLink endpoint", func(t *testing.T) { + streamsCmd := exec.Command(cliPath, + "streams", + "privateLink", + "create", + "-f", + "data/create_streams_privateLink_test.json", + "-o=json", + "--projectId", + g.projectID, + ) + + streamsCmd.Env = os.Environ() + streamsResp, err := e2e.RunAndGetStdOut(streamsCmd) + req.NoError(err, string(streamsResp)) + + var privateLinkEndpoint atlasv2.StreamsPrivateLinkConnection + req.NoError(json.Unmarshal(streamsResp, &privateLinkEndpoint)) + + a := assert.New(t) + a.Equal("Azure", *privateLinkEndpoint.Provider) + a.Equal("US_EAST_2", *privateLinkEndpoint.Region) + a.Equal("/subscriptions/fd01adff-b37e-4693-8497-83ecf183a145/resourceGroups/test-rg/providers/Microsoft.EventHub/namespaces/test-namespace", *privateLinkEndpoint.ServiceEndpointId) + a.Equal("test-namespace.servicebus.windows.net", *privateLinkEndpoint.DnsDomain) + }) + // Connections t.Run("Creating a streams connection", func(t *testing.T) { cmd := exec.Command(cliPath,