def test_allow_static_theme_waffle(self): manifest = utils.ManifestJSONExtractor( '/fake_path', '{"theme": {}}').parse() utils.check_xpi_info(manifest) assert self.parse({'theme': {}})['type'] == amo.ADDON_STATICTHEME
def test_too_long_uuid(self): """An add-on uuid must be 64chars at most, see bug 1201176.""" with self.assertRaises(forms.ValidationError) as exc: check_xpi_info({ 'guid': u'this_guid_is_longer_than_the_limit_of_64_chars_see_' u'bug_1201176_and_should_fail@xpi'}) expected = 'Add-on ID must be 64 characters or less.' assert exc.exception.message == expected
def test_disallow_static_theme(self): manifest = utils.ManifestJSONExtractor( '/fake_path', '{"theme": {}}').parse() with pytest.raises(forms.ValidationError) as exc: utils.check_xpi_info(manifest) assert ( exc.value.message == 'WebExtension theme uploads are currently not supported.')
def test_long_uuid(self): """An add-on uuid may be more than 64 chars, see bug 1203915.""" self.create_switch('allow-long-addon-guid') long_guid = (u'this_guid_is_longer_than_the_limit_of_64_chars_see_' u'bug_1201176_but_should_not_fail_see_bug_1203915@xpi') xpi_info = check_xpi_info({'guid': long_guid, 'version': '1.0'}) assert xpi_info['guid'] == long_guid
def test_static_theme_max_size(self, getsize_mock): getsize_mock.return_value = settings.MAX_STATICTHEME_SIZE manifest = utils.ManifestJSONExtractor( '/fake_path', '{"theme": {}}').parse() # Calling to check it doesn't raise. assert utils.check_xpi_info(manifest, xpi_file=mock.Mock()) # Increase the size though and it should raise an error. getsize_mock.return_value = settings.MAX_STATICTHEME_SIZE + 1 with pytest.raises(forms.ValidationError) as exc: utils.check_xpi_info(manifest, xpi_file=mock.Mock()) assert ( exc.value.message == u'Maximum size for WebExtension themes is 7.0 MB.') # dpuble check only static themes are limited manifest = utils.ManifestJSONExtractor( '/fake_path', '{}').parse() assert utils.check_xpi_info(manifest, xpi_file=mock.Mock())
def test_long_version_number(self): with self.assertRaises(forms.ValidationError) as e: check_xpi_info({'guid': 'guid', 'version': '1' * 33}) msg = e.exception.messages[0] assert msg == 'Version numbers should have fewer than 32 characters.'
def test_bad_version_number(self): with self.assertRaises(forms.ValidationError) as e: check_xpi_info({'guid': 'guid', 'version': 'bad #version'}) msg = e.exception.messages[0] assert msg.startswith('Version numbers should only contain'), msg
def test_good_version_number(self): check_xpi_info({'guid': 'guid', 'version': '1.2a-b+32*__yeah'}) check_xpi_info({'guid': 'guid', 'version': '1' * 32})
def test_disallow_regular_submission_of_site_permission_addons_normal_user(self): user = user_factory() parsed_data = self.parse() with self.assertRaises(ValidationError): utils.check_xpi_info(parsed_data, user=user)
def test_long_uuid(self): """An add-on uuid may be more than 64 chars, see bug 1203915.""" long_guid = (u'this_guid_is_longer_than_the_limit_of_64_chars_see_' u'bug_1201176_but_should_not_fail_see_bug_1203915@xpi') xpi_info = check_xpi_info({'guid': long_guid, 'version': '1.0'}) assert xpi_info['guid'] == long_guid
def test_allow_submission_of_site_permissions_addons_from_task_user(self): user = user_factory(pk=settings.TASK_USER_ID) parsed_data = self.parse() assert parsed_data['type'] == amo.ADDON_SITE_PERMISSION assert parsed_data['site_permissions'] == ['webmidi'] assert utils.check_xpi_info(parsed_data, user=user)
def test_static_theme(self): manifest = utils.ManifestJSONExtractor('{"theme": {}}').parse() utils.check_xpi_info(manifest) assert self.parse({'theme': {}})['type'] == amo.ADDON_STATICTHEME