Skip to content

Commit 04d40a6

Browse files
committed
Fixed exceptin in push manager when auth response is empty
1 parent 703b5cd commit 04d40a6

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

splitio/push/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def _trigger_connection_flow(self):
143143
self._feedback_loop.put(Status.PUSH_RETRYABLE_ERROR)
144144
return
145145

146-
if not token.push_enabled:
146+
if token is None or not token.push_enabled:
147147
self._feedback_loop.put(Status.PUSH_NONRETRYABLE_ERROR)
148148
return
149149
self._telemetry_runtime_producer.record_token_refreshes()

tests/push/test_manager.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,28 @@ def new_start(*args, **kwargs): # pylint: disable=unused-argument
9090
assert feedback_loop.get() == Status.PUSH_RETRYABLE_ERROR
9191
assert timer_mock.mock_calls == [mocker.call(0, Any())]
9292

93+
def test_empty_auth_respnse(self, mocker):
94+
"""Test the initial status is ok and reset() works as expected."""
95+
api_mock = mocker.Mock()
96+
api_mock.authenticate.return_value = None
97+
98+
sse_mock = mocker.Mock(spec=SplitSSEClient)
99+
sse_constructor_mock = mocker.Mock()
100+
sse_constructor_mock.return_value = sse_mock
101+
timer_mock = mocker.Mock()
102+
mocker.patch('splitio.push.manager.Timer', new=timer_mock)
103+
mocker.patch('splitio.push.manager.SplitSSEClient', new=sse_constructor_mock)
104+
feedback_loop = Queue()
105+
telemetry_storage = InMemoryTelemetryStorage()
106+
telemetry_producer = TelemetryStorageProducer(telemetry_storage)
107+
telemetry_runtime_producer = telemetry_producer.get_telemetry_runtime_producer()
108+
manager = PushManager(api_mock, mocker.Mock(), feedback_loop, mocker.Mock(), telemetry_runtime_producer)
109+
manager.start()
110+
assert feedback_loop.get() == Status.PUSH_NONRETRYABLE_ERROR
111+
assert timer_mock.mock_calls == [mocker.call(0, Any())]
112+
assert sse_mock.mock_calls == []
113+
114+
93115
def test_push_disabled(self, mocker):
94116
"""Test the initial status is ok and reset() works as expected."""
95117
api_mock = mocker.Mock()

0 commit comments

Comments
 (0)