mirror of https://github.com/zulip/zulip.git
urls: Use POST for zerver.views.realm_icon.upload_icon.
This upload_icon endpoint is changed from PUT to POST becuase this endpoint is not idempotent.
This commit is contained in:
parent
0606ba88df
commit
cf2dec539f
|
@ -310,7 +310,7 @@ function test_upload_realm_icon(upload_realm_icon) {
|
|||
];
|
||||
|
||||
var posted;
|
||||
channel.put = function (req) {
|
||||
channel.post = function (req) {
|
||||
posted = true;
|
||||
assert.equal(req.url, '/json/realm/icon');
|
||||
assert.equal(req.data.csrfmiddlewaretoken, 'token-stub');
|
||||
|
|
|
@ -634,7 +634,7 @@ function _set_up() {
|
|||
var spinner = $("#upload_icon_spinner").expectOne();
|
||||
loading.make_indicator(spinner, {text: i18n.t("Uploading icon.")});
|
||||
|
||||
channel.put({
|
||||
channel.post({
|
||||
url: '/json/realm/icon',
|
||||
data: form_data,
|
||||
cache: false,
|
||||
|
|
|
@ -801,7 +801,7 @@ class RealmIconTest(UploadSerializeMixin, ZulipTestCase):
|
|||
self.login(self.example_email("iago"))
|
||||
with get_test_image_file('img.png') as fp1, \
|
||||
get_test_image_file('img.png') as fp2:
|
||||
result = self.client_put_multipart("/json/realm/icon", {'f1': fp1, 'f2': fp2})
|
||||
result = self.client_post("/json/realm/icon", {'f1': fp1, 'f2': fp2})
|
||||
self.assert_json_error(result, "You must upload exactly one icon.")
|
||||
|
||||
def test_no_file_upload_failure(self):
|
||||
|
@ -811,7 +811,7 @@ class RealmIconTest(UploadSerializeMixin, ZulipTestCase):
|
|||
"""
|
||||
self.login(self.example_email("iago"))
|
||||
|
||||
result = self.client_put_multipart("/json/realm/icon")
|
||||
result = self.client_post("/json/realm/icon")
|
||||
self.assert_json_error(result, "You must upload exactly one icon.")
|
||||
|
||||
correct_files = [
|
||||
|
@ -826,7 +826,7 @@ class RealmIconTest(UploadSerializeMixin, ZulipTestCase):
|
|||
# type: () -> None
|
||||
self.login(self.example_email("hamlet"))
|
||||
with get_test_image_file(self.correct_files[0][0]) as fp:
|
||||
result = self.client_put_multipart("/json/realm/icon", {'file': fp})
|
||||
result = self.client_post("/json/realm/icon", {'file': fp})
|
||||
self.assert_json_error(result, 'Must be a realm administrator')
|
||||
|
||||
def test_get_gravatar_icon(self):
|
||||
|
@ -867,7 +867,7 @@ class RealmIconTest(UploadSerializeMixin, ZulipTestCase):
|
|||
# with self.subTest(fname=fname):
|
||||
self.login(self.example_email("iago"))
|
||||
with get_test_image_file(fname) as fp:
|
||||
result = self.client_put_multipart("/json/realm/icon", {'file': fp})
|
||||
result = self.client_post("/json/realm/icon", {'file': fp})
|
||||
realm = get_realm('zulip')
|
||||
self.assert_json_success(result)
|
||||
json = ujson.loads(result.content)
|
||||
|
@ -890,7 +890,7 @@ class RealmIconTest(UploadSerializeMixin, ZulipTestCase):
|
|||
# with self.subTest(fname=fname):
|
||||
self.login(self.example_email("iago"))
|
||||
with get_test_image_file(fname) as fp:
|
||||
result = self.client_put_multipart("/json/realm/icon", {'file': fp})
|
||||
result = self.client_post("/json/realm/icon", {'file': fp})
|
||||
|
||||
self.assert_json_error(result, "Could not decode image; did you upload an image file?")
|
||||
|
||||
|
@ -920,7 +920,7 @@ class RealmIconTest(UploadSerializeMixin, ZulipTestCase):
|
|||
icon_version = realm.icon_version
|
||||
self.assertEqual(icon_version, 1)
|
||||
with get_test_image_file(self.correct_files[0][0]) as fp:
|
||||
self.client_put_multipart("/json/realm/icon", {'file': fp})
|
||||
self.client_post("/json/realm/icon", {'file': fp})
|
||||
realm = get_realm('zulip')
|
||||
self.assertEqual(realm.icon_version, icon_version + 1)
|
||||
|
||||
|
@ -929,7 +929,7 @@ class RealmIconTest(UploadSerializeMixin, ZulipTestCase):
|
|||
self.login(self.example_email("iago"))
|
||||
with get_test_image_file(self.correct_files[0][0]) as fp:
|
||||
with self.settings(MAX_ICON_FILE_SIZE=0):
|
||||
result = self.client_put_multipart("/json/realm/icon", {'file': fp})
|
||||
result = self.client_post("/json/realm/icon", {'file': fp})
|
||||
self.assert_json_error(result, "Uploaded file is larger than the allowed limit of 0 MB")
|
||||
|
||||
def tearDown(self):
|
||||
|
|
|
@ -196,7 +196,7 @@ v1_api_and_json_patterns = [
|
|||
|
||||
# realm/icon -> zerver.views.realm_icon
|
||||
url(r'^realm/icon$', rest_dispatch,
|
||||
{'PUT': 'zerver.views.realm_icon.upload_icon',
|
||||
{'POST': 'zerver.views.realm_icon.upload_icon',
|
||||
'DELETE': 'zerver.views.realm_icon.delete_icon_backend',
|
||||
'GET': 'zerver.views.realm_icon.get_icon_backend'}),
|
||||
|
||||
|
|
Loading…
Reference in New Issue