Files are flagged when the validator says they require chrome (bug 694655)
This commit is contained in:
Родитель
637e788c79
Коммит
684e1626a7
|
@ -56,7 +56,8 @@ class File(amo.models.OnChangeMixin, amo.models.ModelBase):
|
|||
default=amo.STATUS_UNREVIEWED)
|
||||
datestatuschanged = models.DateTimeField(null=True, auto_now_add=True)
|
||||
no_restart = models.BooleanField(default=False)
|
||||
|
||||
# The XPI contains JS that calls require("chrome").
|
||||
requires_chrome = models.BooleanField(default=False)
|
||||
reviewed = models.DateTimeField(null=True)
|
||||
|
||||
class Meta(amo.models.ModelBase.Meta):
|
||||
|
@ -154,6 +155,10 @@ class File(amo.models.OnChangeMixin, amo.models.ModelBase):
|
|||
f.hash = (f.generate_hash(upload.path)
|
||||
if waffle.switch_is_active('file-hash-paranoia')
|
||||
else upload.hash)
|
||||
if upload.validation:
|
||||
validation = json.loads(upload.validation)
|
||||
if validation['metadata'].get('requires_chrome'):
|
||||
f.requires_chrome = True
|
||||
f.save()
|
||||
log.debug('New file: %r from %r' % (f, upload))
|
||||
# Move the uploaded file from the temp location.
|
||||
|
|
|
@ -453,6 +453,8 @@ class TestParseAlternateXpi(amo.tests.TestCase, amo.tests.AMOPaths):
|
|||
|
||||
|
||||
class TestFileUpload(UploadTest):
|
||||
fixtures = ['applications/all_apps.json', 'base/appversion',
|
||||
'base/addon_3615']
|
||||
|
||||
def setUp(self):
|
||||
super(TestFileUpload, self).setUp()
|
||||
|
@ -510,6 +512,28 @@ class TestFileUpload(UploadTest):
|
|||
fu = FileUpload.from_post('', u'\u05d0\u05d5\u05e1\u05e3.xpi', 0)
|
||||
assert 'xpi' in fu.name
|
||||
|
||||
def test_validator_sets_require_chrome(self):
|
||||
validation = json.dumps({
|
||||
"errors": 0,
|
||||
"success": True,
|
||||
"warnings": 0,
|
||||
"notices": 0,
|
||||
"message_tree": {},
|
||||
"messages": [],
|
||||
"metadata": {
|
||||
"contains_binary_extension": True,
|
||||
"version": "1.0",
|
||||
"name": "gK0Bes Bot",
|
||||
"id": "gkobes@gkobes",
|
||||
"requires_chrome": True
|
||||
}
|
||||
})
|
||||
upload = self.get_upload(filename='extension.xpi', validation=validation)
|
||||
version = Version.objects.filter(addon__pk=3615)[0]
|
||||
plat = Platform.objects.get(pk=amo.PLATFORM_LINUX.id)
|
||||
file_ = File.from_upload(upload, version, plat)
|
||||
eq_(file_.requires_chrome, True)
|
||||
|
||||
|
||||
class TestFileFromUpload(UploadTest):
|
||||
fixtures = ['base/apps']
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE files ADD COLUMN requires_chrome bool NOT NULL DEFAULT 0;
|
Загрузка…
Ссылка в новой задаче