Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
bots: Reject config_data updates for bots that are not embedded.
Evy Kassirer4eb9c5e56e9d
diff --git a/zerver/tests/test_bots.py b/zerver/tests/test_bots.pyindex 7571e8b5e3c..781f97b6660 100644--- a/zerver/tests/test_bots.py+++ b/zerver/tests/test_bots.py@@ -2044,6 +2044,18 @@ class BotTest(ZulipTestCase, UploadSerializeMixin):config_data = orjson.loads(result.content)["config_data"]self.assertEqual(config_data, orjson.loads(bot_info["config_data"]))+ def test_patch_bot_config_data_for_non_embedded_bot(self) -> None:+ self.create_test_bot(+ "test",+ self.example_user("hamlet"),+ full_name="Bot without config data",+ bot_type=UserProfile.DEFAULT_BOT,+ )+ bot_info = {"config_data": orjson.dumps({"key": "87654321"}).decode()}+ email = "[email protected]"+ result = self.client_patch(f"/json/bots/{self.get_bot_user(email).id}", bot_info)+ self.assert_json_error(result, "Only embedded bots have config_data.")+def test_outgoing_webhook_invalid_interface(self) -> None:self.login("hamlet")bot_info = {diff --git a/zerver/views/users.py b/zerver/views/users.pyindex 19ba3005748..444ad1ab547 100644--- a/zerver/views/users.py+++ b/zerver/views/users.py@@ -563,6 +563,8 @@ def patch_bot_backend()if config_data is not None:+ if bot.bot_type != UserProfile.EMBEDDED_BOT:+ raise JsonableError(_("Only embedded bots have config_data."))do_update_bot_config_data(bot, config_data)if len(request.FILES) == 0: