mirror of https://github.com/zulip/zulip.git
update_storage: Validate storage type correctly.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
717e349834
commit
c584462b32
|
@ -299,7 +299,7 @@ class TestServiceBotStateHandler(ZulipTestCase):
|
|||
'storage': ujson.dumps({'foo': [1, 2, 3]}),
|
||||
}
|
||||
result = self.client_put('/json/bot_storage', params)
|
||||
self.assert_json_error(result, "Value type is <class 'list'>, but should be str.")
|
||||
self.assert_json_error(result, "storage contains a value that is not a string")
|
||||
|
||||
# Remove some entries.
|
||||
keys_to_remove = ['key 1', 'key 2']
|
||||
|
|
|
@ -16,11 +16,13 @@ from zerver.models import UserProfile
|
|||
|
||||
|
||||
@has_request_variables
|
||||
def update_storage(request: HttpRequest, user_profile: UserProfile,
|
||||
storage: Dict[str, str]=REQ(validator=check_dict([]))) -> HttpResponse:
|
||||
def update_storage(
|
||||
request: HttpRequest, user_profile: UserProfile,
|
||||
storage: Dict[str, str]=REQ(validator=check_dict([], value_validator=check_string)),
|
||||
) -> HttpResponse:
|
||||
try:
|
||||
set_bot_storage(user_profile, list(storage.items()))
|
||||
except StateError as e:
|
||||
except StateError as e: # nocoverage
|
||||
return json_error(str(e))
|
||||
return json_success()
|
||||
|
||||
|
|
Loading…
Reference in New Issue