Skip to content

Commit 9cd5ec5

Browse files
committed
Merge branch 'master' into issue1916
2 parents 0d7a72c + 1fe304c commit 9cd5ec5

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

SoftLayer/CLI/event_log/get.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import SoftLayer
77
from SoftLayer.CLI import environment
8-
from SoftLayer.CLI import exceptions
8+
from SoftLayer import exceptions
99
from SoftLayer import utils
1010

1111

@@ -40,6 +40,7 @@ def cli(env, date_min, date_max, obj_event, obj_id, obj_type, utc_offset, metada
4040
request_filter = event_mgr.build_filter(date_min, date_max, obj_event, obj_id, obj_type, utc_offset)
4141
logs = event_mgr.get_event_logs(request_filter)
4242
log_time = "%Y-%m-%dT%H:%M:%S.%f%z"
43+
# A list of IDs that we have looked up user information about.
4344
user_data = {}
4445

4546
if metadata:
@@ -59,9 +60,11 @@ def cli(env, date_min, date_max, obj_event, obj_id, obj_type, utc_offset, metada
5960
if username is None:
6061
try:
6162
username = user_mgr.get_user(log['userId'], "mask[username]")['username']
62-
user_data[log['userId']] = username
63+
# Some users might not be able to access information about this specific userId
6364
except exceptions.SoftLayerAPIError:
6465
username = log['userId']
66+
# This keeps track of any users we asked the API about, so we can make fewer calls.
67+
user_data[log['userId']] = username
6568
user = username
6669

6770
if metadata:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
'prompt_toolkit >= 2',
4141
'pygments >= 2.0.0',
4242
'urllib3 >= 1.24',
43-
'rich == 13.3.3'
43+
'rich == 13.3.4'
4444
],
4545
keywords=['softlayer', 'cloud', 'slcli'],
4646
classifiers=[

tests/CLI/modules/event_log_tests.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import json
88

9+
from SoftLayer import SoftLayerAPIError
910
from SoftLayer import testing
1011

1112

@@ -91,3 +92,16 @@ def test_get_unlimited_events(self):
9192
self.assert_no_fail(result)
9293
self.assert_called_with('SoftLayer_Event_Log', 'getAllObjects')
9394
self.assertEqual(8, result.output.count("\n"))
95+
96+
def test_issues1905(self):
97+
"""https://github.com/softlayer/softlayer-python/issues/1905"""
98+
getUser = self.set_mock('SoftLayer_User_Customer', 'getObject')
99+
getUser.side_effect = SoftLayerAPIError(
100+
"SoftLayer_Exception_PermissionDenied",
101+
"You do not have permission to access this user")
102+
result = self.run_command(['event-log', 'get', '-l -1'])
103+
self.assert_no_fail(result)
104+
self.assert_called_with('SoftLayer_Event_Log', 'getAllObjects')
105+
self.assert_called_with('SoftLayer_User_Customer', 'getObject', identifier=400)
106+
user_calls = self.calls('SoftLayer_User_Customer', 'getObject')
107+
self.assertEqual(1, len(user_calls))

tools/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ requests >= 2.20.0
44
prompt_toolkit >= 2
55
pygments >= 2.0.0
66
urllib3 >= 1.24
7-
rich == 13.3.3
7+
rich == 13.3.4
88
# only used for soap transport
99
# softlayer-zeep >= 5.0.0

0 commit comments

Comments
 (0)