[extensions-web: 10/11] update-check: validate extension version.
- From: Yuri Konotopov <ykonotopov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web: 10/11] update-check: validate extension version.
- Date: Tue, 29 Nov 2016 19:46:11 +0000 (UTC)
commit f0604d2bf52c68128269e99c582ac7308da56061
Author: Yuri Konotopov <ykonotopov gnome org>
Date: Tue Nov 29 22:41:49 2016 +0300
update-check: validate extension version.
Assume that user has version 1 of extension if it has provided wrong
version.
sweettooth/extensions/tests.py | 13 +++++++++++++
sweettooth/extensions/views.py | 4 +++-
2 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/sweettooth/extensions/tests.py b/sweettooth/extensions/tests.py
index 0319c9b..ffa3839 100644
--- a/sweettooth/extensions/tests.py
+++ b/sweettooth/extensions/tests.py
@@ -527,6 +527,19 @@ class UpdateVersionTest(TestCase):
response = self.grab_response(installed)
self.assertEqual(self.full_expected, response)
+ def test_wrong_version(self):
+ uuid = self.upgrade_uuid
+
+ # The user provided wrong version, upgrade him if we have version > 1
+ expected = {uuid: self.full_expected[self.upgrade_uuid]}
+ response = self.grab_response({uuid: ''})
+ self.assertEqual(response, expected)
+
+ expected = {uuid: self.full_expected[self.upgrade_uuid]}
+ response = self.grab_response({uuid: '0.8.4'})
+ self.assertEqual(response, expected)
+
+
class QueryExtensionsTest(BasicUserTestCase, TestCase):
def get_response(self, params):
response = self.client.get(reverse('extensions-query'), params)
diff --git a/sweettooth/extensions/views.py b/sweettooth/extensions/views.py
index 1543ace..ad2b987 100644
--- a/sweettooth/extensions/views.py
+++ b/sweettooth/extensions/views.py
@@ -89,11 +89,13 @@ def shell_update(request):
for uuid, meta in installed.iteritems():
try:
- version = meta['version']
+ version = int(meta['version'])
except (KeyError, TypeError):
# XXX - if the user has a locally installed version of
# an extension on SweetTooth, what should we do?
continue
+ except ValueError:
+ version = 1
try:
extension = models.Extension.objects.get(uuid=uuid)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]