Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions SoftLayer/CLI/nas/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ def cli(env, identifier):
nw_mgr = SoftLayer.NetworkManager(env.client)
result = nw_mgr.get_nas_credentials(identifier)
table = formatting.Table(['username', 'password'])
table.add_row([result['username'],
result['password']])
table.add_row([result.get('username', 'None'),
result.get('password', 'None')])
env.fout(table)
29 changes: 29 additions & 0 deletions tests/CLI/modules/nas_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,32 @@ def test_list_nas(self):
'server': '127.0.0.1',
'id': 1,
'size': 10}])

def test_nas_credentials(self):
result = self.run_command(['nas', 'credentials', '12345'])
self.assert_no_fail(result)
self.assertEqual(json.loads(result.output),
[{
'password': '',
'username': 'username'
}])

def test_server_credentials_exception_password_not_found(self):
mock = self.set_mock('SoftLayer_Network_Storage', 'getObject')

mock.return_value = {
"accountId": 11111,
"capacityGb": 20,
"id": 22222,
"nasType": "NAS",
"serviceProviderId": 1,
"username": "SL01SEV307",
"credentials": []
}

result = self.run_command(['nas', 'credentials', '12345'])

self.assertEqual(
'None',
str(result.exception)
)