Skip to content

Commit 54c1c56

Browse files
Ramkishor ChaladiRamkishor Chaladi
authored andcommitted
updated
1 parent 252e6b9 commit 54c1c56

2 files changed

Lines changed: 1 addition & 52 deletions

File tree

plugin/commands/user/vpn_enable.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,34 +39,19 @@ func NewVpnEnableCommand(sl *metadata.SoftlayerCommand) (cmd *VpnEnableCommand)
3939
}
4040

4141
func (cmd *VpnEnableCommand) Run(args []string) error {
42-
4342
userID, err := strconv.Atoi(args[0])
4443
if err != nil {
4544
return slErrors.NewInvalidSoftlayerIdInputError("User ID")
4645
}
47-
4846
userTemplate := datatypes.User_Customer{
4947
SslVpnAllowedFlag: sl.Bool(true),
5048
}
51-
52-
subs := map[string]interface{}{"UserId": userID}
53-
confirm, err := cmd.UI.Confirm(T("This will Enable vpn for the user id: {{.UserId}}. Continue?", subs))
54-
if err != nil {
55-
return err
56-
}
57-
if !confirm {
58-
cmd.UI.Print(T("Aborted."))
59-
return nil
60-
}
61-
6249
success, err := cmd.UserManager.EditUser(userTemplate, userID)
6350
if err != nil {
64-
return slErrors.NewAPIError(T("Failed to enable vpn for the 'User ID' \n", subs), err.Error(), 2)
51+
return slErrors.NewAPIError(T("Error: "), err.Error(), 2)
6552
}
66-
6753
if success {
6854
cmd.UI.Ok()
69-
cmd.UI.Print(T("{{.UserId}} is successfully enabled.", subs))
7055
}
7156
return nil
7257
}
Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package user_test
22

33
import (
4-
"errors"
5-
64
"github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal"
75
. "github.com/onsi/ginkgo"
86
. "github.com/onsi/gomega"
@@ -46,39 +44,5 @@ var _ = Describe("user vpn-enable", func() {
4644
Expect(err.Error()).To(ContainSubstring("Invalid input for 'User ID'. It must be a positive integer."))
4745
})
4846
})
49-
50-
Context("Vpn enable with correct vpn ID but continue", func() {
51-
It("return no error", func() {
52-
fakeUI.Inputs("No")
53-
err := testhelpers.RunCobraCommand(cliCommand.Command, "1234")
54-
Expect(err).NotTo(HaveOccurred())
55-
Expect(fakeUI.Outputs()).To(ContainSubstring("This will Enable vpn for the user id: 1234. Continue?"))
56-
Expect(fakeUI.Outputs()).To(ContainSubstring("Aborted."))
57-
})
58-
})
59-
60-
Context("Return error", func() {
61-
BeforeEach(func() {
62-
fakeUserManager.EditUserReturns(false, errors.New("Failed"))
63-
})
64-
It("Failed edit user", func() {
65-
err := testhelpers.RunCobraCommand(cliCommand.Command, "111111")
66-
Expect(err).To(HaveOccurred())
67-
Expect(err.Error()).To(ContainSubstring("Failed to enable vpn for the 'User ID' "))
68-
Expect(err.Error()).To(ContainSubstring("SoftLayer_Exception_ObjectNotFound: Unable to find object with id of '123'. (HTTP 404)"))
69-
})
70-
})
71-
72-
Context("Return no error", func() {
73-
BeforeEach(func() {
74-
fakeUserManager.EditUserReturns(true, nil)
75-
})
76-
It("vpn enable", func() {
77-
err := testhelpers.RunCobraCommand(cliCommand.Command, "111111")
78-
Expect(err).NotTo(HaveOccurred())
79-
Expect(fakeUI.Outputs()).To(ContainSubstring("OK"))
80-
Expect(fakeUI.Outputs()).To(ContainSubstring("1234 is successfully enabled."))
81-
})
82-
})
8347
})
8448
})

0 commit comments

Comments
 (0)