Skip to content

Commit d833f77

Browse files
committed
softlayer#1410 add username lookup test to slcli object-storage credential list
1 parent 35f7a0c commit d833f77

1 file changed

Lines changed: 6 additions & 19 deletions

File tree

tests/CLI/modules/object_storage_tests.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
:license: MIT, see LICENSE for more details.
66
"""
77
import json
8+
from unittest import mock
89

910
from SoftLayer import testing
1011

@@ -82,25 +83,11 @@ def test_limit_credential(self):
8283
self.assertEqual(json.loads(result.output), [{'limit': 2}])
8384

8485
def test_list_credential(self):
85-
accounts = self.set_mock('SoftLayer_Network_Storage_Hub_Cleversafe_Account', 'getCredentials')
86-
accounts.return_value = [{'id': 1103123,
87-
'password': 'nwUEUsx6PiEoN0B1Xe9z9hUCyXM',
88-
'type': {'name': 'S3 Compatible Signature'},
89-
'username': 'XfHhBNBPlPdlWya'},
90-
{'id': 1103333,
91-
'password': 'nwUEUsx6PiEoN0B1Xe9z9',
92-
'type': {'name': 'S3 Compatible Signature'},
93-
'username': 'XfHhBNBPlPd'}]
94-
9586
result = self.run_command(['object-storage', 'credential', 'list', '100'])
87+
self.assert_no_fail(result)
9688

89+
@mock.patch('SoftLayer.CLI.helpers.resolve_id')
90+
def test_list_credential_by_username(self, resolve_id_mock):
91+
resolve_id_mock.return_value = 100
92+
result = self.run_command(['object-storage', 'credential', 'list', 'test'])
9793
self.assert_no_fail(result)
98-
self.assertEqual(json.loads(result.output),
99-
[{'id': 1103123,
100-
'password': 'nwUEUsx6PiEoN0B1Xe9z9hUCyXM',
101-
'type_name': 'S3 Compatible Signature',
102-
'username': 'XfHhBNBPlPdlWya'},
103-
{'id': 1103333,
104-
'password': 'nwUEUsx6PiEoN0B1Xe9z9',
105-
'type_name': 'S3 Compatible Signature',
106-
'username': 'XfHhBNBPlPd'}])

0 commit comments

Comments
 (0)