Skip to content

Commit 0190093

Browse files
Merge pull request #1011 from FernandoOjeda/fo_nas_credentials
Fixed nas credentials issue.
2 parents 817a9a5 + 2b67bf8 commit 0190093

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

SoftLayer/CLI/nas/credentials.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ def cli(env, identifier):
1717
nw_mgr = SoftLayer.NetworkManager(env.client)
1818
result = nw_mgr.get_nas_credentials(identifier)
1919
table = formatting.Table(['username', 'password'])
20-
table.add_row([result['username'],
21-
result['password']])
20+
table.add_row([result.get('username', 'None'),
21+
result.get('password', 'None')])
2222
env.fout(table)

tests/CLI/modules/nas_tests.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,32 @@ def test_list_nas(self):
1919
'server': '127.0.0.1',
2020
'id': 1,
2121
'size': 10}])
22+
23+
def test_nas_credentials(self):
24+
result = self.run_command(['nas', 'credentials', '12345'])
25+
self.assert_no_fail(result)
26+
self.assertEqual(json.loads(result.output),
27+
[{
28+
'password': '',
29+
'username': 'username'
30+
}])
31+
32+
def test_server_credentials_exception_password_not_found(self):
33+
mock = self.set_mock('SoftLayer_Network_Storage', 'getObject')
34+
35+
mock.return_value = {
36+
"accountId": 11111,
37+
"capacityGb": 20,
38+
"id": 22222,
39+
"nasType": "NAS",
40+
"serviceProviderId": 1,
41+
"username": "SL01SEV307",
42+
"credentials": []
43+
}
44+
45+
result = self.run_command(['nas', 'credentials', '12345'])
46+
47+
self.assertEqual(
48+
'None',
49+
str(result.exception)
50+
)

0 commit comments

Comments
 (0)