salesforce bot: Quit on invalid API key.
This commit is contained in:
parent
8417dbf154
commit
57342072dc
|
@ -163,9 +163,7 @@ class SalesforceHandler(object):
|
||||||
security_token=self.config_info['security_token']
|
security_token=self.config_info['security_token']
|
||||||
)
|
)
|
||||||
except simple_salesforce.exceptions.SalesforceAuthenticationFailed as err:
|
except simple_salesforce.exceptions.SalesforceAuthenticationFailed as err:
|
||||||
logging.error(
|
bot_handler.quit('Failed to log in to Salesforce. {} {}'.format(err.code, err.message))
|
||||||
'Failed to log in to Salesforce. {} {}'.format(err.code, err.message))
|
|
||||||
quit()
|
|
||||||
|
|
||||||
def handle_message(self, message: Any, bot_handler: Any) -> None:
|
def handle_message(self, message: Any, bot_handler: Any) -> None:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from zulip_bots.test_lib import BotTestCase, read_bot_fixture_data
|
from zulip_bots.test_lib import BotTestCase, StubBotHandler, read_bot_fixture_data
|
||||||
import simple_salesforce
|
import simple_salesforce
|
||||||
from simple_salesforce.exceptions import SalesforceAuthenticationFailed
|
from simple_salesforce.exceptions import SalesforceAuthenticationFailed
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
@ -174,11 +174,8 @@ class TestSalesforceBot(BotTestCase):
|
||||||
'Usage: find contact <name> [arguments]')
|
'Usage: find contact <name> [arguments]')
|
||||||
|
|
||||||
def test_bad_auth(self) -> None:
|
def test_bad_auth(self) -> None:
|
||||||
with self.assertLogs(level='ERROR') as log, \
|
with self.assertRaises(StubBotHandler.BotQuitException):
|
||||||
patch('builtins.quit'):
|
|
||||||
self._test_initialize(auth_success=False)
|
self._test_initialize(auth_success=False)
|
||||||
self.assertIn(
|
|
||||||
'ERROR:root:Failed to log in to Salesforce. 403 auth failed', log.output)
|
|
||||||
|
|
||||||
def test_callback(self) -> None:
|
def test_callback(self) -> None:
|
||||||
self._test('test_one_result', 'echo hello', 'hello')
|
self._test('test_one_result', 'echo hello', 'hello')
|
||||||
|
|
Loading…
Reference in a new issue