mirror of https://github.com/zulip/zulip.git
Add events for bot api_key changes
(imported from commit 44e4e374ee4951c4d984c009ef7af825985fabbf)
This commit is contained in:
parent
64ba85aa19
commit
c0d104c110
|
@ -1333,6 +1333,13 @@ def do_regenerate_api_key(user_profile, log=True):
|
||||||
log_event({'type': 'user_change_api_key',
|
log_event({'type': 'user_change_api_key',
|
||||||
'user': user_profile.email})
|
'user': user_profile.email})
|
||||||
|
|
||||||
|
if user_profile.is_bot:
|
||||||
|
send_event(dict(type='realm_bot',
|
||||||
|
op='update',
|
||||||
|
bot=dict(email=user_profile.email,
|
||||||
|
api_key=user_profile.api_key,)),
|
||||||
|
bot_owner_userids(user_profile))
|
||||||
|
|
||||||
def _default_stream_permision_check(user_profile, stream):
|
def _default_stream_permision_check(user_profile, stream):
|
||||||
# Any user can have a None default stream
|
# Any user can have a None default stream
|
||||||
if stream is not None:
|
if stream is not None:
|
||||||
|
|
|
@ -24,6 +24,7 @@ from zerver.lib.actions import (
|
||||||
do_set_realm_name,
|
do_set_realm_name,
|
||||||
do_update_pointer,
|
do_update_pointer,
|
||||||
do_create_user,
|
do_create_user,
|
||||||
|
do_regenerate_api_key,
|
||||||
fetch_initial_state_data,
|
fetch_initial_state_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -289,6 +290,12 @@ class EventsRegisterTest(AuthedTestCase):
|
||||||
error = self.build_update_checker('full_name', check_string)('events[1]', events[1])
|
error = self.build_update_checker('full_name', check_string)('events[1]', events[1])
|
||||||
self.assert_on_error(error)
|
self.assert_on_error(error)
|
||||||
|
|
||||||
|
def test_regenerate_bot_api_key(self):
|
||||||
|
action = lambda: do_regenerate_api_key(self.bot)
|
||||||
|
events = self.do_test(action)
|
||||||
|
error = self.build_update_checker('api_key', check_string)('events[0]', events[0])
|
||||||
|
self.assert_on_error(error)
|
||||||
|
|
||||||
def test_rename_stream(self):
|
def test_rename_stream(self):
|
||||||
realm = get_realm('zulip.com')
|
realm = get_realm('zulip.com')
|
||||||
stream, _ = create_stream_if_needed(realm, 'old_name')
|
stream, _ = create_stream_if_needed(realm, 'old_name')
|
||||||
|
|
Loading…
Reference in New Issue