Skip to content

Commit 2ce2f55

Browse files
Merge pull request #1910 from BrianSantivanez/issue1908
New Command: `slcli user vpn-password`
2 parents ea9ca00 + 7e2597f commit 2ce2f55

File tree

7 files changed

+54
-0
lines changed

7 files changed

+54
-0
lines changed

SoftLayer/CLI/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@
388388
('user:vpn-subnet', 'SoftLayer.CLI.user.vpn_subnet:cli'),
389389
('user:remove-access', 'SoftLayer.CLI.user.remove_access:cli'),
390390
('user:grant-access', 'SoftLayer.CLI.user.grant_access:cli'),
391+
('user:vpn-password', 'SoftLayer.CLI.user.vpn_password:cli'),
391392

392393
('vlan', 'SoftLayer.CLI.vlan'),
393394
('vlan:create', 'SoftLayer.CLI.vlan.create:cli'),

SoftLayer/CLI/user/vpn_password.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""Set the user VPN password."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
import SoftLayer
6+
7+
from SoftLayer.CLI.command import SLCommand as SLCommand
8+
from SoftLayer.CLI import environment
9+
from SoftLayer.CLI import helpers
10+
11+
12+
@click.command(cls=SLCommand, )
13+
@click.argument('identifier')
14+
@click.option('--password', required=True, help="Your new VPN password")
15+
@environment.pass_env
16+
def cli(env, identifier, password):
17+
"""Set the user VPN password.
18+
19+
Example: slcli user vpn-password 123456 --password=Mypassword1.
20+
"""
21+
22+
mgr = SoftLayer.UserManager(env.client)
23+
user_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'username')
24+
result = mgr.update_vpn_password(user_id, password)
25+
if result:
26+
click.secho("Successfully updated user VPN password.", fg='green')

SoftLayer/fixtures/SoftLayer_User_Customer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
addDedicatedHostAccess = True
9393
addHardwareAccess = True
9494
addVirtualGuestAccess = True
95+
updateVpnPassword = True
9596

9697
getHardware = [{
9798
"domain": "testedit.com",

SoftLayer/managers/user.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,16 @@ def get_user_virtuals(self, user_id):
476476
"""
477477
return self.user_service.getVirtualGuests(id=user_id)
478478

479+
def update_vpn_password(self, user_id, password):
480+
"""Update a user's VPN password.
481+
482+
:param int user_id:
483+
:param string password:
484+
485+
:returns: true
486+
"""
487+
return self.user_service.updateVpnPassword(password, id=user_id)
488+
479489

480490
def _keyname_search(haystack, needle):
481491
for item in haystack:

docs/cli/users.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,7 @@ Version 5.6.0 introduces the ability to interact with user accounts from the cli
6060
:prog: user grant-access
6161
:show-nested:
6262

63+
.. click:: SoftLayer.CLI.user.vpn_password:cli
64+
:prog: user vpn-password
65+
:show-nested:
6366

tests/CLI/modules/user_tests.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,12 @@ def test_remove_without_device(self):
378378
result = self.run_command(['user', 'remove-access', '123456'])
379379
self.assertEqual(2, result.exit_code)
380380
self.assertIn('A device option is required.', result.exception.message)
381+
382+
def test_update_vpn_password(self):
383+
result = self.run_command(['user', 'vpn-password', '123456', '--password', 'Mypassword1.'])
384+
self.assert_no_fail(result)
385+
386+
def test_remove_without_password(self):
387+
result = self.run_command(['user', 'vpn-password', '123456'])
388+
self.assertEqual(2, result.exit_code)
389+
self.assertIn("Missing option '--password'", result.output)

tests/managers/user_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,7 @@ def test_remove_virtual(self):
330330
def test_remove_dedicated(self):
331331
self.manager.remove_dedicated_access(123456, 369852)
332332
self.assert_called_with('SoftLayer_User_Customer', 'removeDedicatedHostAccess')
333+
334+
def test_update_vpn_password(self):
335+
self.manager.update_vpn_password(123456, "Mypassword1.")
336+
self.assert_called_with('SoftLayer_User_Customer', 'updateVpnPassword')

0 commit comments

Comments
 (0)