diff --git a/cmd/ecloud/ecloud.go b/cmd/ecloud/ecloud.go index 3ac6611..7f03810 100644 --- a/cmd/ecloud/ecloud.go +++ b/cmd/ecloud/ecloud.go @@ -69,6 +69,7 @@ func ECloudRootCmd(f factory.ClientFactory, fs afero.Fs) *cobra.Command { cmd.AddCommand(ecloudVPNProfileGroupRootCmd(f)) cmd.AddCommand(ecloudVPNServiceRootCmd(f)) cmd.AddCommand(ecloudVPNSessionRootCmd(f)) + cmd.AddCommand(ecloudVPNGatewayRootCmd(f)) cmd.AddCommand(ecloudVolumeGroupRootCmd(f)) cmd.AddCommand(ecloudAffinityRuleRootCmd(f)) cmd.AddCommand(ecloudAffinityRuleMemberRootCmd(f)) diff --git a/cmd/ecloud/ecloud_vpngateway.go b/cmd/ecloud/ecloud_vpngateway.go new file mode 100644 index 0000000..ded1b8f --- /dev/null +++ b/cmd/ecloud/ecloud_vpngateway.go @@ -0,0 +1,234 @@ +package ecloud + +import ( + "errors" + "fmt" + + "github.com/ans-group/cli/internal/pkg/factory" + "github.com/ans-group/cli/internal/pkg/helper" + "github.com/ans-group/cli/internal/pkg/output" + "github.com/ans-group/sdk-go/pkg/service/ecloud" + "github.com/spf13/cobra" +) + +func ecloudVPNGatewayRootCmd(f factory.ClientFactory) *cobra.Command { + cmd := &cobra.Command{ + Use: "vpngateway", + Short: "sub-commands relating to VPN gateways", + } + + // Child commands + cmd.AddCommand(ecloudVPNGatewayUserRootCmd(f)) + cmd.AddCommand(ecloudVPNGatewaySpecificationRootCmd(f)) + cmd.AddCommand(ecloudVPNGatewayListCmd(f)) + cmd.AddCommand(ecloudVPNGatewayShowCmd(f)) + cmd.AddCommand(ecloudVPNGatewayCreateCmd(f)) + cmd.AddCommand(ecloudVPNGatewayUpdateCmd(f)) + cmd.AddCommand(ecloudVPNGatewayDeleteCmd(f)) + + return cmd +} + +func ecloudVPNGatewayListCmd(f factory.ClientFactory) *cobra.Command { + cmd := &cobra.Command{ + Use: "list", + Short: "Lists VPN gateways", + Example: "ans ecloud vpngateway list", + RunE: ecloudCobraRunEFunc(f, ecloudVPNGatewayList), + } + + cmd.Flags().String("name", "", "VPN gateway name for filtering") + + return cmd +} + +func ecloudVPNGatewayList(service ecloud.ECloudService, cmd *cobra.Command, args []string) error { + params, err := helper.GetAPIRequestParametersFromFlags(cmd, + helper.NewStringFilterFlagOption("name", "name"), + ) + if err != nil { + return err + } + + gateways, err := service.GetVPNGateways(params) + if err != nil { + return fmt.Errorf("Error retrieving VPN gateways: %s", err) + } + + return output.CommandOutput(cmd, OutputECloudVPNGatewaysProvider(gateways)) +} + +func ecloudVPNGatewayShowCmd(f factory.ClientFactory) *cobra.Command { + return &cobra.Command{ + Use: "show ...", + Short: "Show details of a VPN gateway", + Example: "ans ecloud vpngateway show vpng-abcdef12", + Args: func(cmd *cobra.Command, args []string) error { + if len(args) < 1 { + return errors.New("Missing VPN gateway") + } + + return nil + }, + RunE: ecloudCobraRunEFunc(f, ecloudVPNGatewayShow), + } +} + +func ecloudVPNGatewayShow(service ecloud.ECloudService, cmd *cobra.Command, args []string) error { + var vpnGateways []ecloud.VPNGateway + for _, arg := range args { + vpnGateway, err := service.GetVPNGateway(arg) + if err != nil { + output.OutputWithErrorLevelf("Error retrieving VPN gateway [%s]: %s", arg, err) + continue + } + + vpnGateways = append(vpnGateways, vpnGateway) + } + + return output.CommandOutput(cmd, OutputECloudVPNGatewaysProvider(vpnGateways)) +} + +func ecloudVPNGatewayCreateCmd(f factory.ClientFactory) *cobra.Command { + cmd := &cobra.Command{ + Use: "create", + Short: "Creates a VPN gateway", + Example: "ans ecloud vpngateway create --router rtr-abcdef12 --specification vpngs-abcdef12", + RunE: ecloudCobraRunEFunc(f, ecloudVPNGatewayCreate), + } + + // Setup flags + cmd.Flags().String("name", "", "Name of gateway") + cmd.Flags().String("router", "", "ID of router") + cmd.MarkFlagRequired("router") + cmd.Flags().String("specification", "", "ID of VPN gateway specification") + cmd.MarkFlagRequired("specification") + cmd.Flags().Bool("wait", false, "Specifies that the command should wait until the VPN gateway has been completely created") + + return cmd +} + +func ecloudVPNGatewayCreate(service ecloud.ECloudService, cmd *cobra.Command, args []string) error { + createRequest := ecloud.CreateVPNGatewayRequest{} + createRequest.Name, _ = cmd.Flags().GetString("name") + createRequest.RouterID, _ = cmd.Flags().GetString("router") + createRequest.SpecificationID, _ = cmd.Flags().GetString("specification") + + taskRef, err := service.CreateVPNGateway(createRequest) + if err != nil { + return fmt.Errorf("Error creating VPN gateway: %s", err) + } + + waitFlag, _ := cmd.Flags().GetBool("wait") + if waitFlag { + err := helper.WaitForCommand(TaskStatusWaitFunc(service, taskRef.TaskID, ecloud.TaskStatusComplete)) + if err != nil { + return fmt.Errorf("Error waiting for VPN gateway task to complete: %s", err) + } + } + + vpnGateway, err := service.GetVPNGateway(taskRef.ResourceID) + if err != nil { + return fmt.Errorf("Error retrieving new VPN gateway: %s", err) + } + + return output.CommandOutput(cmd, OutputECloudVPNGatewaysProvider([]ecloud.VPNGateway{vpnGateway})) +} + +func ecloudVPNGatewayUpdateCmd(f factory.ClientFactory) *cobra.Command { + cmd := &cobra.Command{ + Use: "update ...", + Short: "Updates a VPN gateway", + Long: "Update the name of a VPN gateway", + Example: "ans ecloud vpngateway update vpng-abcdef12 --name \"my gateway\"", + Args: func(cmd *cobra.Command, args []string) error { + if len(args) < 1 { + return errors.New("Missing VPN gateway") + } + + return nil + }, + RunE: ecloudCobraRunEFunc(f, ecloudVPNGatewayUpdate), + } + + cmd.Flags().String("name", "", "Name of gateway") + cmd.Flags().Bool("wait", false, "Specifies that the command should wait until the VPN gateway has been completely updated") + + return cmd +} + +func ecloudVPNGatewayUpdate(service ecloud.ECloudService, cmd *cobra.Command, args []string) error { + patchRequest := ecloud.PatchVPNGatewayRequest{} + + if cmd.Flags().Changed("name") { + patchRequest.Name, _ = cmd.Flags().GetString("name") + } + + var vpnGateways []ecloud.VPNGateway + for _, arg := range args { + task, err := service.PatchVPNGateway(arg, patchRequest) + if err != nil { + output.OutputWithErrorLevelf("Error updating VPN gateway [%s]: %s", arg, err) + continue + } + + waitFlag, _ := cmd.Flags().GetBool("wait") + if waitFlag { + err := helper.WaitForCommand(TaskStatusWaitFunc(service, task.TaskID, ecloud.TaskStatusComplete)) + if err != nil { + output.OutputWithErrorLevelf("Error waiting for task to complete for VPN gateway [%s]: %s", arg, err) + continue + } + } + + vpnGateway, err := service.GetVPNGateway(arg) + if err != nil { + output.OutputWithErrorLevelf("Error retrieving updated VPN gateway [%s]: %s", arg, err) + continue + } + + vpnGateways = append(vpnGateways, vpnGateway) + } + + return output.CommandOutput(cmd, OutputECloudVPNGatewaysProvider(vpnGateways)) +} + +func ecloudVPNGatewayDeleteCmd(f factory.ClientFactory) *cobra.Command { + cmd := &cobra.Command{ + Use: "delete ...", + Short: "Removes a VPN gateway", + Example: "ans ecloud vpngateway delete vpng-abcdef12", + Args: func(cmd *cobra.Command, args []string) error { + if len(args) < 1 { + return errors.New("Missing VPN gateway") + } + + return nil + }, + RunE: ecloudCobraRunEFunc(f, ecloudVPNGatewayDelete), + } + + cmd.Flags().Bool("wait", false, "Specifies that the command should wait until the VPN gateway has been completely removed") + + return cmd +} + +func ecloudVPNGatewayDelete(service ecloud.ECloudService, cmd *cobra.Command, args []string) error { + for _, arg := range args { + taskID, err := service.DeleteVPNGateway(arg) + if err != nil { + output.OutputWithErrorLevelf("Error removing VPN gateway [%s]: %s", arg, err) + continue + } + + waitFlag, _ := cmd.Flags().GetBool("wait") + if waitFlag { + err := helper.WaitForCommand(TaskStatusWaitFunc(service, taskID, ecloud.TaskStatusComplete)) + if err != nil { + output.OutputWithErrorLevelf("Error waiting for task to complete for VPN gateway [%s]: %s", arg, err) + continue + } + } + } + return nil +} diff --git a/cmd/ecloud/ecloud_vpngateway_specs.go b/cmd/ecloud/ecloud_vpngateway_specs.go new file mode 100644 index 0000000..d6c5d5c --- /dev/null +++ b/cmd/ecloud/ecloud_vpngateway_specs.go @@ -0,0 +1,85 @@ +package ecloud + +import ( + "errors" + "fmt" + + "github.com/ans-group/cli/internal/pkg/factory" + "github.com/ans-group/cli/internal/pkg/helper" + "github.com/ans-group/cli/internal/pkg/output" + "github.com/ans-group/sdk-go/pkg/service/ecloud" + "github.com/spf13/cobra" +) + +func ecloudVPNGatewaySpecificationRootCmd(f factory.ClientFactory) *cobra.Command { + cmd := &cobra.Command{ + Use: "spec", + Short: "sub-commands relating to VPN gateway specifications", + } + + // Child commands + cmd.AddCommand(ecloudVPNGatewaySpecificationListCmd(f)) + cmd.AddCommand(ecloudVPNGatewaySpecificationShowCmd(f)) + + return cmd +} + +func ecloudVPNGatewaySpecificationListCmd(f factory.ClientFactory) *cobra.Command { + cmd := &cobra.Command{ + Use: "list", + Short: "Lists VPN gateway specifications", + Example: "ans ecloud vpngateway spec list", + RunE: ecloudCobraRunEFunc(f, ecloudVPNGatewaySpecificationList), + } + + cmd.Flags().String("name", "", "VPN gateway specification name for filtering") + + return cmd +} + +func ecloudVPNGatewaySpecificationList(service ecloud.ECloudService, cmd *cobra.Command, args []string) error { + params, err := helper.GetAPIRequestParametersFromFlags(cmd, + helper.NewStringFilterFlagOption("name", "name"), + ) + if err != nil { + return err + } + + specs, err := service.GetVPNGatewaySpecifications(params) + if err != nil { + return fmt.Errorf("Error retrieving VPN gateway specifications: %s", err) + } + + return output.CommandOutput(cmd, OutputECloudVPNGatewaySpecificationsProvider(specs)) +} + +func ecloudVPNGatewaySpecificationShowCmd(f factory.ClientFactory) *cobra.Command { + return &cobra.Command{ + Use: "show ...", + Short: "Show details of a VPN gateway specification", + Example: "ans ecloud vpngateway spec show vpngs-abcdef12", + Args: func(cmd *cobra.Command, args []string) error { + if len(args) < 1 { + return errors.New("Missing VPN gateway specification") + } + + return nil + }, + RunE: ecloudCobraRunEFunc(f, ecloudVPNGatewaySpecificationShow), + } +} + +func ecloudVPNGatewaySpecificationShow(service ecloud.ECloudService, cmd *cobra.Command, args []string) error { + var specs []ecloud.VPNGatewaySpecification + for _, arg := range args { + spec, err := service.GetVPNGatewaySpecification(arg) + if err != nil { + output.OutputWithErrorLevelf("Error retrieving VPN gateway specification [%s]: %s", arg, err) + continue + } + + specs = append(specs, spec) + } + + return output.CommandOutput(cmd, OutputECloudVPNGatewaySpecificationsProvider(specs)) +} diff --git a/cmd/ecloud/ecloud_vpngateway_specs_test.go b/cmd/ecloud/ecloud_vpngateway_specs_test.go new file mode 100644 index 0000000..2a9b022 --- /dev/null +++ b/cmd/ecloud/ecloud_vpngateway_specs_test.go @@ -0,0 +1,108 @@ +package ecloud + +import ( + "errors" + "testing" + + "github.com/ans-group/cli/internal/pkg/clierrors" + "github.com/ans-group/cli/test/mocks" + "github.com/ans-group/cli/test/test_output" + "github.com/ans-group/sdk-go/pkg/service/ecloud" + gomock "github.com/golang/mock/gomock" + "github.com/spf13/cobra" + "github.com/stretchr/testify/assert" +) + +func Test_ecloudVPNGatewaySpecificationList(t *testing.T) { + t.Run("DefaultRetrieve", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().GetVPNGatewaySpecifications(gomock.Any()).Return([]ecloud.VPNGatewaySpecification{}, nil).Times(1) + + ecloudVPNGatewaySpecificationList(service, &cobra.Command{}, []string{}) + }) + + t.Run("MalformedFlag_ReturnsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + cmd := &cobra.Command{} + cmd.Flags().StringArray("filter", []string{"invalidfilter"}, "") + + err := ecloudVPNGatewaySpecificationList(service, cmd, []string{}) + + assert.IsType(t, &clierrors.ErrInvalidFlagValue{}, err) + }) + + t.Run("GetVPNGatewaySpecificationsError_ReturnsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().GetVPNGatewaySpecifications(gomock.Any()).Return([]ecloud.VPNGatewaySpecification{}, errors.New("test error")).Times(1) + + err := ecloudVPNGatewaySpecificationList(service, &cobra.Command{}, []string{}) + + assert.Equal(t, "Error retrieving VPN gateway specifications: test error", err.Error()) + }) +} + +func Test_ecloudVPNGatewaySpecificationShowCmd_Args(t *testing.T) { + t.Run("ValidArgs_NoError", func(t *testing.T) { + err := ecloudVPNGatewaySpecificationShowCmd(nil).Args(nil, []string{"vpngs-abcdef12"}) + + assert.Nil(t, err) + }) + + t.Run("InvalidArgs_Error", func(t *testing.T) { + err := ecloudVPNGatewaySpecificationShowCmd(nil).Args(nil, []string{}) + + assert.NotNil(t, err) + assert.Equal(t, "Missing VPN gateway specification", err.Error()) + }) +} + +func Test_ecloudVPNGatewaySpecificationShow(t *testing.T) { + t.Run("SingleSpecification", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().GetVPNGatewaySpecification("vpngs-abcdef12").Return(ecloud.VPNGatewaySpecification{}, nil).Times(1) + + ecloudVPNGatewaySpecificationShow(service, &cobra.Command{}, []string{"vpngs-abcdef12"}) + }) + + t.Run("MultipleSpecifications", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + gomock.InOrder( + service.EXPECT().GetVPNGatewaySpecification("vpngs-abcdef12").Return(ecloud.VPNGatewaySpecification{}, nil), + service.EXPECT().GetVPNGatewaySpecification("vpngs-abcdef23").Return(ecloud.VPNGatewaySpecification{}, nil), + ) + + ecloudVPNGatewaySpecificationShow(service, &cobra.Command{}, []string{"vpngs-abcdef12", "vpngs-abcdef23"}) + }) + + t.Run("GetVPNGatewaySpecificationError_OutputsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().GetVPNGatewaySpecification("vpngs-abcdef12").Return(ecloud.VPNGatewaySpecification{}, errors.New("test error")) + + test_output.AssertErrorOutput(t, "Error retrieving VPN gateway specification [vpngs-abcdef12]: test error\n", func() { + ecloudVPNGatewaySpecificationShow(service, &cobra.Command{}, []string{"vpngs-abcdef12"}) + }) + }) +} diff --git a/cmd/ecloud/ecloud_vpngateway_test.go b/cmd/ecloud/ecloud_vpngateway_test.go new file mode 100644 index 0000000..71c0372 --- /dev/null +++ b/cmd/ecloud/ecloud_vpngateway_test.go @@ -0,0 +1,435 @@ +package ecloud + +import ( + "errors" + "testing" + + "github.com/ans-group/cli/internal/pkg/clierrors" + "github.com/ans-group/cli/test/mocks" + "github.com/ans-group/cli/test/test_output" + "github.com/ans-group/sdk-go/pkg/service/ecloud" + gomock "github.com/golang/mock/gomock" + "github.com/spf13/cobra" + "github.com/stretchr/testify/assert" +) + +func Test_ecloudVPNGatewayList(t *testing.T) { + t.Run("DefaultRetrieve", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().GetVPNGateways(gomock.Any()).Return([]ecloud.VPNGateway{}, nil).Times(1) + + ecloudVPNGatewayList(service, &cobra.Command{}, []string{}) + }) + + t.Run("MalformedFlag_ReturnsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + cmd := &cobra.Command{} + cmd.Flags().StringArray("filter", []string{"invalidfilter"}, "") + + err := ecloudVPNGatewayList(service, cmd, []string{}) + + assert.IsType(t, &clierrors.ErrInvalidFlagValue{}, err) + }) + + t.Run("GetVPNGatewaysError_ReturnsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().GetVPNGateways(gomock.Any()).Return([]ecloud.VPNGateway{}, errors.New("test error")).Times(1) + + err := ecloudVPNGatewayList(service, &cobra.Command{}, []string{}) + + assert.Equal(t, "Error retrieving VPN gateways: test error", err.Error()) + }) +} + +func Test_ecloudVPNGatewayShowCmd_Args(t *testing.T) { + t.Run("ValidArgs_NoError", func(t *testing.T) { + err := ecloudVPNGatewayShowCmd(nil).Args(nil, []string{"vpng-abcdef12"}) + + assert.Nil(t, err) + }) + + t.Run("InvalidArgs_Error", func(t *testing.T) { + err := ecloudVPNGatewayShowCmd(nil).Args(nil, []string{}) + + assert.NotNil(t, err) + assert.Equal(t, "Missing VPN gateway", err.Error()) + }) +} + +func Test_ecloudVPNGatewayShow(t *testing.T) { + t.Run("SingleGateway", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().GetVPNGateway("vpng-abcdef12").Return(ecloud.VPNGateway{}, nil).Times(1) + + ecloudVPNGatewayShow(service, &cobra.Command{}, []string{"vpng-abcdef12"}) + }) + + t.Run("MultipleVPNGateways", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + gomock.InOrder( + service.EXPECT().GetVPNGateway("vpng-abcdef12").Return(ecloud.VPNGateway{}, nil), + service.EXPECT().GetVPNGateway("vpng-abcdef23").Return(ecloud.VPNGateway{}, nil), + ) + + ecloudVPNGatewayShow(service, &cobra.Command{}, []string{"vpng-abcdef12", "vpng-abcdef23"}) + }) + + t.Run("GetVPNGatewayError_OutputsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().GetVPNGateway("vpng-abcdef12").Return(ecloud.VPNGateway{}, errors.New("test error")) + + test_output.AssertErrorOutput(t, "Error retrieving VPN gateway [vpng-abcdef12]: test error\n", func() { + ecloudVPNGatewayShow(service, &cobra.Command{}, []string{"vpng-abcdef12"}) + }) + }) +} + +func Test_ecloudVPNGatewayCreate(t *testing.T) { + t.Run("DefaultCreate", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + cmd := ecloudVPNGatewayCreateCmd(nil) + cmd.ParseFlags([]string{"--name=testgateway", "--router=rtr-abcdef12", "--specification=vpngs-abcdef12"}) + + req := ecloud.CreateVPNGatewayRequest{ + Name: "testgateway", + RouterID: "rtr-abcdef12", + SpecificationID: "vpngs-abcdef12", + } + + resp := ecloud.TaskReference{ + TaskID: "task-abcdef12", + ResourceID: "vpng-abcdef12", + } + + gomock.InOrder( + service.EXPECT().CreateVPNGateway(req).Return(resp, nil), + service.EXPECT().GetVPNGateway("vpng-abcdef12").Return(ecloud.VPNGateway{}, nil), + ) + + ecloudVPNGatewayCreate(service, cmd, []string{}) + }) + + t.Run("CreateWithWaitFlagNoError_Succeeds", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + cmd := ecloudVPNGatewayCreateCmd(nil) + cmd.ParseFlags([]string{"--name=testgateway", "--router=rtr-abcdef12", "--specification=vpngs-abcdef12", "--wait"}) + + req := ecloud.CreateVPNGatewayRequest{ + Name: "testgateway", + RouterID: "rtr-abcdef12", + SpecificationID: "vpngs-abcdef12", + } + + resp := ecloud.TaskReference{ + TaskID: "task-abcdef12", + ResourceID: "vpng-abcdef12", + } + + gomock.InOrder( + service.EXPECT().CreateVPNGateway(req).Return(resp, nil), + service.EXPECT().GetTask("task-abcdef12").Return(ecloud.Task{Status: ecloud.TaskStatusComplete}, nil), + service.EXPECT().GetVPNGateway("vpng-abcdef12").Return(ecloud.VPNGateway{}, nil), + ) + + ecloudVPNGatewayCreate(service, cmd, []string{}) + }) + + t.Run("WithWaitFlag_GetTaskError_ReturnsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + cmd := ecloudVPNGatewayCreateCmd(nil) + cmd.ParseFlags([]string{"--name=testgateway", "--router=rtr-abcdef12", "--specification=vpngs-abcdef12", "--wait"}) + + req := ecloud.CreateVPNGatewayRequest{ + Name: "testgateway", + RouterID: "rtr-abcdef12", + SpecificationID: "vpngs-abcdef12", + } + + resp := ecloud.TaskReference{ + TaskID: "task-abcdef12", + ResourceID: "vpng-abcdef12", + } + + gomock.InOrder( + service.EXPECT().CreateVPNGateway(req).Return(resp, nil), + service.EXPECT().GetTask("task-abcdef12").Return(ecloud.Task{Status: ecloud.TaskStatusComplete}, errors.New("test error")), + ) + + err := ecloudVPNGatewayCreate(service, cmd, []string{}) + assert.Equal(t, "Error waiting for VPN gateway task to complete: Error waiting for command: Failed to retrieve task status: test error", err.Error()) + }) + + t.Run("CreateVPNGatewayError_ReturnsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + cmd := ecloudVPNGatewayCreateCmd(nil) + cmd.ParseFlags([]string{"--name=testgateway", "--router=rtr-abcdef12", "--specification=vpngs-abcdef12"}) + + service.EXPECT().CreateVPNGateway(gomock.Any()).Return(ecloud.TaskReference{}, errors.New("test error")).Times(1) + + err := ecloudVPNGatewayCreate(service, cmd, []string{}) + + assert.Equal(t, "Error creating VPN gateway: test error", err.Error()) + }) + + t.Run("GetVPNGatewayError_ReturnsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + cmd := ecloudVPNGatewayCreateCmd(nil) + cmd.ParseFlags([]string{"--name=testgateway", "--router=rtr-abcdef12", "--specification=vpngs-abcdef12"}) + + gomock.InOrder( + service.EXPECT().CreateVPNGateway(gomock.Any()).Return(ecloud.TaskReference{ResourceID: "vpng-abcdef12"}, nil), + service.EXPECT().GetVPNGateway("vpng-abcdef12").Return(ecloud.VPNGateway{}, errors.New("test error")), + ) + + err := ecloudVPNGatewayCreate(service, cmd, []string{}) + + assert.Equal(t, "Error retrieving new VPN gateway: test error", err.Error()) + }) +} + +func Test_ecloudVPNGatewayUpdateCmd_Args(t *testing.T) { + t.Run("ValidArgs_NoError", func(t *testing.T) { + err := ecloudVPNGatewayUpdateCmd(nil).Args(nil, []string{"vpng-abcdef12"}) + + assert.Nil(t, err) + }) + + t.Run("InvalidArgs_Error", func(t *testing.T) { + err := ecloudVPNGatewayUpdateCmd(nil).Args(nil, []string{}) + + assert.NotNil(t, err) + assert.Equal(t, "Missing VPN gateway", err.Error()) + }) +} + +func Test_ecloudVPNGatewayUpdate(t *testing.T) { + t.Run("SingleGateway", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + cmd := ecloudVPNGatewayUpdateCmd(nil) + cmd.ParseFlags([]string{"--name=testgateway"}) + + req := ecloud.PatchVPNGatewayRequest{ + Name: "testgateway", + } + + resp := ecloud.TaskReference{ + TaskID: "task-abcdef12", + ResourceID: "vpng-abcdef12", + } + + gomock.InOrder( + service.EXPECT().PatchVPNGateway("vpng-abcdef12", req).Return(resp, nil), + service.EXPECT().GetVPNGateway("vpng-abcdef12").Return(ecloud.VPNGateway{}, nil), + ) + + ecloudVPNGatewayUpdate(service, cmd, []string{"vpng-abcdef12"}) + }) + + t.Run("WithWaitFlag_NoError_Succeeds", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + cmd := ecloudVPNGatewayUpdateCmd(nil) + cmd.ParseFlags([]string{"--name=testgateway", "--wait"}) + + req := ecloud.PatchVPNGatewayRequest{ + Name: "testgateway", + } + + resp := ecloud.TaskReference{ + TaskID: "task-abcdef12", + ResourceID: "vpng-abcdef12", + } + + gomock.InOrder( + service.EXPECT().PatchVPNGateway("vpng-abcdef12", req).Return(resp, nil), + service.EXPECT().GetTask("task-abcdef12").Return(ecloud.Task{Status: ecloud.TaskStatusComplete}, nil), + service.EXPECT().GetVPNGateway("vpng-abcdef12").Return(ecloud.VPNGateway{}, nil), + ) + + ecloudVPNGatewayUpdate(service, cmd, []string{"vpng-abcdef12"}) + }) + + t.Run("WithWaitFlag_GetTaskError_OutputsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + cmd := ecloudVPNGatewayUpdateCmd(nil) + cmd.ParseFlags([]string{"--name=testgateway", "--wait"}) + + req := ecloud.PatchVPNGatewayRequest{ + Name: "testgateway", + } + + resp := ecloud.TaskReference{ + TaskID: "task-abcdef12", + ResourceID: "vpng-abcdef12", + } + + gomock.InOrder( + service.EXPECT().PatchVPNGateway("vpng-abcdef12", req).Return(resp, nil), + service.EXPECT().GetTask("task-abcdef12").Return(ecloud.Task{Status: ecloud.TaskStatusComplete}, errors.New("test error")), + ) + + test_output.AssertErrorOutput(t, "Error waiting for task to complete for VPN gateway [vpng-abcdef12]: Error waiting for command: Failed to retrieve task status: test error\n", func() { + ecloudVPNGatewayUpdate(service, cmd, []string{"vpng-abcdef12"}) + }) + }) + + t.Run("PatchVPNGatewayError_OutputsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().PatchVPNGateway("vpng-abcdef12", gomock.Any()).Return(ecloud.TaskReference{}, errors.New("test error")) + + test_output.AssertErrorOutput(t, "Error updating VPN gateway [vpng-abcdef12]: test error\n", func() { + ecloudVPNGatewayUpdate(service, &cobra.Command{}, []string{"vpng-abcdef12"}) + }) + }) + + t.Run("GetVPNGatewayError_OutputsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + resp := ecloud.TaskReference{ + TaskID: "task-abcdef12", + ResourceID: "vpng-abcdef12", + } + + gomock.InOrder( + service.EXPECT().PatchVPNGateway("vpng-abcdef12", gomock.Any()).Return(resp, nil), + service.EXPECT().GetVPNGateway("vpng-abcdef12").Return(ecloud.VPNGateway{}, errors.New("test error")), + ) + + test_output.AssertErrorOutput(t, "Error retrieving updated VPN gateway [vpng-abcdef12]: test error\n", func() { + ecloudVPNGatewayUpdate(service, &cobra.Command{}, []string{"vpng-abcdef12"}) + }) + }) +} + +func Test_ecloudVPNGatewayDeleteCmd_Args(t *testing.T) { + t.Run("ValidArgs_NoError", func(t *testing.T) { + err := ecloudVPNGatewayDeleteCmd(nil).Args(nil, []string{"vpng-abcdef12"}) + + assert.Nil(t, err) + }) + + t.Run("InvalidArgs_Error", func(t *testing.T) { + err := ecloudVPNGatewayDeleteCmd(nil).Args(nil, []string{}) + + assert.NotNil(t, err) + assert.Equal(t, "Missing VPN gateway", err.Error()) + }) +} + +func Test_ecloudVPNGatewayDelete(t *testing.T) { + t.Run("SingleGateway", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().DeleteVPNGateway("vpng-abcdef12").Return("task-abcdef12", nil) + + ecloudVPNGatewayDelete(service, &cobra.Command{}, []string{"vpng-abcdef12"}) + }) + + t.Run("WithWaitFlag_NoError_Succeeds", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + cmd := ecloudVPNGatewayDeleteCmd(nil) + cmd.ParseFlags([]string{"--wait"}) + + service := mocks.NewMockECloudService(mockCtrl) + + gomock.InOrder( + service.EXPECT().DeleteVPNGateway("vpng-abcdef12").Return("task-abcdef12", nil), + service.EXPECT().GetTask("task-abcdef12").Return(ecloud.Task{Status: ecloud.TaskStatusComplete}, nil), + ) + + ecloudVPNGatewayDelete(service, cmd, []string{"vpng-abcdef12"}) + }) + + t.Run("WithWaitFlag_GetTaskError_OutputsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + cmd := ecloudVPNGatewayDeleteCmd(nil) + cmd.ParseFlags([]string{"--wait"}) + + gomock.InOrder( + service.EXPECT().DeleteVPNGateway("vpng-abcdef12").Return("task-abcdef12", nil), + service.EXPECT().GetTask("task-abcdef12").Return(ecloud.Task{Status: ecloud.TaskStatusComplete}, errors.New("test error")), + ) + + test_output.AssertErrorOutput(t, "Error waiting for task to complete for VPN gateway [vpng-abcdef12]: Error waiting for command: Failed to retrieve task status: test error\n", func() { + ecloudVPNGatewayDelete(service, cmd, []string{"vpng-abcdef12"}) + }) + }) + + t.Run("DeleteVPNGatewayError_OutputsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().DeleteVPNGateway("vpng-abcdef12").Return("", errors.New("test error")).Times(1) + + test_output.AssertErrorOutput(t, "Error removing VPN gateway [vpng-abcdef12]: test error\n", func() { + ecloudVPNGatewayDelete(service, &cobra.Command{}, []string{"vpng-abcdef12"}) + }) + }) +} diff --git a/cmd/ecloud/ecloud_vpngateway_user.go b/cmd/ecloud/ecloud_vpngateway_user.go new file mode 100644 index 0000000..97aebe2 --- /dev/null +++ b/cmd/ecloud/ecloud_vpngateway_user.go @@ -0,0 +1,242 @@ +package ecloud + +import ( + "errors" + "fmt" + + "github.com/ans-group/cli/internal/pkg/factory" + "github.com/ans-group/cli/internal/pkg/helper" + "github.com/ans-group/cli/internal/pkg/output" + "github.com/ans-group/sdk-go/pkg/service/ecloud" + "github.com/spf13/cobra" +) + +func ecloudVPNGatewayUserRootCmd(f factory.ClientFactory) *cobra.Command { + cmd := &cobra.Command{ + Use: "user", + Short: "sub-commands relating to VPN gateway users", + } + + // Child commands + cmd.AddCommand(ecloudVPNGatewayUserListCmd(f)) + cmd.AddCommand(ecloudVPNGatewayUserShowCmd(f)) + cmd.AddCommand(ecloudVPNGatewayUserCreateCmd(f)) + cmd.AddCommand(ecloudVPNGatewayUserUpdateCmd(f)) + cmd.AddCommand(ecloudVPNGatewayUserDeleteCmd(f)) + + return cmd +} + +func ecloudVPNGatewayUserListCmd(f factory.ClientFactory) *cobra.Command { + cmd := &cobra.Command{ + Use: "list", + Short: "Lists VPN gateway users", + Long: "This command lists VPN gateway users", + Example: "ans ecloud vpngateway user list", + RunE: ecloudCobraRunEFunc(f, ecloudVPNGatewayUserList), + } + + cmd.Flags().String("name", "", "VPN gateway user name for filtering") + cmd.Flags().String("vpngateway", "", "VPN gateway ID for filtering") + + return cmd +} + +func ecloudVPNGatewayUserList(service ecloud.ECloudService, cmd *cobra.Command, args []string) error { + params, err := helper.GetAPIRequestParametersFromFlags(cmd, + helper.NewStringFilterFlagOption("name", "name"), + helper.NewStringFilterFlagOption("vpngateway", "vpn_gateway_id"), + ) + if err != nil { + return err + } + + users, err := service.GetVPNGatewayUsers(params) + if err != nil { + return fmt.Errorf("Error retrieving VPN gateway users: %s", err) + } + + return output.CommandOutput(cmd, OutputECloudVPNGatewayUsersProvider(users)) +} + +func ecloudVPNGatewayUserShowCmd(f factory.ClientFactory) *cobra.Command { + return &cobra.Command{ + Use: "show ...", + Short: "Shows a VPN gateway user", + Example: "ans ecloud vpngateway user show vpngu-abcdef12", + Args: func(cmd *cobra.Command, args []string) error { + if len(args) < 1 { + return errors.New("Missing VPN gateway user") + } + + return nil + }, + RunE: ecloudCobraRunEFunc(f, ecloudVPNGatewayUserShow), + } +} + +func ecloudVPNGatewayUserShow(service ecloud.ECloudService, cmd *cobra.Command, args []string) error { + var users []ecloud.VPNGatewayUser + for _, arg := range args { + user, err := service.GetVPNGatewayUser(arg) + if err != nil { + output.OutputWithErrorLevelf("Error retrieving VPN gateway user [%s]: %s", arg, err) + continue + } + + users = append(users, user) + } + + return output.CommandOutput(cmd, OutputECloudVPNGatewayUsersProvider(users)) +} + +func ecloudVPNGatewayUserCreateCmd(f factory.ClientFactory) *cobra.Command { + cmd := &cobra.Command{ + Use: "create", + Short: "Creates a VPN gateway user", + Example: "ans ecloud vpngateway user create --vpngateway vpng-abcdef12 --username testuser --password testpass", + RunE: ecloudCobraRunEFunc(f, ecloudVPNGatewayUserCreate), + } + + // Setup flags + cmd.Flags().String("name", "", "Name of user") + cmd.Flags().String("vpngateway", "", "ID of VPN gateway") + cmd.MarkFlagRequired("vpngateway") + cmd.Flags().String("username", "", "Username for the VPN user") + cmd.MarkFlagRequired("username") + cmd.Flags().String("password", "", "Password for the VPN user") + cmd.MarkFlagRequired("password") + cmd.Flags().Bool("wait", false, "Specifies that the command should wait until the user has been created") + + return cmd +} + +func ecloudVPNGatewayUserCreate(service ecloud.ECloudService, cmd *cobra.Command, args []string) error { + createRequest := ecloud.CreateVPNGatewayUserRequest{} + createRequest.Name, _ = cmd.Flags().GetString("name") + createRequest.VPNGatewayID, _ = cmd.Flags().GetString("vpngateway") + createRequest.Username, _ = cmd.Flags().GetString("username") + createRequest.Password, _ = cmd.Flags().GetString("password") + + taskRef, err := service.CreateVPNGatewayUser(createRequest) + if err != nil { + return fmt.Errorf("Error creating VPN gateway user: %s", err) + } + + waitFlag, _ := cmd.Flags().GetBool("wait") + if waitFlag { + err := helper.WaitForCommand(TaskStatusWaitFunc(service, taskRef.TaskID, ecloud.TaskStatusComplete)) + if err != nil { + return fmt.Errorf("Error waiting for VPN gateway user task to complete: %s", err) + } + } + + user, err := service.GetVPNGatewayUser(taskRef.ResourceID) + if err != nil { + return fmt.Errorf("Error retrieving new VPN gateway user: %s", err) + } + + return output.CommandOutput(cmd, OutputECloudVPNGatewayUsersProvider([]ecloud.VPNGatewayUser{user})) +} + +func ecloudVPNGatewayUserUpdateCmd(f factory.ClientFactory) *cobra.Command { + cmd := &cobra.Command{ + Use: "update ...", + Short: "Updates a VPN gateway user", + Long: "Updates the specified VPN user's friendly name and/or password", + Example: "ans ecloud vpngateway user update vpngu-abcdef12 --name \"my user\" --password newpass123", + Args: func(cmd *cobra.Command, args []string) error { + if len(args) < 1 { + return errors.New("Missing VPN gateway user") + } + + return nil + }, + RunE: ecloudCobraRunEFunc(f, ecloudVPNGatewayUserUpdate), + } + + cmd.Flags().String("name", "", "Name of user") + cmd.Flags().String("password", "", "Password for the VPN user") + cmd.Flags().Bool("wait", false, "Specifies that the command should wait until the user has been updated") + + return cmd +} + +func ecloudVPNGatewayUserUpdate(service ecloud.ECloudService, cmd *cobra.Command, args []string) error { + patchRequest := ecloud.PatchVPNGatewayUserRequest{} + + if cmd.Flags().Changed("name") { + patchRequest.Name, _ = cmd.Flags().GetString("name") + } + if cmd.Flags().Changed("password") { + patchRequest.Password, _ = cmd.Flags().GetString("password") + } + + var users []ecloud.VPNGatewayUser + for _, arg := range args { + task, err := service.PatchVPNGatewayUser(arg, patchRequest) + if err != nil { + output.OutputWithErrorLevelf("Error updating VPN gateway user [%s]: %s", arg, err) + continue + } + + waitFlag, _ := cmd.Flags().GetBool("wait") + if waitFlag { + err := helper.WaitForCommand(TaskStatusWaitFunc(service, task.TaskID, ecloud.TaskStatusComplete)) + if err != nil { + output.OutputWithErrorLevelf("Error waiting for task to complete for VPN gateway user [%s]: %s", arg, err) + continue + } + } + + user, err := service.GetVPNGatewayUser(arg) + if err != nil { + output.OutputWithErrorLevelf("Error retrieving updated VPN gateway user [%s]: %s", arg, err) + continue + } + + users = append(users, user) + } + + return output.CommandOutput(cmd, OutputECloudVPNGatewayUsersProvider(users)) +} + +func ecloudVPNGatewayUserDeleteCmd(f factory.ClientFactory) *cobra.Command { + cmd := &cobra.Command{ + Use: "delete ...", + Short: "Removes a VPN gateway user", + Example: "ans ecloud vpngateway user delete vpngu-abcdef12", + Args: func(cmd *cobra.Command, args []string) error { + if len(args) < 1 { + return errors.New("Missing VPN gateway user") + } + + return nil + }, + RunE: ecloudCobraRunEFunc(f, ecloudVPNGatewayUserDelete), + } + + cmd.Flags().Bool("wait", false, "Specifies that the command should wait until the user has been removed") + + return cmd +} + +func ecloudVPNGatewayUserDelete(service ecloud.ECloudService, cmd *cobra.Command, args []string) error { + for _, arg := range args { + taskID, err := service.DeleteVPNGatewayUser(arg) + if err != nil { + output.OutputWithErrorLevelf("Error removing VPN gateway user [%s]: %s", arg, err) + continue + } + + waitFlag, _ := cmd.Flags().GetBool("wait") + if waitFlag { + err := helper.WaitForCommand(TaskStatusWaitFunc(service, taskID, ecloud.TaskStatusComplete)) + if err != nil { + output.OutputWithErrorLevelf("Error waiting for task to complete for VPN gateway user [%s]: %s", arg, err) + continue + } + } + } + return nil +} diff --git a/cmd/ecloud/ecloud_vpngateway_user_test.go b/cmd/ecloud/ecloud_vpngateway_user_test.go new file mode 100644 index 0000000..7bf91e3 --- /dev/null +++ b/cmd/ecloud/ecloud_vpngateway_user_test.go @@ -0,0 +1,439 @@ +package ecloud + +import ( + "errors" + "testing" + + "github.com/ans-group/cli/internal/pkg/clierrors" + "github.com/ans-group/cli/test/mocks" + "github.com/ans-group/cli/test/test_output" + "github.com/ans-group/sdk-go/pkg/service/ecloud" + gomock "github.com/golang/mock/gomock" + "github.com/spf13/cobra" + "github.com/stretchr/testify/assert" +) + +func Test_ecloudVPNGatewayUserList(t *testing.T) { + t.Run("DefaultRetrieve", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().GetVPNGatewayUsers(gomock.Any()).Return([]ecloud.VPNGatewayUser{}, nil).Times(1) + + ecloudVPNGatewayUserList(service, &cobra.Command{}, []string{}) + }) + + t.Run("MalformedFlag_ReturnsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + cmd := &cobra.Command{} + cmd.Flags().StringArray("filter", []string{"invalidfilter"}, "") + + err := ecloudVPNGatewayUserList(service, cmd, []string{}) + + assert.IsType(t, &clierrors.ErrInvalidFlagValue{}, err) + }) + + t.Run("GetVPNGatewayUsersError_ReturnsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().GetVPNGatewayUsers(gomock.Any()).Return([]ecloud.VPNGatewayUser{}, errors.New("test error")).Times(1) + + err := ecloudVPNGatewayUserList(service, &cobra.Command{}, []string{}) + + assert.Equal(t, "Error retrieving VPN gateway users: test error", err.Error()) + }) +} + +func Test_ecloudVPNGatewayUserShowCmd_Args(t *testing.T) { + t.Run("ValidArgs_NoError", func(t *testing.T) { + err := ecloudVPNGatewayUserShowCmd(nil).Args(nil, []string{"vpngu-abcdef12"}) + + assert.Nil(t, err) + }) + + t.Run("InvalidArgs_Error", func(t *testing.T) { + err := ecloudVPNGatewayUserShowCmd(nil).Args(nil, []string{}) + + assert.NotNil(t, err) + assert.Equal(t, "Missing VPN gateway user", err.Error()) + }) +} + +func Test_ecloudVPNGatewayUserShow(t *testing.T) { + t.Run("SingleUser", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().GetVPNGatewayUser("vpngu-abcdef12").Return(ecloud.VPNGatewayUser{}, nil).Times(1) + + ecloudVPNGatewayUserShow(service, &cobra.Command{}, []string{"vpngu-abcdef12"}) + }) + + t.Run("MultipleUsers", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + gomock.InOrder( + service.EXPECT().GetVPNGatewayUser("vpngu-abcdef12").Return(ecloud.VPNGatewayUser{}, nil), + service.EXPECT().GetVPNGatewayUser("vpngu-abcdef23").Return(ecloud.VPNGatewayUser{}, nil), + ) + + ecloudVPNGatewayUserShow(service, &cobra.Command{}, []string{"vpngu-abcdef12", "vpngu-abcdef23"}) + }) + + t.Run("GetVPNGatewayUserError_OutputsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().GetVPNGatewayUser("vpngu-abcdef12").Return(ecloud.VPNGatewayUser{}, errors.New("test error")) + + test_output.AssertErrorOutput(t, "Error retrieving VPN gateway user [vpngu-abcdef12]: test error\n", func() { + ecloudVPNGatewayUserShow(service, &cobra.Command{}, []string{"vpngu-abcdef12"}) + }) + }) +} + +func Test_ecloudVPNGatewayUserCreate(t *testing.T) { + t.Run("DefaultCreate", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + cmd := ecloudVPNGatewayUserCreateCmd(nil) + cmd.ParseFlags([]string{"--name=testuser", "--vpngateway=vpng-abcdef12", "--username=user1", "--password=pass123"}) + + req := ecloud.CreateVPNGatewayUserRequest{ + Name: "testuser", + VPNGatewayID: "vpng-abcdef12", + Username: "user1", + Password: "pass123", + } + + resp := ecloud.TaskReference{ + TaskID: "task-abcdef12", + ResourceID: "vpngu-abcdef12", + } + + gomock.InOrder( + service.EXPECT().CreateVPNGatewayUser(req).Return(resp, nil), + service.EXPECT().GetVPNGatewayUser("vpngu-abcdef12").Return(ecloud.VPNGatewayUser{}, nil), + ) + + ecloudVPNGatewayUserCreate(service, cmd, []string{}) + }) + + t.Run("CreateWithWaitFlagNoError_Succeeds", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + cmd := ecloudVPNGatewayUserCreateCmd(nil) + cmd.ParseFlags([]string{"--name=testuser", "--vpngateway=vpng-abcdef12", "--username=user1", "--password=pass123", "--wait"}) + + req := ecloud.CreateVPNGatewayUserRequest{ + Name: "testuser", + VPNGatewayID: "vpng-abcdef12", + Username: "user1", + Password: "pass123", + } + + resp := ecloud.TaskReference{ + TaskID: "task-abcdef12", + ResourceID: "vpngu-abcdef12", + } + + gomock.InOrder( + service.EXPECT().CreateVPNGatewayUser(req).Return(resp, nil), + service.EXPECT().GetTask("task-abcdef12").Return(ecloud.Task{Status: ecloud.TaskStatusComplete}, nil), + service.EXPECT().GetVPNGatewayUser("vpngu-abcdef12").Return(ecloud.VPNGatewayUser{}, nil), + ) + + ecloudVPNGatewayUserCreate(service, cmd, []string{}) + }) + + t.Run("WithWaitFlag_GetTaskError_ReturnsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + cmd := ecloudVPNGatewayUserCreateCmd(nil) + cmd.ParseFlags([]string{"--name=testuser", "--vpngateway=vpng-abcdef12", "--username=user1", "--password=pass123", "--wait"}) + + req := ecloud.CreateVPNGatewayUserRequest{ + Name: "testuser", + VPNGatewayID: "vpng-abcdef12", + Username: "user1", + Password: "pass123", + } + + resp := ecloud.TaskReference{ + TaskID: "task-abcdef12", + ResourceID: "vpngu-abcdef12", + } + + gomock.InOrder( + service.EXPECT().CreateVPNGatewayUser(req).Return(resp, nil), + service.EXPECT().GetTask("task-abcdef12").Return(ecloud.Task{Status: ecloud.TaskStatusComplete}, errors.New("test error")), + ) + + err := ecloudVPNGatewayUserCreate(service, cmd, []string{}) + assert.Equal(t, "Error waiting for VPN gateway user task to complete: Error waiting for command: Failed to retrieve task status: test error", err.Error()) + }) + + t.Run("CreateVPNGatewayUserError_ReturnsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + cmd := ecloudVPNGatewayUserCreateCmd(nil) + cmd.ParseFlags([]string{"--name=testuser", "--vpngateway=vpng-abcdef12", "--username=user1", "--password=pass123"}) + + service.EXPECT().CreateVPNGatewayUser(gomock.Any()).Return(ecloud.TaskReference{}, errors.New("test error")).Times(1) + + err := ecloudVPNGatewayUserCreate(service, cmd, []string{}) + + assert.Equal(t, "Error creating VPN gateway user: test error", err.Error()) + }) + + t.Run("GetVPNGatewayUserError_ReturnsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + cmd := ecloudVPNGatewayUserCreateCmd(nil) + cmd.ParseFlags([]string{"--name=testuser", "--vpngateway=vpng-abcdef12", "--username=user1", "--password=pass123"}) + + gomock.InOrder( + service.EXPECT().CreateVPNGatewayUser(gomock.Any()).Return(ecloud.TaskReference{ResourceID: "vpngu-abcdef12"}, nil), + service.EXPECT().GetVPNGatewayUser("vpngu-abcdef12").Return(ecloud.VPNGatewayUser{}, errors.New("test error")), + ) + + err := ecloudVPNGatewayUserCreate(service, cmd, []string{}) + + assert.Equal(t, "Error retrieving new VPN gateway user: test error", err.Error()) + }) +} + +func Test_ecloudVPNGatewayUserUpdateCmd_Args(t *testing.T) { + t.Run("ValidArgs_NoError", func(t *testing.T) { + err := ecloudVPNGatewayUserUpdateCmd(nil).Args(nil, []string{"vpngu-abcdef12"}) + + assert.Nil(t, err) + }) + + t.Run("InvalidArgs_Error", func(t *testing.T) { + err := ecloudVPNGatewayUserUpdateCmd(nil).Args(nil, []string{}) + + assert.NotNil(t, err) + assert.Equal(t, "Missing VPN gateway user", err.Error()) + }) +} + +func Test_ecloudVPNGatewayUserUpdate(t *testing.T) { + t.Run("SingleUser", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + cmd := ecloudVPNGatewayUserUpdateCmd(nil) + cmd.ParseFlags([]string{"--name=testuser", "--username=user1"}) + + req := ecloud.PatchVPNGatewayUserRequest{ + Name: "testuser", + Username: "user1", + } + + resp := ecloud.TaskReference{ + TaskID: "task-abcdef12", + ResourceID: "vpngu-abcdef12", + } + + gomock.InOrder( + service.EXPECT().PatchVPNGatewayUser("vpngu-abcdef12", req).Return(resp, nil), + service.EXPECT().GetVPNGatewayUser("vpngu-abcdef12").Return(ecloud.VPNGatewayUser{}, nil), + ) + + ecloudVPNGatewayUserUpdate(service, cmd, []string{"vpngu-abcdef12"}) + }) + + t.Run("WithWaitFlag_NoError_Succeeds", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + cmd := ecloudVPNGatewayUserUpdateCmd(nil) + cmd.ParseFlags([]string{"--name=testuser", "--wait"}) + + req := ecloud.PatchVPNGatewayUserRequest{ + Name: "testuser", + } + + resp := ecloud.TaskReference{ + TaskID: "task-abcdef12", + ResourceID: "vpngu-abcdef12", + } + + gomock.InOrder( + service.EXPECT().PatchVPNGatewayUser("vpngu-abcdef12", req).Return(resp, nil), + service.EXPECT().GetTask("task-abcdef12").Return(ecloud.Task{Status: ecloud.TaskStatusComplete}, nil), + service.EXPECT().GetVPNGatewayUser("vpngu-abcdef12").Return(ecloud.VPNGatewayUser{}, nil), + ) + + ecloudVPNGatewayUserUpdate(service, cmd, []string{"vpngu-abcdef12"}) + }) + + t.Run("WithWaitFlag_GetTaskError_OutputsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + cmd := ecloudVPNGatewayUserUpdateCmd(nil) + cmd.ParseFlags([]string{"--name=testuser", "--wait"}) + + req := ecloud.PatchVPNGatewayUserRequest{ + Name: "testuser", + } + + resp := ecloud.TaskReference{ + TaskID: "task-abcdef12", + ResourceID: "vpngu-abcdef12", + } + + gomock.InOrder( + service.EXPECT().PatchVPNGatewayUser("vpngu-abcdef12", req).Return(resp, nil), + service.EXPECT().GetTask("task-abcdef12").Return(ecloud.Task{Status: ecloud.TaskStatusComplete}, errors.New("test error")), + ) + + test_output.AssertErrorOutput(t, "Error waiting for task to complete for VPN gateway user [vpngu-abcdef12]: Error waiting for command: Failed to retrieve task status: test error\n", func() { + ecloudVPNGatewayUserUpdate(service, cmd, []string{"vpngu-abcdef12"}) + }) + }) + + t.Run("PatchVPNGatewayUserError_OutputsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().PatchVPNGatewayUser("vpngu-abcdef12", gomock.Any()).Return(ecloud.TaskReference{}, errors.New("test error")) + + test_output.AssertErrorOutput(t, "Error updating VPN gateway user [vpngu-abcdef12]: test error\n", func() { + ecloudVPNGatewayUserUpdate(service, &cobra.Command{}, []string{"vpngu-abcdef12"}) + }) + }) + + t.Run("GetVPNGatewayUserError_OutputsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + resp := ecloud.TaskReference{ + TaskID: "task-abcdef12", + ResourceID: "vpngu-abcdef12", + } + + gomock.InOrder( + service.EXPECT().PatchVPNGatewayUser("vpngu-abcdef12", gomock.Any()).Return(resp, nil), + service.EXPECT().GetVPNGatewayUser("vpngu-abcdef12").Return(ecloud.VPNGatewayUser{}, errors.New("test error")), + ) + + test_output.AssertErrorOutput(t, "Error retrieving updated VPN gateway user [vpngu-abcdef12]: test error\n", func() { + ecloudVPNGatewayUserUpdate(service, &cobra.Command{}, []string{"vpngu-abcdef12"}) + }) + }) +} + +func Test_ecloudVPNGatewayUserDeleteCmd_Args(t *testing.T) { + t.Run("ValidArgs_NoError", func(t *testing.T) { + err := ecloudVPNGatewayUserDeleteCmd(nil).Args(nil, []string{"vpngu-abcdef12"}) + + assert.Nil(t, err) + }) + + t.Run("InvalidArgs_Error", func(t *testing.T) { + err := ecloudVPNGatewayUserDeleteCmd(nil).Args(nil, []string{}) + + assert.NotNil(t, err) + assert.Equal(t, "Missing VPN gateway user", err.Error()) + }) +} + +func Test_ecloudVPNGatewayUserDelete(t *testing.T) { + t.Run("SingleUser", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().DeleteVPNGatewayUser("vpngu-abcdef12").Return("task-abcdef12", nil) + + ecloudVPNGatewayUserDelete(service, &cobra.Command{}, []string{"vpngu-abcdef12"}) + }) + + t.Run("WithWaitFlag_NoError_Succeeds", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + cmd := ecloudVPNGatewayUserDeleteCmd(nil) + cmd.ParseFlags([]string{"--wait"}) + + service := mocks.NewMockECloudService(mockCtrl) + + gomock.InOrder( + service.EXPECT().DeleteVPNGatewayUser("vpngu-abcdef12").Return("task-abcdef12", nil), + service.EXPECT().GetTask("task-abcdef12").Return(ecloud.Task{Status: ecloud.TaskStatusComplete}, nil), + ) + + ecloudVPNGatewayUserDelete(service, cmd, []string{"vpngu-abcdef12"}) + }) + + t.Run("WithWaitFlag_GetTaskError_OutputsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + cmd := ecloudVPNGatewayUserDeleteCmd(nil) + cmd.ParseFlags([]string{"--wait"}) + + gomock.InOrder( + service.EXPECT().DeleteVPNGatewayUser("vpngu-abcdef12").Return("task-abcdef12", nil), + service.EXPECT().GetTask("task-abcdef12").Return(ecloud.Task{Status: ecloud.TaskStatusComplete}, errors.New("test error")), + ) + + test_output.AssertErrorOutput(t, "Error waiting for task to complete for VPN gateway user [vpngu-abcdef12]: Error waiting for command: Failed to retrieve task status: test error\n", func() { + ecloudVPNGatewayUserDelete(service, cmd, []string{"vpngu-abcdef12"}) + }) + }) + + t.Run("DeleteVPNGatewayUserError_OutputsError", func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + service := mocks.NewMockECloudService(mockCtrl) + + service.EXPECT().DeleteVPNGatewayUser("vpngu-abcdef12").Return("", errors.New("test error")).Times(1) + + test_output.AssertErrorOutput(t, "Error removing VPN gateway user [vpngu-abcdef12]: test error\n", func() { + ecloudVPNGatewayUserDelete(service, &cobra.Command{}, []string{"vpngu-abcdef12"}) + }) + }) +} diff --git a/cmd/ecloud/output.go b/cmd/ecloud/output.go index 4d51d1b..d67d2ab 100644 --- a/cmd/ecloud/output.go +++ b/cmd/ecloud/output.go @@ -483,3 +483,15 @@ func OutputECloudNATOverloadRulesProvider(rules []ecloud.NATOverloadRule) output func OutputECloudIOPSTierProvider(tiers []ecloud.IOPSTier) output.OutputHandlerDataProvider { return output.NewSerializedOutputHandlerDataProvider(tiers).WithDefaultFields([]string{"id", "name", "level"}) } + +func OutputECloudVPNGatewaysProvider(gateways []ecloud.VPNGateway) output.OutputHandlerDataProvider { + return output.NewSerializedOutputHandlerDataProvider(gateways).WithDefaultFields([]string{"id", "name", "router_id", "specification_id", "sync_status"}) +} + +func OutputECloudVPNGatewaySpecificationsProvider(specs []ecloud.VPNGatewaySpecification) output.OutputHandlerDataProvider { + return output.NewSerializedOutputHandlerDataProvider(specs).WithDefaultFields([]string{"id", "name", "description"}) +} + +func OutputECloudVPNGatewayUsersProvider(users []ecloud.VPNGatewayUser) output.OutputHandlerDataProvider { + return output.NewSerializedOutputHandlerDataProvider(users).WithDefaultFields([]string{"id", "name", "username", "vpn_gateway_id", "sync_status"}) +} diff --git a/go.mod b/go.mod index 5915d68..618dc45 100644 --- a/go.mod +++ b/go.mod @@ -2,10 +2,10 @@ module github.com/ans-group/cli go 1.22.0 -toolchain go1.22.7 +toolchain go1.23.2 require ( - github.com/ans-group/sdk-go v1.20.4 + github.com/ans-group/sdk-go v1.21.0 github.com/blang/semver v3.5.1+incompatible github.com/golang/mock v1.6.0 github.com/iancoleman/strcase v0.3.0 @@ -18,45 +18,44 @@ require ( github.com/stretchr/testify v1.9.0 gopkg.in/go-playground/assert.v1 v1.2.1 gopkg.in/yaml.v3 v3.0.1 - k8s.io/client-go v0.31.1 + k8s.io/client-go v0.31.2 ) require ( github.com/ans-group/go-durationstring v1.2.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/fsnotify/fsnotify v1.6.0 // indirect - github.com/go-playground/locales v0.12.1 // indirect - github.com/go-playground/universal-translator v0.16.0 // indirect + github.com/fsnotify/fsnotify v1.8.0 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect github.com/google/go-github/v30 v30.1.0 // indirect github.com/google/go-querystring v1.0.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/leodido/go-urn v1.1.0 // indirect + github.com/leodido/go-urn v1.4.0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/pelletier/go-toml/v2 v2.1.0 // indirect + github.com/pelletier/go-toml/v2 v2.2.3 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/rivo/uniseg v0.4.7 // indirect - github.com/sagikazarmark/locafero v0.3.0 // indirect + github.com/sagikazarmark/locafero v0.6.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect - github.com/spf13/cast v1.5.1 // indirect + github.com/spf13/cast v1.7.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/spf13/viper v1.17.0 // indirect + github.com/spf13/viper v1.19.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/tcnksm/go-gitconfig v0.1.2 // indirect github.com/ulikunitz/xz v0.5.9 // indirect - go.uber.org/atomic v1.9.0 // indirect - go.uber.org/multierr v1.9.0 // indirect + go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.24.0 // indirect - golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect + golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect golang.org/x/oauth2 v0.21.0 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/text v0.19.0 // indirect - gopkg.in/go-playground/validator.v9 v9.27.0 // indirect + golang.org/x/sys v0.27.0 // indirect + golang.org/x/text v0.20.0 // indirect + gopkg.in/go-playground/validator.v9 v9.31.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) diff --git a/go.sum b/go.sum index 1155828..9d659be 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/ans-group/go-durationstring v1.2.0 h1:UJIuQATkp0t1rBvZsHRwki33YHV9E+Ulro+3NbMB7MM= github.com/ans-group/go-durationstring v1.2.0/go.mod h1:QGF9Mdpq9058QXaut8r55QWu6lcHX6i/GvF1PZVkV6o= -github.com/ans-group/sdk-go v1.20.4 h1:Jw5ZvVfIfm/zyRr68X/uJ3j3xOPnBJfq/jT11WYSLOQ= -github.com/ans-group/sdk-go v1.20.4/go.mod h1:w4tX8raa9y3j7pug6TLcF8ZW1j9G05AmNoQLBloYxEY= +github.com/ans-group/sdk-go v1.21.0 h1:ORTzq0c+/x9wgzBsyMdm6jujLFho4ipMtzLqdutQc0s= +github.com/ans-group/sdk-go v1.21.0/go.mod h1:Dx34ZUbyHNniHAKsDy/vp8q8hQC5L51ub2sv9We7d8E= github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -9,15 +9,15 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= -github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/go-playground/locales v0.12.1 h1:2FITxuFt/xuCNP1Acdhv62OzaCiviiE4kotfhkmOqEc= -github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= -github.com/go-playground/universal-translator v0.16.0 h1:X++omBR/4cE2MNg91AoC3rmGrCjJ8eAeUP/K/EKx4DM= -github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= +github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= +github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -44,8 +44,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.1.0 h1:Sm1gr51B1kKyfD2BlRcLSiEkffoG96g6TPv6eRoEiB8= -github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= +github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= +github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= @@ -60,8 +60,8 @@ github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.2 h1:3mYCb7aPxS/RU7TI1y4rkEn1oKmPRjNJLNEXgw7MH2I= github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= -github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= +github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= +github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -77,29 +77,24 @@ github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/f github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/sagikazarmark/locafero v0.3.0 h1:zT7VEGWC2DTflmccN/5T1etyKvxSxpHsjb9cJvm4SvQ= -github.com/sagikazarmark/locafero v0.3.0/go.mod h1:w+v7UsPNFwzF1cHuOajOOzoq4U7v/ig1mpRjqV+Bu1U= +github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk= +github.com/sagikazarmark/locafero v0.6.0/go.mod h1:77OmuIc6VTraTXKXIs/uvUxKGUXjE1GbemJYHqdNjX0= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= -github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= -github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= +github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w= +github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.17.0 h1:I5txKw7MJasPL/BrfkbA0Jyo/oELqVmux4pR/UxOMfI= -github.com/spf13/viper v1.17.0/go.mod h1:BmMMMLQXSbcHK6KAOiFLz0l5JHrU89OdIRHvsk0+yVI= +github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= +github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= @@ -109,17 +104,15 @@ github.com/tcnksm/go-gitconfig v0.1.2/go.mod h1:/8EhP4H7oJZdIPyT+/UIsG87kTzrzM4U github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I= github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= -go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= -go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= +golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY= +golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -143,17 +136,16 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= -golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= @@ -169,16 +161,15 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v9 v9.27.0 h1:wCg/0hk9RzcB0CYw8pYV6FiBYug1on0cpco9YZF8jqA= -gopkg.in/go-playground/validator.v9 v9.27.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= +gopkg.in/go-playground/validator.v9 v9.31.0 h1:bmXmP2RSNtFES+bn4uYuHT7iJFJv7Vj+an+ZQdDaD1M= +gopkg.in/go-playground/validator.v9 v9.31.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/client-go v0.31.1 h1:f0ugtWSbWpxHR7sjVpQwuvw9a3ZKLXX0u0itkFXufb0= -k8s.io/client-go v0.31.1/go.mod h1:sKI8871MJN2OyeqRlmA4W4KM9KBdBUpDLu/43eGemCg= +k8s.io/client-go v0.31.2 h1:Y2F4dxU5d3AQj+ybwSMqQnpZH9F30//1ObxOKlTI9yc= +k8s.io/client-go v0.31.2/go.mod h1:NPa74jSVR/+eez2dFsEIHNa+3o09vtNaWwWwb1qSxSs= diff --git a/test/mocks/mock_ecloudservice.go b/test/mocks/mock_ecloudservice.go index 368bd1d..b7ea92e 100644 --- a/test/mocks/mock_ecloudservice.go +++ b/test/mocks/mock_ecloudservice.go @@ -5,11 +5,11 @@ package mocks import ( - gomock "github.com/golang/mock/gomock" - reflect "reflect" connection "github.com/ans-group/sdk-go/pkg/connection" account "github.com/ans-group/sdk-go/pkg/service/account" ecloud "github.com/ans-group/sdk-go/pkg/service/ecloud" + gomock "github.com/golang/mock/gomock" + reflect "reflect" ) // MockECloudService is a mock of ECloudService interface. @@ -454,6 +454,36 @@ func (mr *MockECloudServiceMockRecorder) CreateVPNEndpoint(arg0 interface{}) *go return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateVPNEndpoint", reflect.TypeOf((*MockECloudService)(nil).CreateVPNEndpoint), arg0) } +// CreateVPNGateway mocks base method. +func (m *MockECloudService) CreateVPNGateway(arg0 ecloud.CreateVPNGatewayRequest) (ecloud.TaskReference, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateVPNGateway", arg0) + ret0, _ := ret[0].(ecloud.TaskReference) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateVPNGateway indicates an expected call of CreateVPNGateway. +func (mr *MockECloudServiceMockRecorder) CreateVPNGateway(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateVPNGateway", reflect.TypeOf((*MockECloudService)(nil).CreateVPNGateway), arg0) +} + +// CreateVPNGatewayUser mocks base method. +func (m *MockECloudService) CreateVPNGatewayUser(arg0 ecloud.CreateVPNGatewayUserRequest) (ecloud.TaskReference, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateVPNGatewayUser", arg0) + ret0, _ := ret[0].(ecloud.TaskReference) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateVPNGatewayUser indicates an expected call of CreateVPNGatewayUser. +func (mr *MockECloudServiceMockRecorder) CreateVPNGatewayUser(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateVPNGatewayUser", reflect.TypeOf((*MockECloudService)(nil).CreateVPNGatewayUser), arg0) +} + // CreateVPNService mocks base method. func (m *MockECloudService) CreateVPNService(arg0 ecloud.CreateVPNServiceRequest) (ecloud.TaskReference, error) { m.ctrl.T.Helper() @@ -954,6 +984,36 @@ func (mr *MockECloudServiceMockRecorder) DeleteVPNEndpoint(arg0 interface{}) *go return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteVPNEndpoint", reflect.TypeOf((*MockECloudService)(nil).DeleteVPNEndpoint), arg0) } +// DeleteVPNGateway mocks base method. +func (m *MockECloudService) DeleteVPNGateway(arg0 string) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteVPNGateway", arg0) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DeleteVPNGateway indicates an expected call of DeleteVPNGateway. +func (mr *MockECloudServiceMockRecorder) DeleteVPNGateway(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteVPNGateway", reflect.TypeOf((*MockECloudService)(nil).DeleteVPNGateway), arg0) +} + +// DeleteVPNGatewayUser mocks base method. +func (m *MockECloudService) DeleteVPNGatewayUser(arg0 string) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteVPNGatewayUser", arg0) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DeleteVPNGatewayUser indicates an expected call of DeleteVPNGatewayUser. +func (mr *MockECloudServiceMockRecorder) DeleteVPNGatewayUser(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteVPNGatewayUser", reflect.TypeOf((*MockECloudService)(nil).DeleteVPNGatewayUser), arg0) +} + // DeleteVPNService mocks base method. func (m *MockECloudService) DeleteVPNService(arg0 string) (string, error) { m.ctrl.T.Helper() @@ -1100,6 +1160,21 @@ func (mr *MockECloudServiceMockRecorder) EncryptInstance(arg0 interface{}) *gomo return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EncryptInstance", reflect.TypeOf((*MockECloudService)(nil).EncryptInstance), arg0) } +// ExecuteInstanceScript mocks base method. +func (m *MockECloudService) ExecuteInstanceScript(arg0 string, arg1 ecloud.ExecuteInstanceScriptRequest) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ExecuteInstanceScript", arg0, arg1) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ExecuteInstanceScript indicates an expected call of ExecuteInstanceScript. +func (mr *MockECloudServiceMockRecorder) ExecuteInstanceScript(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExecuteInstanceScript", reflect.TypeOf((*MockECloudService)(nil).ExecuteInstanceScript), arg0, arg1) +} + // GetActiveDirectoryDomain mocks base method. func (m *MockECloudService) GetActiveDirectoryDomain(arg0 int) (ecloud.ActiveDirectoryDomain, error) { m.ctrl.T.Helper() @@ -4220,6 +4295,201 @@ func (mr *MockECloudServiceMockRecorder) GetVPNEndpointsPaginated(arg0 interface return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVPNEndpointsPaginated", reflect.TypeOf((*MockECloudService)(nil).GetVPNEndpointsPaginated), arg0) } +// GetVPNGateway mocks base method. +func (m *MockECloudService) GetVPNGateway(arg0 string) (ecloud.VPNGateway, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetVPNGateway", arg0) + ret0, _ := ret[0].(ecloud.VPNGateway) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetVPNGateway indicates an expected call of GetVPNGateway. +func (mr *MockECloudServiceMockRecorder) GetVPNGateway(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVPNGateway", reflect.TypeOf((*MockECloudService)(nil).GetVPNGateway), arg0) +} + +// GetVPNGatewaySpecification mocks base method. +func (m *MockECloudService) GetVPNGatewaySpecification(arg0 string) (ecloud.VPNGatewaySpecification, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetVPNGatewaySpecification", arg0) + ret0, _ := ret[0].(ecloud.VPNGatewaySpecification) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetVPNGatewaySpecification indicates an expected call of GetVPNGatewaySpecification. +func (mr *MockECloudServiceMockRecorder) GetVPNGatewaySpecification(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVPNGatewaySpecification", reflect.TypeOf((*MockECloudService)(nil).GetVPNGatewaySpecification), arg0) +} + +// GetVPNGatewaySpecificationAvailabilityZones mocks base method. +func (m *MockECloudService) GetVPNGatewaySpecificationAvailabilityZones(arg0 string, arg1 connection.APIRequestParameters) ([]ecloud.AvailabilityZone, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetVPNGatewaySpecificationAvailabilityZones", arg0, arg1) + ret0, _ := ret[0].([]ecloud.AvailabilityZone) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetVPNGatewaySpecificationAvailabilityZones indicates an expected call of GetVPNGatewaySpecificationAvailabilityZones. +func (mr *MockECloudServiceMockRecorder) GetVPNGatewaySpecificationAvailabilityZones(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVPNGatewaySpecificationAvailabilityZones", reflect.TypeOf((*MockECloudService)(nil).GetVPNGatewaySpecificationAvailabilityZones), arg0, arg1) +} + +// GetVPNGatewaySpecificationAvailabilityZonesPaginated mocks base method. +func (m *MockECloudService) GetVPNGatewaySpecificationAvailabilityZonesPaginated(arg0 string, arg1 connection.APIRequestParameters) (*connection.Paginated[ecloud.AvailabilityZone], error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetVPNGatewaySpecificationAvailabilityZonesPaginated", arg0, arg1) + ret0, _ := ret[0].(*connection.Paginated[ecloud.AvailabilityZone]) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetVPNGatewaySpecificationAvailabilityZonesPaginated indicates an expected call of GetVPNGatewaySpecificationAvailabilityZonesPaginated. +func (mr *MockECloudServiceMockRecorder) GetVPNGatewaySpecificationAvailabilityZonesPaginated(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVPNGatewaySpecificationAvailabilityZonesPaginated", reflect.TypeOf((*MockECloudService)(nil).GetVPNGatewaySpecificationAvailabilityZonesPaginated), arg0, arg1) +} + +// GetVPNGatewaySpecifications mocks base method. +func (m *MockECloudService) GetVPNGatewaySpecifications(arg0 connection.APIRequestParameters) ([]ecloud.VPNGatewaySpecification, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetVPNGatewaySpecifications", arg0) + ret0, _ := ret[0].([]ecloud.VPNGatewaySpecification) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetVPNGatewaySpecifications indicates an expected call of GetVPNGatewaySpecifications. +func (mr *MockECloudServiceMockRecorder) GetVPNGatewaySpecifications(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVPNGatewaySpecifications", reflect.TypeOf((*MockECloudService)(nil).GetVPNGatewaySpecifications), arg0) +} + +// GetVPNGatewaySpecificationsPaginated mocks base method. +func (m *MockECloudService) GetVPNGatewaySpecificationsPaginated(arg0 connection.APIRequestParameters) (*connection.Paginated[ecloud.VPNGatewaySpecification], error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetVPNGatewaySpecificationsPaginated", arg0) + ret0, _ := ret[0].(*connection.Paginated[ecloud.VPNGatewaySpecification]) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetVPNGatewaySpecificationsPaginated indicates an expected call of GetVPNGatewaySpecificationsPaginated. +func (mr *MockECloudServiceMockRecorder) GetVPNGatewaySpecificationsPaginated(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVPNGatewaySpecificationsPaginated", reflect.TypeOf((*MockECloudService)(nil).GetVPNGatewaySpecificationsPaginated), arg0) +} + +// GetVPNGatewayTasks mocks base method. +func (m *MockECloudService) GetVPNGatewayTasks(arg0 string, arg1 connection.APIRequestParameters) ([]ecloud.Task, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetVPNGatewayTasks", arg0, arg1) + ret0, _ := ret[0].([]ecloud.Task) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetVPNGatewayTasks indicates an expected call of GetVPNGatewayTasks. +func (mr *MockECloudServiceMockRecorder) GetVPNGatewayTasks(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVPNGatewayTasks", reflect.TypeOf((*MockECloudService)(nil).GetVPNGatewayTasks), arg0, arg1) +} + +// GetVPNGatewayTasksPaginated mocks base method. +func (m *MockECloudService) GetVPNGatewayTasksPaginated(arg0 string, arg1 connection.APIRequestParameters) (*connection.Paginated[ecloud.Task], error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetVPNGatewayTasksPaginated", arg0, arg1) + ret0, _ := ret[0].(*connection.Paginated[ecloud.Task]) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetVPNGatewayTasksPaginated indicates an expected call of GetVPNGatewayTasksPaginated. +func (mr *MockECloudServiceMockRecorder) GetVPNGatewayTasksPaginated(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVPNGatewayTasksPaginated", reflect.TypeOf((*MockECloudService)(nil).GetVPNGatewayTasksPaginated), arg0, arg1) +} + +// GetVPNGatewayUser mocks base method. +func (m *MockECloudService) GetVPNGatewayUser(arg0 string) (ecloud.VPNGatewayUser, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetVPNGatewayUser", arg0) + ret0, _ := ret[0].(ecloud.VPNGatewayUser) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetVPNGatewayUser indicates an expected call of GetVPNGatewayUser. +func (mr *MockECloudServiceMockRecorder) GetVPNGatewayUser(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVPNGatewayUser", reflect.TypeOf((*MockECloudService)(nil).GetVPNGatewayUser), arg0) +} + +// GetVPNGatewayUsers mocks base method. +func (m *MockECloudService) GetVPNGatewayUsers(arg0 connection.APIRequestParameters) ([]ecloud.VPNGatewayUser, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetVPNGatewayUsers", arg0) + ret0, _ := ret[0].([]ecloud.VPNGatewayUser) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetVPNGatewayUsers indicates an expected call of GetVPNGatewayUsers. +func (mr *MockECloudServiceMockRecorder) GetVPNGatewayUsers(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVPNGatewayUsers", reflect.TypeOf((*MockECloudService)(nil).GetVPNGatewayUsers), arg0) +} + +// GetVPNGatewayUsersPaginated mocks base method. +func (m *MockECloudService) GetVPNGatewayUsersPaginated(arg0 connection.APIRequestParameters) (*connection.Paginated[ecloud.VPNGatewayUser], error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetVPNGatewayUsersPaginated", arg0) + ret0, _ := ret[0].(*connection.Paginated[ecloud.VPNGatewayUser]) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetVPNGatewayUsersPaginated indicates an expected call of GetVPNGatewayUsersPaginated. +func (mr *MockECloudServiceMockRecorder) GetVPNGatewayUsersPaginated(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVPNGatewayUsersPaginated", reflect.TypeOf((*MockECloudService)(nil).GetVPNGatewayUsersPaginated), arg0) +} + +// GetVPNGateways mocks base method. +func (m *MockECloudService) GetVPNGateways(arg0 connection.APIRequestParameters) ([]ecloud.VPNGateway, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetVPNGateways", arg0) + ret0, _ := ret[0].([]ecloud.VPNGateway) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetVPNGateways indicates an expected call of GetVPNGateways. +func (mr *MockECloudServiceMockRecorder) GetVPNGateways(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVPNGateways", reflect.TypeOf((*MockECloudService)(nil).GetVPNGateways), arg0) +} + +// GetVPNGatewaysPaginated mocks base method. +func (m *MockECloudService) GetVPNGatewaysPaginated(arg0 connection.APIRequestParameters) (*connection.Paginated[ecloud.VPNGateway], error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetVPNGatewaysPaginated", arg0) + ret0, _ := ret[0].(*connection.Paginated[ecloud.VPNGateway]) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetVPNGatewaysPaginated indicates an expected call of GetVPNGatewaysPaginated. +func (mr *MockECloudServiceMockRecorder) GetVPNGatewaysPaginated(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVPNGatewaysPaginated", reflect.TypeOf((*MockECloudService)(nil).GetVPNGatewaysPaginated), arg0) +} + // GetVPNProfileGroup mocks base method. func (m *MockECloudService) GetVPNProfileGroup(arg0 string) (ecloud.VPNProfileGroup, error) { m.ctrl.T.Helper() @@ -4993,6 +5263,36 @@ func (mr *MockECloudServiceMockRecorder) PatchVPNEndpoint(arg0, arg1 interface{} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchVPNEndpoint", reflect.TypeOf((*MockECloudService)(nil).PatchVPNEndpoint), arg0, arg1) } +// PatchVPNGateway mocks base method. +func (m *MockECloudService) PatchVPNGateway(arg0 string, arg1 ecloud.PatchVPNGatewayRequest) (ecloud.TaskReference, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PatchVPNGateway", arg0, arg1) + ret0, _ := ret[0].(ecloud.TaskReference) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PatchVPNGateway indicates an expected call of PatchVPNGateway. +func (mr *MockECloudServiceMockRecorder) PatchVPNGateway(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchVPNGateway", reflect.TypeOf((*MockECloudService)(nil).PatchVPNGateway), arg0, arg1) +} + +// PatchVPNGatewayUser mocks base method. +func (m *MockECloudService) PatchVPNGatewayUser(arg0 string, arg1 ecloud.PatchVPNGatewayUserRequest) (ecloud.TaskReference, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PatchVPNGatewayUser", arg0, arg1) + ret0, _ := ret[0].(ecloud.TaskReference) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PatchVPNGatewayUser indicates an expected call of PatchVPNGatewayUser. +func (mr *MockECloudServiceMockRecorder) PatchVPNGatewayUser(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchVPNGatewayUser", reflect.TypeOf((*MockECloudService)(nil).PatchVPNGatewayUser), arg0, arg1) +} + // PatchVPNService mocks base method. func (m *MockECloudService) PatchVPNService(arg0 string, arg1 ecloud.PatchVPNServiceRequest) (ecloud.TaskReference, error) { m.ctrl.T.Helper()