streams: Fix bug that allows 0 value for message_retention_days.

This commit is contained in:
Pragati Agrawal 2020-06-21 14:20:01 +05:30 committed by Tim Abbott
parent 72dd5bfa77
commit 7b3f4755ff
2 changed files with 5 additions and 1 deletions

View File

@ -938,6 +938,10 @@ class StreamAdminTest(ZulipTestCase):
{'message_retention_days': ujson.dumps(-1)})
self.assert_json_error(result, "Bad value for 'message_retention_days': -1")
result = self.client_patch(f'/json/streams/{stream.id}',
{'message_retention_days': ujson.dumps(0)})
self.assert_json_error(result, "Bad value for 'message_retention_days': 0")
def test_change_stream_message_retention_days_requires_realm_owner(self) -> None:
user_profile = self.example_user('iago')
self.login_user(user_profile)

View File

@ -134,7 +134,7 @@ def parse_message_retention_days(value: Union[int, str]) -> Optional[int]:
return -1
if value == "realm_default":
return None
if isinstance(value, str) or value < 0:
if isinstance(value, str) or value <= 0:
raise RequestVariableConversionError('message_retention_days', value)
assert isinstance(value, int)
return value